ETS on 'portable' python.

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

ETS on 'portable' python.

Jordan Ilott-2
Hello all, I wanted to share my experience getting Traits, TraitsUI and Chaco working on Windows with PySide without installing anything.

In order to have strict control over the Python environment in which my application is running, I wanted to either 'freeze' the application or build a distribution that supported running without installation. I was not successful at freezing but I was able to package my application into a single folder with its own local Python.

I began with PortablePython and extracted it keeping only Numpy and PIL selected(I was trying to minimize the size). PortablePython includes easy_install, and this made it simple to install cython, configobj, pandas, ReportLab and PySide from a Windows shell.

It was also necessary for me to copy the VC2008 crt dlls and manifest to the PySide folder in order to prevent DLL import errors with PySide apps at run time. I was able to confirm that several of the demos included with PySide were functioning correctly at this point in the process.

With PySide installed, I proceed to install the ETS packages that I needed to use. The list included: traits, apptools, etsproxy, pyface, traitsui, enable, and Chaco. I simply cloned the Git repositories and ran setup.py install . At this point the result was a relatively small Python environment with the packages I needed.

I found some Chaco demos were failing without SciPy and so I installed it as well. I downloaded the super package from the SourceForge page but found that I had to manually set some registry keys so that the installer could find my python 'installation'. Once SciPy was installed, I was able to remove these registry keys without consequence. Further reading suggests that Chaco may not actually require SciPy for many applications, however, if you know you need SciPy, it can be left selected when extracting portable python.

Having done all of this, I've found that my application will run on machines that have no history of Python or Qt installations simply by copying the directory in which I installed the Python environment. Considering the complicated nature of the hidden imports used by PyFace to support multiple back-ends, this approach appeared to be much less effort than building spec and hook file for PyInstaller or any of the other freezer apps.

I hope that my experience may be of some benefit to another member of the community in the future. Let me know if you have any questions.

Jordan

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: ETS on 'portable' python.

Henry Gomersall
On Thu, 2013-04-18 at 18:17 -0500, Jordan Ilott wrote:
> Hello all, I wanted to share my experience getting Traits, TraitsUI
> and Chaco working on Windows with PySide without installing anything.

Hi Jordan,

I too spent a while trying to do exactly that.

After also failing with a freezing option, the solution I came up with
was to assume an installation of Python, PySide, numpy and distribute
and then package the program with eggs of all the necessary Enthought
tools (adding them to the sys.path of the program).

The only real problem I encountered was that when building with MinGW,
kiva (as part of enable) builds the _plat_support.pyd binary without
libgcc or libstdc++ compiled in. The resultant egg then works on the
build machine but is not portable.

I remedied it by adding ['-static-libstdc++','-static-libgcc'] to the
'extra_link_args' key of the plat_info dict in enable/kiva/agg/setup.py.

It would be great to have that happen by default when building with gcc.
Perhaps the Enthought guys can comment on this?

Cheers,

Henry

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: ETS on 'portable' python.

Joel B. Mohler
In reply to this post by Jordan Ilott-2
On 4/18/2013 7:17 PM, Jordan Ilott wrote:
Hello all, I wanted to share my experience getting Traits, TraitsUI and Chaco working on Windows with PySide without installing anything.

In order to have strict control over the Python environment in which my application is running, I wanted to either 'freeze' the application or build a distribution that supported running without installation. I was not successful at freezing but I was able to package my application into a single folder with its own local Python.

Could you enlarge on what made the freezing not successful?  I've used py2exe to package an application which includes Chaco (and thus traits, enable & kiva).  It also includes h5py & PySide.  I needed the following py2exe options which seem a fairly modest selection of py2exe special rules:

options = {}
options["py2exe"] = {"excludes": [
                        "Tkinter", # no!
                        "tcl", # no!
                        "zmq", # punt for now: see[1]
                        "matplotlib", # no!
                        "IPython"], # relies on zmq
                    "includes": [
                        "h5py.defs",
                        "h5py.utils",
                        "h5py._proxy",
                        "PySide.QtNetwork",
                        "pyface.ui.qt4.*",
                        "pyface.ui.qt4.action.*",
                        "enable.qt4.*"],
                    "dll_excludes": [
                        "MSVCP90.dll"]} # TODO:  get the msvcrt issues sorted

# [1] http://stackoverflow.com/questions/14870825/py2exe-error-libzmq-pyd-no-such-file-or-directory

I began with PortablePython and extracted it keeping only Numpy and PIL selected(I was trying to minimize the size). PortablePython includes easy_install, and this made it simple to install cython, configobj, pandas, ReportLab and PySide from a Windows shell.

There are indeed nice reasons to use a portable python install even if py2exe works.

Joel


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: ETS on 'portable' python.

Jordan Ilott-2
In reply to this post by Henry Gomersall



On Fri, Apr 19, 2013 at 3:30 AM, Henry Gomersall <[hidden email]> wrote:
On Thu, 2013-04-18 at 18:17 -0500, Jordan Ilott wrote:
> Hello all, I wanted to share my experience getting Traits, TraitsUI
> and Chaco working on Windows with PySide without installing anything.

Hi Jordan,

I too spent a while trying to do exactly that.

