How to build windows binary yourself?

80 views
Skip to first unread message

Brian M

unread,
Mar 19, 2011, 10:53:59 PM3/19/11
to web...@googlegroups.com
I was going to take a shot at building my own windows exe version of web2py and see if I could get pyodbc included, but ran into a problem.  I started out with the source distribution of web2py 1.94.5. and then ran 
> python setup_exe.py web2py

Everything seems to start building OK until it begins to try copying the data files. Setup throws warnings for NEWINSTALL, ABOUT, LICENSE & VERSION (btw, splashlogo.gif is missing from the list but needed) because there isn't a destination directory specified.  Then as soon as it tries to copy the applications it dies with the following 

    error: can't copy 'applications\examples\controllers': doesn't exist or not a regular file

The 'applications\examples\controllers' directory is certainly there, so I'm not sure what's wrong.

If I remove the lines in setup_exe.py that add in 
          [x for x in reglob('applications/examples')] + \
          [x for x in reglob('applications/welcome')] + \
          [x for x in reglob('applications/admin')]
then the exe appears to build ok and runs if I copy in the data files from the source dist, but I assume that since the applications are mentioned in the official source they're supposed to be included in the build automatically.

Massimo, how do you build the Windows version of web2py?

Massimo Di Pierro

unread,
Mar 20, 2011, 1:03:22 AM3/20/11
to web2py-users
I do not build the windows version. I did it once last time 2 years
ago. Since than I only replace the pyc files and rezip. It is possible
we added some files that broke the py2exe script. Moreover I do not
use windows myself. If you have fixed it and want to email a revised
script I will post it.

Brian M

unread,
Mar 20, 2011, 6:36:22 PM3/20/11
to web...@googlegroups.com
OK, I've got a version that appears to build successfully - had to re-write the code to gather the list of data_files - reglob() didn't return files in expected format.  It's working but currently is including a bunch of windows API files in the dist directory, so it would NOT be appropriate for public distribution as-is without removing those files first (Danger, Danger Will Robinson licensing issues!). I'll see if I can figure out how to exclude them in the first place or at least automatically remove them with a secondary batch script.

Praneeth Bodduluri

unread,
Mar 20, 2011, 7:34:37 PM3/20/11
to web...@googlegroups.com, Brian M
We have used

http://bazaar.launchpad.net/~flavour/sahana-eden/trunk/view/head:/static/scripts/tools/standalone_exe.py

To build custom exes of web2py with certain modules added in. The
above works with py2exe. Recently I have been using cxfreeze with my
other projects - It appears to be way more simpler than py2exe.


--
Praneeth
IRC: lifeeth

Brian M

unread,
Mar 20, 2011, 8:25:54 PM3/20/11
to web...@googlegroups.com, Brian M
Thanks Praneeth, looks like what your script builds & what I've got going produce pretty much the same output (once I comment out the few extra modules you've got that I don't). 
1) I notice you're using shutil to just copy the applications directory rather than passing the correct tuples to data_files - that's probably an easier approach.
2) The data_files declaration you do have is missing splashlogo.gif, so the TK gui will not work.
3) You're not including routes.example.py, router.example.py or options_std.py probably not a major issue.
4) You're also including a bunch of API-MS-WIN-CORE-*.dll files which probably shouldn't be distributed with the app. Perhaps some extra shutil calls at the end to remove them?


Relating back to my original reason for starting this task - it looks like you don't need to do anything special to get pyodbc included - as long as you've got it installed it seems to get included in the binary distribution.

Brian M

unread,
Mar 27, 2011, 9:23:47 PM3/27/11
to web...@googlegroups.com, Massimo Di Pierro
Massimo,

I'll be emailing you a revised script based off of Praneeth's standalone_exe.py shortly. I decided to make it a bit more interactive

Features:
1) Creates web2py.exe with py2exe
2) Offers to remove the Windows DLLs that py2exe includes but are likely to have licensing issues.
3) Offers to let user decide if they want to include their applications (if not still includes admin app)
4) Offers to let user decide if they want to include their site-packages & scripts sub-folders (in case they've stuck needed modules there)
5) Offers to create a zip file of the build
6) If the zip file was make offers to clean up after itself (remove build, deposit & dist folders)

I've tested this on my Win7 box with Python 2.6 and it would appear to work as desired though I'll have to try running the resulting exe on some computers that have never seen python sometime next week.

As a side not, while doing a diff I noticed that the example app included in the official web2py_win.zip includes a bunch of extra files in applications/example/static that are not in the source distribution. They're almost all epydoc & sphinx files. Is there a reason for this or has something gotten out of sync?

Massimo Di Pierro

unread,
Mar 27, 2011, 9:27:42 PM3/27/11
to web...@googlegroups.com
Fantastic. Yes something got out of sync. I will remove the unwanted files.

Brian M

unread,
Mar 27, 2011, 10:33:23 PM3/27/11
to web...@googlegroups.com
http://code.google.com/p/web2py/issues/detail?id=224 Issue created so this doesn't get lost. (script is attached if anyone wants it)
Reply all
Reply to author
Forward
0 new messages