At my work place I still use py2exe but I do not rely on its automatic 
discovery and packaging.

The setup.py lists all the dependencies explicitly in "packages" and "includes" 
parameters.  These end up in library.zip.

Then the source file paths with the actual business logic are gathered with 
os.walk and passed in as data_files parameter.

Finally the actual service executable is generated from the very minimal script.
This executable is registered only once and as long as you do not move it to a 
different directory Windows will find it and start it up for you.

The service script that gets used by py2exe is truly minimal.  It just changes 
working directory to where the executable sits, adds current directory to the 
sys.path and loads the main script.

The main script would be copied by setup.py into the current working directory.

When there is a new release I update the files with business logic and restart 
the service.
When I want to update the dependent libraries I regenerate library.zip, copy it 
over and again restart the service.

The trick is to let the files from the current directory to be imported first.
To achieve it you should avoid putting your business logic files into your 
library.zip.
py2exe will do it if you let it to.

Depending on situation I go to into dirty tricks like selectively commenting 
out import statements before running py2exe or even post-processing library.zip 
and deleting the business logic files from the archive.

With a little bit of care you can make it work but I admit my approach is not 
very clean.

Oh another trick I have learned.
If your service does not start because let's say an import has failed look into 
Event Viewer/Application.  There should be an entry with a nice traceback 
listing what went wrong.

Waldemar
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to