forked from tlecomte/friture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinbuild.ps1
132 lines (99 loc) · 4.14 KB
/
winbuild.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
$virtualenv = "buildenv"
# check for python and pip in PATH
$pythonPath = Get-Command "python" -ErrorAction SilentlyContinue
if ($pythonPath -eq $null)
{
throw "Unable to find python in PATH"
}
Write-Host "python found in " $pythonPath.Definition
$pipPath = Get-Command "pip" -ErrorAction SilentlyContinue
if ($pipPath -eq $null)
{
# try to add the Python Scripts folder to the path
$pythonPath = Get-Command "python" | Select-Object -ExpandProperty Definition | Split-Path
$env:Path += ";$pythonPath\Scripts"
# retry
$pipPath = Get-Command "pip" -ErrorAction SilentlyContinue
if ($pipPath -eq $null)
{
throw "Unable to find pip in PATH"
}
}
Write-Host "pip found in " $pipPath.Definition
$nsisPath = Get-Command "makensis" -ErrorAction SilentlyContinue
if ($nsisPath -eq $null)
{
# try with the standard NSIS location
$env:Path += ";C:\Program Files (x86)\NSIS"
$nsisPath = Get-Command "makensis" -ErrorAction SilentlyContinue
if ((Get-Command "makensis" -ErrorAction SilentlyContinue) -eq $null)
{
throw "Unable to find makensis in PATH. Install NSIS using the official installer or using chocolatey."
}
}
Write-Host "makensis found in " $nsisPath.Definition
Write-Host ""
Write-Host "==========================================="
Write-Host "Cleaning up"
Write-Host "==========================================="
Remove-Item $virtualenv -Recurse -ErrorAction Ignore
Remove-Item "build" -Recurse -ErrorAction Ignore
Remove-Item "dist" -Recurse -ErrorAction Ignore
Write-Host ""
Write-Host "==========================================="
Write-Host "Making sure pip is up-to-date"
Write-Host "==========================================="
& python -m pip install --upgrade pip
Write-Host ""
Write-Host "==========================================="
Write-Host "Making sure setuptools is up-to-date (for compiler compatibility)"
Write-Host "==========================================="
& pip install --upgrade setuptools
Write-Host ""
Write-Host "==========================================="
Write-Host "Installing virtualenv"
Write-Host "==========================================="
& pip install -U virtualenv
Write-Host ""
Write-Host "==========================================="
Write-Host "Creating a virtualenv"
Write-Host "==========================================="
& virtualenv $virtualenv
Write-Host ""
Write-Host "==========================================="
Write-Host "Activating the virtualenv"
Write-Host "==========================================="
& "$virtualenv\Scripts\activate"
Write-Host ""
Write-Host "==========================================="
Write-Host "Installing requirements"
Write-Host "==========================================="
& pip install -r requirements.txt
Write-Host ""
Write-Host "==========================================="
Write-Host "Installing pyinstaller"
Write-Host "==========================================="
# install a version of pefile that does not use the past library, which in turn imports too many things
& pip install git+https://github.com/tlecomte/pefile.git@tlecomte-remove-past
# install a recent pyinstaller with no need for mscvr*.dll, and that lets python35.dll be signed
& pip install -U git+https://github.com/pyinstaller/pyinstaller.git@469f1fa19275e415110f783fd538ad46805edff4
Write-Host ""
Write-Host "==========================================="
Write-Host "Building Cython extensions"
Write-Host "==========================================="
& python setup.py build_ext --inplace
Write-Host ""
Write-Host "==========================================="
Write-Host "Packaging with pyinstaller"
Write-Host "==========================================="
& pyinstaller friture.spec -y --log-level=DEBUG
Write-Host ""
Write-Host "==========================================="
Write-Host "Archiving the package as a zip file"
Write-Host "==========================================="
Compress-Archive -Path .\dist\friture\* -DestinationPath .\dist\friture.zip
Write-Host ""
Write-Host "==========================================="
Write-Host "Building the NSIS installer"
Write-Host "==========================================="
& makensis.exe installer\friture-setup.nsi