--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
def InstallDependencies(dependency_dict):
'''
Will try to install missing dependencies via pip install.
Takes a dict argument in format:
{'module to import':['pip arguments to use to retrieve module'],}
If dict value is empty list, will pass key to pip for install.
TODO: Error handling
'''
try:
import pip, importlib, copy
except ImportError:
raise
pip_args = [ '-vvv' ]
try:
proxy = os.environ['http_proxy']
except Exception as e:
proxy = None
if proxy:
pip_args.append('--proxy')
pip_args.append(proxy)
pip_args.append('install')
try:
for req in dependency_dict.keys():
pai = copy.copy(pip_args)
try:
importlib.import_module(req)
except ImportError:
if dependency_dict[req] != []:
pai.extend(dependency_dict[req])
else:
pai.append(req)
try:
res = pip.main(args=pai)
if res == 1:
raise ImportError
except Exception as e:
raise
try:
importlib.import_module(req)
except Exception as e:
raise
except Exception as e:
raise
#######################################################
try:
import wx # If Phoenix installed on system, this should import it
except ImportError: # If fails, Classic might be installed, so try to select it with wxversion
try:
import wxversion
wxversion.select('3.0')
import wx
except ImportError:
dependency_dict = {'wx':['--upgrade','--trusted-host', 'wxpython.org', '--pre', '-f', 'http://wxpython.org/Phoenix/snapshot-builds/', 'wxPython_Phoenix']}
InstallDependencies(dependency_dict)
try:
import wx
except Exception as e:
print 'Exiting due to import errors: %s' % str(e)
import sys
sys.exit(-1)
try:
InstallDependencies({'concurrent.futures':['futures']})
except Exception as e:
print 'Exiting due to import errors: %s' % str(e)
import sys
sys.exit(-1)
if 'phoenix'in wx.PlatformInfo:
PHOENIX = True
else:
PHOENIX = False