-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.bat
executable file
·70 lines (58 loc) · 3.2 KB
/
make.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
:: Make sure to use conda version 4.6.14 or lower
:: mingwpy just runs in Python 3.4, newer versions of Conda
:: dont support it
:: Install py37 for site-packages:
call conda create -p py37 -qy python=3.7 wheel || goto :error
call conda activate .\py37 || goto :error
call conda install -qy nsis -c nsis || goto :error
call conda install -qy 7za pywget || goto :error
:: Download embeddable python:
set "ZIP=python-3.7.3-embed-amd64.zip"
set "URL=https://www.python.org/ftp/python/3.7.3/%ZIP%"
call python -m wget "%URL%" -o "%ZIP%" || goto :error
call 7za x -y -opkg "%ZIP%" || goto :error
:: DO NOT add quotes or space around `import site`, it will mess up the output!
echo import site>>pkg\python37._pth
echo purelib.zip>>pkg\python37._pth
call pip wheel -w wheels -r requirements.txt || goto :error
call pip install -f wheels -r requirements.txt ^
-t pkg\Lib\site-packages --no-index -I || goto :error
call rd /s /q pkg\Lib\site-packages\bin
:: Safe our packages at top level to make them easier to find and edit,
:: and to prevent them from being minified down below:
call move pkg\Lib\site-packages\madgui pkg\
call move pkg\Lib\site-packages\minrpc pkg\
call move pkg\Lib\site-packages\cpymad pkg\
call move pkg\Lib\site-packages\hit_acs pkg\
:: Performance tweaks: remove .py files and zip up pure thirdparty packages:
:: call pip install distlib || goto :error
:: call python minify.py pkg\Lib\site-packages || goto :error
:: call python purelib.py pkg\Lib\site-packages || goto :error
:: call move purelib.zip pkg
:: This actually didnt work last time
:: Install py34 for mingwpy:
call conda create -p py34 -qy python=3.4 -c conda-forge || goto :error
call conda install -p py34 -qy mingwpy -c conda-forge || goto :error
set "gcc=py34\Scripts\gcc.exe"
set "windres=py34\Scripts\windres.exe"
set "cflags=-Ipy37\include"
set "lflags=-Lpy37\libs -lpython37 -nostdlib -lkernel32 -lshell32"
:: Determine madgui version, and create madgui.rc:
for /f %%G in ('pkg\python -c "import madgui; print(madgui.__version__)"') do (set "VERSION=%%G")
call pip install j2cli
call j2 madgui.template.rc > madgui.rc
call %gcc% %cflags% python.c %lflags% -o pkg\python.exe || goto :error
call %windres% madgui.rc -O coff -o madgui.res || goto :error
call %gcc% %cflags% launcher.c %lflags% -o pkg\madgui.exe ^
-DMODULE=madgui madgui.res -mwindows || goto :error
call %gcc% %cflags% launcher.c %lflags% -o pkg\beamopt.exe ^
-DMODULE=hit_acs.gui_qt || goto :error
call %gcc% %cflags% shim.c %lflags% -o madgui.exe ^
-DEXE=madgui_%VERSION%\\madgui.exe madgui.res -mwindows || goto :error
copy madgui.yml pkg || goto :error
call makensis /DVERSION=%VERSION% madgui.nsi || goto :error
@exit /b 0
:error
@set errcode=%ERRORLEVEL%
@echo "Previous command returned error code: %errcode%"
@exit /b %errcode%