MobileBlur

Diff
Login

Differences From Artifact [8ed272e097]:

To Artifact [5c9c529861]:


1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
16








-
+







#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Usage:
    Install py2exe: http://sourceforge.net/projects/py2exe/files/
    Copy script to the web2py directory
    c:\bin\python26\python build_windows_exe.py py2exe
    

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

from distutils.core import setup
import py2exe
from gluon.import_all import base_modules, contributed_modules
from glob import glob
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
35
36
37
38
39
40
41

42
43
44
45
46
47
48
49







-
+







#I don't know if this is even necessary
if python_version == '2.6':
    # Python26 compatibility: http://www.py2exe.org/index.cgi/Tutorial#Step52
    try:
        shutil.copytree('C:\Bin\Microsoft.VC90.CRT', 'dist/')
    except:
        print "You MUST copy Microsoft.VC90.CRT folder into the dist directory"
        

#read web2py version from VERSION file
web2py_version_line = readlines_file('VERSION')[0]
#use regular expression to get just the version number
v_re = re.compile('[0-9]+\.[0-9]+\.[0-9]+')
web2py_version = v_re.search(web2py_version_line).group(0)

setup(
79
80
81
82
83
84
85
86

87
88
89
90
91
92
93
79
80
81
82
83
84
85

86
87
88
89
90
91
92
93







-
+







delete_ms_files = raw_input("Delete API-MS-Win-* files that are probably unsafe for distribution? (Y/n) ")
if delete_ms_files.lower().startswith("y"):
    print "Deleted Microsoft files not licensed for open source distribution"
    print "You are still responsible for making sure you have the rights to distribute any other included files!"
    #delete the API-MS-Win-Core DLLs
    for f in glob ('dist/API-MS-Win-*.dll'):
        os.unlink (f)
    #then delete some other files belonging to Microsoft    
    #then delete some other files belonging to Microsoft
    other_ms_files = ['KERNELBASE.dll', 'MPR.dll', 'MSWSOCK.dll', 'POWRPROF.dll']
    for f in other_ms_files:
        try:
            os.unlink(os.path.join('dist',f))
        except:
            print "unable to delete dist/"+f
            sys.exit(1)
109
110
111
112
113
114
115
116

117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
109
110
111
112
113
114
115

116
117
118
119
120
121
122
123

124
125
126
127
128
129
130
131







-
+







-
+







#Offer to copy project's site-packages into dist/site-packages
copy_apps = raw_input("Include your web2py site-packages & scripts folders? (Y/n) ")
if copy_apps.lower().startswith("y"):
    #copy site-packages
    if os.path.exists('dist/site-packages')
        shutil.rmtree('dist/site-packages')
    shutil.copytree('site-packages', 'dist/site-packages')
    #copy scripts 
    #copy scripts
    if os.path.exists('dist/scripts'):
        shutil.rmtree('dist/scripts')
    shutil.copytree('scripts', 'dist/scripts')
else:
    #no worries, web2py will create the (empty) folder first run
    print "Skipping site-packages & scripts"
    pass
    


print ""

#borrowed from http://bytes.com/topic/python/answers/851018-how-zip-directory-python-using-zipfile
def recursive_zip(zipf, directory, folder = ""):
   for item in os.listdir(directory):
      if os.path.isfile(os.path.join(directory, item)):
142
143
144
145
146
147
148
149

150
151
152
153
154
155
156
157
158
159
160
161
162
163

164
165
166

142
143
144
145
146
147
148

149
150
151
152
153
154
155
156
157
158
159
160
161
162

163
164
165
166
167







-
+













-
+



+
    zipf = zipfile.ZipFile("web2py_win.zip", "w", compression=zipfile.ZIP_DEFLATED )
    path = 'zip_temp' #just temp so the web2py directory is included in our zip file
    recursive_zip(zipf, path) #leave the first folder as None, as path is root.
    zipf.close()
    shutil.rmtree('zip_temp')
    print "Your Windows binary version of web2py can be found in web2py_win.zip"
    print "You may extract the archive anywhere and then run web2py/web2py.exe"
    

    # offer to clear up
    print "Since you created a zip file you likely do not need the build, deposit and dist folders used while building binary."
    clean_up_files = raw_input("Delete these un-necessary folders/files? (Y/n) ")
    if clean_up_files.lower().startswith("y"):
        shutil.rmtree('build')
        shutil.rmtree('deposit')
        shutil.rmtree('dist')
    else:
        print "Your Windows binary & associated files can also be found in /dist"
else:
    #Didn't want zip file created
    print ""
    print "Creation of web2py Windows binary completed."
    print "You should copy the /dist directory and its contents." 
    print "You should copy the /dist directory and its contents."
    print "To run use web2py.exe"
print "Finished!"
print "Enjoy web2py " +web2py_version_line