File tree Expand file tree Collapse file tree 7 files changed +52
-6
lines changed
Expand file tree Collapse file tree 7 files changed +52
-6
lines changed Original file line number Diff line number Diff line change 55import subprocess
66import platform
77import stat
8+ import re
89
910# This will not show "Segmentation fault" error message:
1011# | subprocess.call(["python", "./wxpython.py"])
2021# 5. To display debug backtrace type "cy bt"
2122# 6. More commands: http://docs.cython.org/src/userguide/debugging.html
2223
23- if len (sys .argv ) > 1 and sys . argv [ 1 ] == " debug" :
24+ if len (sys .argv ) > 1 and "-- debug" in sys . argv :
2425 DEBUG = True
2526 print ("DEBUG mode On" )
2627else :
2728 DEBUG = False
2829
30+ if len (sys .argv ) > 1 and re .search (r"^\d+\.\d+$" , sys .argv [1 ]):
31+ VERSION = sys .argv [1 ]
32+ else :
33+ print ("[compile.py] ERROR: expected first argument to be version number" )
34+ print (" Allowed version format: \\ d+\.\\ d+" )
35+ sys .exit (1 )
36+
37+ print ("VERSION=%s" % VERSION )
38+
2939BITS = platform .architecture ()[0 ]
3040assert (BITS == "32bit" or BITS == "64bit" )
3141
111121
112122os .chdir ("./setup" )
113123
114- ret = subprocess .call ("python fix_includes .py" , shell = True )
124+ ret = subprocess .call ("python fix_pyx_files .py" , shell = True )
115125if ret != 0 :
116126 sys .exit ("ERROR" )
117127
128+ # Create __version__.pyx after fix_pyx_files.py was called,
129+ # as that script deletes old pyx files before copying new ones.
130+ print ("Creating __version__.pyx file" )
131+ with open ("__version__.pyx" , "w" ) as fo :
132+ fo .write ('__version__ = "{}"\n ' .format (VERSION ))
133+
118134if DEBUG :
119135 ret = subprocess .call ("python-dbg setup.py build_ext --inplace"
120136 " --cython-gdb" , shell = True )
File renamed without changes.
Original file line number Diff line number Diff line change 55import subprocess
66import platform
77import stat
8+ import re
89
910# This will not show "Segmentation fault" error message:
1011# | subprocess.call(["python", "./wxpython.py"])
2021# 5. To display debug backtrace type "cy bt"
2122# 6. More commands: http://docs.cython.org/src/userguide/debugging.html
2223
23- if len (sys .argv ) > 1 and sys . argv [ 1 ] == " debug" :
24+ if len (sys .argv ) > 1 and "-- debug" in sys . argv :
2425 DEBUG = True
2526 print ("DEBUG mode On" )
2627else :
2728 DEBUG = False
2829
30+ if len (sys .argv ) > 1 and re .search (r"^\d+\.\d+$" , sys .argv [1 ]):
31+ VERSION = sys .argv [1 ]
32+ else :
33+ print ("[compile.py] ERROR: expected first argument to be version number" )
34+ print (" Allowed version format: \\ d+\.\\ d+" )
35+ sys .exit (1 )
36+
37+ print ("VERSION=%s" % VERSION )
38+
2939BITS = platform .architecture ()[0 ]
3040assert (BITS == "32bit" or BITS == "64bit" )
3141PYTHON_CMD = "python"
129139
130140os .chdir ("./setup" )
131141
132- ret = subprocess .call (PYTHON_CMD + " fix_includes .py" , shell = True )
142+ ret = subprocess .call (PYTHON_CMD + " fix_pyx_files .py" , shell = True )
133143if ret != 0 :
134144 sys .exit ("ERROR" )
135145
146+ # Create __version__.pyx after fix_pyx_files.py was called,
147+ # as that script deletes old pyx files before copying new ones.
148+ print ("Creating __version__.pyx file" )
149+ with open ("__version__.pyx" , "w" ) as fo :
150+ fo .write ('__version__ = "{}"\n ' .format (VERSION ))
151+
136152if DEBUG :
137153 ret = subprocess .call (PYTHON_CMD + "-dbg setup.py build_ext --inplace"
138154 " --cython-gdb" , shell = True )
File renamed without changes.
Original file line number Diff line number Diff line change @@ -176,9 +176,18 @@ echo [compile.bat] Entering setup/ directory
176176cd %setup%
177177
178178echo [compile.bat] Copying .pyx files to setup/ directory and fixing includes
179- python fix_includes .py
179+ python fix_pyx_files .py
180180if %errorlevel% neq 0 (
181- echo [compile.bat] ERROR: running fix_includes.py failed
181+ echo [compile.bat] ERROR: running fix_pyx_files.py failed
182+ exit /B 1
183+ )
184+
185+ :: __version__.pyx must be generated after running fix_pyx_files.py,
186+ :: as that script deletes old pyx files before copying new ones.
187+ echo [compile.bat] Creating __version__.pyx file
188+ echo __version__ = " %version% " >> __version__.pyx
189+ if %errorlevel% neq 0 (
190+ echo [compile.bat] ERROR: writing __version__.pyx failed
182191 exit /B 1
183192)
184193
File renamed without changes.
Original file line number Diff line number Diff line change 8383# like "bool(1)" being invalid, in pyx files.
8484
8585# All .pyx files need to be included in this file.
86+ # Includes being made in other .pyx files are allowed to help
87+ # IDE completion, but will be removed during cython compilation.
88+
89+ # Version file is generated by the compile.bat/compile.py script.
90+ include " __version__.pyx"
8691
8792include " cython_includes/compile_time_constants.pxi"
8893include " imports.pyx"
You can’t perform that action at this time.
0 commit comments