-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.ps1
executable file
·70 lines (57 loc) · 2.38 KB
/
make.ps1
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
$ErrorActionPreference = "Stop"
function call()
{
& $args[0] $args[1..$args.length]
if (!$?) { throw "Exit code $LastExitCode from command `"$args`"." }
}
# On some machines required to make HTTPS work:
[Net.ServicePointManager]::Expect100Continue = $true;
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
# Download embeddable python:
$zip = "python-3.7.3-embed-amd64.zip"
$url = "https://www.python.org/ftp/python/3.7.3/$zip"
$web = New-Object System.Net.WebClient
$web.DownloadFile($url, $zip)
Expand-Archive -Force -LiteralPath $zip -DestinationPath pkg
Add-Content pkg\python37._pth "import site`r`n"
Add-Content pkg\python37._pth "purelib.zip`r`n"
# Install py37 for site-packages:
conda create -p py37 -qy python=3.7 wheel
conda activate .\py37
conda install -qy nsis -c nsis
call pip wheel -w wheels -r requirements.txt
call pip install -f wheels -r requirements.txt `
-t pkg\Lib\site-packages --no-index -I
rm -r 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:
mv pkg\Lib\site-packages\madgui pkg
mv pkg\Lib\site-packages\minrpc pkg
mv pkg\Lib\site-packages\cpymad pkg
mv pkg\Lib\site-packages\hit_acs pkg
# Performance tweaks: remove .py files and zip up pure thirdparty packages:
call pip install distlib
call python minify.py pkg\Lib\site-packages
call python purelib.py pkg\Lib\site-packages
mv purelib.zip pkg
# Install py34 for mingwpy:
conda create -p py34 -qy python=3.4 -c conda-forge
conda install -p py34 -qy mingwpy -c conda-forge
$gcc = "py34\Scripts\gcc.exe"
$windres = "py34\Scripts\windres.exe"
$cflags = @( '-Ipy37\include' )
$lflags = @( '-Lpy37\libs', '-lpython37', '-nostdlib', '-lkernel32', '-lshell32' )
# Determine madgui version, and create madgui.rc:
$env:VERSION = & python -c "import madgui; print(madgui.__version__)"
call pip install j2cli
call j2 madgui.template.rc > madgui.rc
call $gcc @cflags python.c @lflags -o pkg\python.exe
call $windres madgui.rc -O coff -o madgui.res
call $gcc @cflags launcher.c @lflags -o pkg\madgui.exe `
"-DMODULE=madgui" -mwindows madgui.res
call $gcc @cflags launcher.c @lflags -o pkg\beamopt.exe `
"-DMODULE=hit_acs.gui_qt"
call $gcc $cflags shim.c $lflags -o madgui.exe `
"-DEXE=madgui_$VERSION\\madgui.exe" madgui.res -mwindows
cp madgui.yml pkg\
call makensis /DVERSION=$env:VERSION madgui.nsi