Phoenix installed system-wide and Classic in a VE

30 views
Skip to first unread message

Ken Vives

unread,
Nov 20, 2015, 9:34:51 AM11/20/15
to wxPython-users
Hello,

I have developed an application on Windows using my system-wide installed version of Phoenix and now would like to distribute it.
I have code that detects if wxPython is installed and will install Phoenix if it is not present.
Now I would like to write and test code to make the necessary changes if the user has Classic already installed. My initial thought was to install Classic in a virtualenv (VE).

Searching around, most solutions show creating symbolic links in the VE to the system installed version of wxPython which does not seem like a viable solution.

Is there any way to install classic to a VE and not affect the system's installation of Phoenix (i.e. from command-line can I just activate the VE and run the installation .exe)?

Or is there any way for Classic and Phoenix to co-exist system-wide?

Am I going about this the wrong way?

Thanks,
Ken

Chris Barker - NOAA Federal

unread,
Nov 20, 2015, 11:33:43 AM11/20/15
to wxpytho...@googlegroups.com
There is nothing about Classic that is incompatible with virtual environments-- it's the old-style Windows installer that's incompatible. 

But I'm pretty sure there is a utility out there that can convert an msi installer to a wheel, and then you can install that in a virtualenv.

 If not, it wouldn't be hard to build a shell yourself -- it's a well defined zip archive.

-CHB
--
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.

Dietmar Schwertberger

unread,
Nov 20, 2015, 1:33:03 PM11/20/15
to wxpytho...@googlegroups.com
Am 20.11.2015 um 15:34 schrieb Ken Vives:
> Hello,
>
> I have developed an application on Windows using my system-wide
> installed version of Phoenix and now would like to distribute it.
> I have code that detects if wxPython is installed and will install
> Phoenix if it is not present.

Is there anything stopping you to build wxPhoenix into a directory
outside Lib/site-packages, e.g. in your application directory?
Then add this directory to the path using sys.path.insert(0, "...path to
Phoenix ...")
It's not nice but probably the easiest way. Otherwise install into
site-packages as wxPhoenix instead of wx and use "import wxPhoenix as wx".

Regards,

Dietmar

Ken Vives

unread,
Nov 20, 2015, 5:11:21 PM11/20/15
to wxPython-users
I found that using the .exe and selecting the site-packages directory in the VE and deselecting to make it the default worked fine.

This is what I've come up with so far:

#!/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



Reply all
Reply to author
Forward
0 new messages