[Twisted-Python] Assistance with using Twisted with "pyinstaller"

Paul Thomas spongelavapaul at googlemail.com
Wed Jan 6 05:03:24 EST 2010


On 5 Jan 2010, at 20:48, Ken MacDonald wrote:

> Hi, we're trying to using pyinstaller to create single-directory  
> distributions of our Twisted/python server on Linux. Wondering if  
> anyone has accomplished this? I googled and checked the archives,  
> but there seems to be no concrete information available.

Sorry to be negative, but I've not managed to get pyinstaller working  
with twisted.

The reason I'm posting is that I have managed to get bbfreeze and  
cx_freeze working. This is all about 6 months old, so newer versions  
might be different, but to summarise:

cx_Freeze put everything into an executable zip file so you are left  
with one main binary and a handful of .so objects for python C modules  
(unless you patch the Python build to build static). I had to switch  
to bbfreeze because I needed to use Nevow and there were too many  
hoops to jump through to make it work with the data files accessed  
relative to __file__.

bbfreeze works with eggs, so it works with Nevow or anything else that  
uses data files, but the down side is that the result isn't zipped up  
into one executable.

I'm about to reopen the whole freezing thing for a new project, so I  
may be able to report back in a few weeks.


>
> I'm real new to pyinstaller and not really familiar with twisted  
> internals, so not sure where to start with this, particularly  
> whether to package our_server.tac, or the twistd script, or the  
> our_server.py as the starting point to bundle all of this stuff  
> together. If anyone's done this successfully, or failed miserably,  
> would be interested in getting details.

I dropped the tac file to make it easier to specify the entrypoint. To  
do this while still getting all the twistd goodness requires some  
hacking, but it isn't really necessary. You can use the tac file  
(better to change the extension to .py though) and put a few imports  
in the file that are only there to pull in dependencies that the  
freezing program can't find. It's basically an iterative thing - build  
it, note the missing dependencies, import them, repeat.

Good luck.




More information about the Twisted-Python mailing list