After also failing with a freezing option, the solution I came up with
was to assume an installation of Python, PySide, numpy and distribute
and then package the program with eggs of all the necessary Enthought
tools (adding them to the sys.path of the program).

The only real problem I encountered was that when building with MinGW,
kiva (as part of enable) builds the _plat_support.pyd binary without
libgcc or libstdc++ compiled in. The resultant egg then works on the
build machine but is not portable.

I remedied it by adding ['-static-libstdc++','-static-libgcc'] to the
'extra_link_args' key of the plat_info dict in enable/kiva/agg/setup.py.

I am using VS2008 to build the packages. I didn't mention that I had to be certain that 'vcvarsall.bat' was on the path of my build machine. I had no problems with standard libraries not being linked, but I'm not sure if Kiva is built statically by default using VS2008 or not. If not, then I may have made an oversight and there may be examples of Windows installs where my application won't run. I should probably take a look at the linking configuration of Kiva.
 
It would be great to have that happen by default when building with gcc.
Perhaps the Enthought guys can comment on this?

Cheers,

Henry

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: ETS on 'portable' python.

Henry Gomersall
In reply to this post by Joel B. Mohler
On Fri, 2013-04-19 at 07:43 -0400, Joel B. Mohler wrote:

> On 4/18/2013 7:17 PM, Jordan Ilott wrote:
>
> > Hello all, I wanted to share my experience getting Traits, TraitsUI
> > and Chaco working on Windows with PySide without installing
> > anything.
> >
> >
> > In order to have strict control over the Python environment in which
> > my application is running, I wanted to either 'freeze' the
> > application or build a distribution that supported running without
> > installation. I was not successful at freezing but I was able to
> > package my application into a single folder with its own local
> > Python.
> >
>
> Could you enlarge on what made the freezing not successful?  I've used
> py2exe to package an application which includes Chaco (and thus
> traits, enable & kiva).  It also includes h5py & PySide.  I needed the
> following py2exe options which seem a fairly modest selection of
> py2exe special rules:

I've no doubt it's possible. I spent a day and a half on it (using
cx_freeze and pyInstaller) and decided to cut my losses and try an
alternative route.

Thanks for letting us know how you achieved it!

Henry


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: ETS on 'portable' python.

Jordan Ilott-2
In reply to this post by Joel B. Mohler



On Fri, Apr 19, 2013 at 6:43 AM, Joel B. Mohler <[hidden email]> wrote:
On 4/18/2013 7:17 PM, Jordan Ilott wrote:
Hello all, I wanted to share my experience getting Traits, TraitsUI and Chaco working on Windows with PySide without installing anything.

In order to have strict control over the Python environment in which my application is running, I wanted to either 'freeze' the application or build a distribution that supported running without installation. I was not successful at freezing but I was able to package my application into a single folder with its own local Python.

Could you enlarge on what made the freezing not successful?  I've used py2exe to package an application which includes Chaco (and thus traits, enable & kiva).  It also includes h5py & PySide.  I needed the following py2exe options which seem a fairly modest selection of py2exe special rules:

I probably didn't put as much effort into py2exe or other freezing techniques as I could have. I've only been working with Python for a little over a month and there are a lot of things I'm not very experienced with. I was leery of py2exe because it hasn't been updated in a lot of years. PyInstaller is actively developed so I spent a little more time with it; however, there are hooks only for PyQt and not PySide. It seemed like the hidden imports in PyFace could make it difficult to get it working as well. There is reasonable documentation for PyInstaller but after spending a day with it, I decided it wasn't worth it.
options = {}
options["py2exe"] = {"excludes": [
                        "Tkinter", # no!
                        "tcl", # no!
                        "zmq", # punt for now: see[1]
                        "matplotlib", # no!
                        "IPython"], # relies on zmq
                    "includes": [
                        "h5py.defs",
                        "h5py.utils",
                        "h5py._proxy",
                        "PySide.QtNetwork",
                        "pyface.ui.qt4.*",
                        "pyface.ui.qt4.action.*",
                        "enable.qt4.*"],
                    "dll_excludes": [
                        "MSVCP90.dll"]} # TODO:  get the msvcrt issues sorted

# [1] http://stackoverflow.com/questions/14870825/py2exe-error-libzmq-pyd-no-such-file-or-directory


I began with PortablePython and extracted it keeping only Numpy and PIL selected(I was trying to minimize the size). PortablePython includes easy_install, and this made it simple to install cython, configobj, pandas, ReportLab and PySide from a Windows shell.

There are indeed nice reasons to use a portable python install even if py2exe works.

What I was really looking for when I set out to freeze the application was assembly of files that I could place on a network share for users to run the application from. The freezer tools would have been suitable but included what seemed to be a steep learning curve for me. This technique yielded the same net result and was easier for me to understand.

One note about running from a network: it's slow. PySide has to pull in the Qt DLLs and this means that a lot data is transferred across the wire at application startup. I will likely split things up to have my application run from the network but the python distribution kept on the user's PC. I may also use egg links to allow me to keep Chaco on the network as well because I have found myself making small updates as I develop the application. Once things are finalized, I could move the ETS packages to local Python folders.
Joel


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev



_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev