forked from winpython/winpython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_a_winpython_distro.bat
394 lines (298 loc) · 16.1 KB
/
generate_a_winpython_distro.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
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
133
134
135
136
137
138
139
140
141
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
rem to launch from a winpython package directory, where 'make.py' is
@echo on
rem *****************************
rem 2020-07-05: install msvc_runtime before packages that may want to compile
rem 2020-12-05 : add a constrints.txt file from a recent pip list
rem 2021-03-20 : track successes packages combination are archived for future contraint update
rem 2021-04-22 : path PyPy3 (as we don't try to copy PyPy3.exe to Python.exe)
rem 2023-08-21a: add a pre_step with my_requirements_pre.txt + my_find_links_pre
rem *****************************
rem algorithm:
rem 0.0 Initialize variables
rem 1.0 Do 2021-04-22 : patch PyPy3 (as we don't try to copy PyPy3.exe to Python.exe)
rem 2021-04-22b: Patch PyPy3, give '%my_python_target_release%' to make (otherwise known only after unzip)
rem 2 a Pre-clear of previous build infrastructure
rem 2.0 Create a new build
rem 2.1 Create basic build infrastructure
rem 2.2 check infrastructure is in place
rem 2.3 add mandatory packages for build
rem 2.4 add packages pre_requirements (if any)
rem 2.5 add requirement packages
rem 2.8 post-build (if specific workarounds)
rem 2.9 archive success
rem 3.0 Generate Changelog and binaries
rem this is pre-initialised per the program calling this .bat
rem set my_original_path=%path%
rem set my_root_dir_for_builds=D:\WinP
rem set my_python_target=34
rem set my_pyver=3.4
rem set my_flavor=mkl
rem set my_release=84
rem set my_find_link=C:\WinP\packages.srcreq
rem this is optionaly pre-initialised per the calling program (simpler to manage here)
rem set my_release_level=
echo ------------------
echo 0.0 Initialize variables
echo ------------------
if "%my_release_level%"=="" set my_release_level=b4
set my_basedir=%my_root_dir_for_builds%\bd%my_python_target%
set my_buildenv=C:\WinPdev\WPy64-3890
if "%my_constraints%"=="" set my_constraints=C:\WinP\constraints.txt
rem 2021-04-22 : path PyPy3 (as we don't try to copy PyPy3.exe to Python.exe)
if "%target_python_exe%"=="" set target_python_exe=python.exe
if %my_python_target%==38 (
set my_python_target_release=3812
set my_release=1
)
if %my_python_target%==39 (
set my_python_target_release=3915
set my_release=1
)
if %my_python_target%==310 (
set my_python_target_release=31011
set my_release=2
)
if %my_python_target%==311 (
set my_python_target_release=3118
set my_release=1
)
if %my_python_target%==312 (
set my_python_target_release=3123
set my_release=0
)
if %my_python_target%==313 (
set my_python_target_release=3130
set my_release=0
)
rem **** 2018-10-30 create_installer **
if "%my_create_installer%"=="" set my_create_installer=True
rem set my_flavor=Slim
rem set my_arch=32
rem set my_preclear_build_directory=Yes
rem 20230821 add a requirement_pre.txt +
rem set my_requirements_pre=C:\WinP\bd311\requirements_mkl_pre.txt
rem set my_find_links_pre=C:\WinP\packages_mkl.srcreq
rem set my_requirements=C:\Winpents=d:\my_req1.txt
rem set my_find_links=D:\WinPython\packages.srcreq
rem set my_source_dirs=D:\WinPython\bd34\packages.src D:\WinPython\bd34\packages.win32.Slim
rem set my_toolsdirs=D:\WinPython\bd34\Tools.Slim
rem set my_docsdirs=D:\WinPython\bd34\docs.Slim
rem set my_install_options=--no-index --pre
set my_day=%date:/=-%
set my_time=%time:~0,5%
set my_time=%my_time::=_%
rem was the bug
set my_time=%my_time: =0%
set my_archive_dir=%~dp0WinPython_build_logs
if not exist %my_archive_dir% mkdir %my_archive_dir%
set my_archive_log=%my_archive_dir%\build_%my_pyver%._.%my_release%%my_flavor%_%my_release_level%_of_%my_day%_at_%my_time%.txt
echo ===============
echo preparing winPython for %my_pyver% (%my_python_target%)release %my_release%%my_flavor% (%my_release_level%) *** %my_arch% bit ***
echo %date% %time%
echo ===============
echo ===============>>%my_archive_log%
echo preparing winPython for %my_pyver% (%my_python_target%)release %my_release%%my_flavor% (%my_release_level%) *** %my_arch% bit ***>>%my_archive_log%
echo %date% %time%>>%my_archive_log%
echo ===============>>%my_archive_log%
if not "%my_preclear_build_directory%"=="Yes" goto no_preclear
echo ------------------
echo 1.0 Do a Pre-clear of previous build infrastructure
echo ------------------
echo ------------------>>%my_archive_log%
echo 1.0 Do a Pre-clear of previous build infrastructure>>%my_archive_log%
echo %date% %time% >>%my_archive_log%
echo ------------------>>%my_archive_log%
rem 2019-05-10 PATCH for build problem (asking permission to overwrite the file)
del -y %userprofile%\.jupyter\jupyter_notebook_config.py
cd /D %my_root_dir_for_builds%\bd%my_python_target%
set build_det=\%my_flavor%
if "%my_flavor%"=="" set build_det=
dir %build_det%
rem 2021-02-13 workaround to hard to remove json files
echo ren bu%my_flavor% bu%my_flavor%_old
ren bu%my_flavor% bu%my_flavor%_old
rem pause
start rmdir /S /Q bu%my_flavor%_old
echo rmdir /S /Q bu%my_flavor%
rem pause
rmdir /S /Q bu%my_flavor%
rmdir /S /Q bu%my_flavor%
rmdir /S /Q bu%my_flavor%
rmdir /S /Q bu%my_flavor%
rmdir /S /Q bu%my_flavor%
rmdir /S /Q dist
echo %date% %time%
echo %date% %time%>>%my_archive_log%
:no_preclear
e
echo -----------------------------
echo 2.0 Create a new build
echo ---------------------------- >>%my_archive_log%
echo 2.0 Create a new build>>%my_archive_log%
echo %date% %time% >>%my_archive_log%
echo ---------------------------- >>%my_archive_log%
echo cd /D %~dp0>>%my_archive_log%
cd /D %~dp0
echo set path=%my_original_path%>>%my_archive_log%
set path=%my_original_path%
echo call %my_buildenv%\scripts\env.bat>>%my_archive_log%
call %my_buildenv%\scripts\env.bat
echo -----------------------------
echo 2.1 Create basic build infrastructure
echo %date% %time%
echo -----------------------------
echo ----------------------------->>%my_archive_log%
echo 2.1 Create basic build infrastructure>>%my_archive_log%
echo %date% %time% >>%my_archive_log%
echo ----------------------------->>%my_archive_log%
rem 2019-10-22 new age step1
rem we don't use requirements
rem we don't create installer at first path
rem we use legacy python build cd /D %~dp0
set my_buildenv_path=%path%
echo python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, flavor='%my_flavor%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%', docsdirs=r'%my_docsdirs%', create_installer='False', python_target_release='%my_python_target_release%')">>%my_archive_log%
echo python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, flavor='%my_flavor%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%', docsdirs=r'%my_docsdirs%', create_installer='False', python_target_release='%my_python_target_release%')"
rem pause
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, flavor='%my_flavor%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%', docsdirs=r'%my_docsdirs%', create_installer='False', python_target_release='%my_python_target_release%')">>%my_archive_log%
rem old one
rem echo python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, flavor='%my_flavor%', requirements=r'%my_requirements%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%', docsdirs=r'%my_docsdirs%', create_installer='%my_create_installer%')">>%my_archive_log%
echo -----------------------------
echo 2.2 check infrastructure is in place
echo %date% %time%
echo -----------------------------
echo ----------------------------->>%my_archive_log%
echo 2.2 check infrastructure is in place>>%my_archive_log%
echo %date% %time% >>%my_archive_log%
echo ----------------------------->>%my_archive_log%
rem 2019-10-22 new age step2
rem we use final environment to install requirements
set path=%my_original_path%
@echo on
set my_WINPYDIRBASE=%my_root_dir_for_builds%\bd%my_python_target%\bu%my_flavor%\Wpy%my_arch%-%my_python_target_release%%my_release%%my_release_level%
set WINPYDIRBASE=%my_WINPYDIRBASE%
rem D/2020-07-04: poka-yoke
if not exist %my_WINPYDIRBASE%\scripts\env.bat (
echo please check and correct my_python_target_release=%my_python_target_release%
echo my_arch=%my_arch%
echo my_python_target_release=%my_python_target_release%
echo my_release=%my_release%
echo my_release_level=%my_release_level%
echo in generate_a_winpython_distro.bat
echo as %my_WINPYDIRBASE%\scripts\env.bat doesnt exist
pause
exit
)
rem F/2020-07-04: poka-yoke
call %my_WINPYDIRBASE%\scripts\env.bat
set
echo beg of step 2/3
rem ok no pause
echo -----------------------------
echo 2.3 add mandatory packages for build
echo %date% %time%
echo -----------------------------
echo ----------------------------->>%my_archive_log%
echo 2.3 add mandatory packages for build>>%my_archive_log%
echo %date% %time% >>%my_archive_log%
echo ----------------------------->>%my_archive_log%
rem D/2024-04-10: do not override "/vcruntime140_1.dll" with msvc_runtime wheel
rem echo python.exe -c "import sys;from pathlib import Path;f=open(Path(sys.prefix) / 'pyenv.cfg', 'w');f.write('include-system-site-packages = true\n');f.close">>%my_archive_log%
rem F/2024-04-10
rem D/2020-07-05: install msvc_runtime before packages that may want to compile
echo pip install msvc_runtime --pre --no-index --trusted-host=None --find-links=%my_find_links% --upgrade
echo pip install msvc_runtime --pre --no-index --trusted-host=None --find-links=%my_find_links% --upgrade>>%my_archive_log%
pip install msvc_runtime --pre --no-index --trusted-host=None --find-links=%my_find_links% --upgrade
rem F/2020-07-05: install msvc_runtime before packages that may want to compile
rem D/2023-08-21a: add a pre_step with my_requirements_pre.txt + my_find_links_pre
echo -----------------------------
echo 2.4 add packages pre_requirements (if any)
echo %date% %time%
echo -----------------------------
echo ----------------------------->>%my_archive_log%
echo 2.4 add packages pre_requirements (if any)
echo %date% %time% >>%my_archive_log%
echo ----------------------------->>%my_archive_log%rem F/20230821 add a pre_step with my_requirements_pre.txt + my_find_links_pre
if not "Z%my_requirements_pre%Z"=="ZZ" (
rem 2023-08-21a: add a pre_step with my_requirements_pre.txt + my_find_links_pre
if "%my_find_links_pre%"=="" set my_find_links_pre=%my_find_links%
echo pip install -r %my_requirements_pre% -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links_pre% --upgrade %new_resolver%
echo pip install -r %my_requirements_pre% -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links_pre% --upgrade %new_resolver%>>%my_archive_log%
echo if pip doesn't work, check the path of %my_WINPYDIRBASE%
pip install -r %my_requirements_pre% -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links_pre% --upgrade %new_resolver%>>%my_archive_log%
) else (
echo no packages pre_requirements
echo no packages pre_requirements>>%my_archive_log%
)
rem F/2023-08-21a: add a pre_step with my_requirements_pre.txt + my_find_links_pre
echo -----------------------------
echo 2.5 add requirement packages
echo %date% %time%
echo -----------------------------
echo ----------------------------->>%my_archive_log%
echo 2.5 add requirement packages_versions>>%my_archive_log%
echo %date% %time% >>%my_archive_log%
echo ----------------------------->>%my_archive_log%
echo pip install -r %my_requirements% -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links% --upgrade %new_resolver%
echo pip install -r %my_requirements% -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links% --upgrade %new_resolver%>>%my_archive_log%
echo if pip doesn't work, check the path of %my_WINPYDIRBASE%
rem 2020-12-05 : add a constraints.txt file from a recent pip list
pip install -r %my_requirements% -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links% --upgrade %new_resolver%>>%my_archive_log%
echo mid of step 2/3
echo -----------------------------
echo 2.8 post-build (if specific workarounds)
echo %date% %time%
echo -----------------------------
echo ----------------------------->>%my_archive_log%
echo 2.8 post-build (if specific workarounds)>>%my_archive_log%
echo %date% %time% >>%my_archive_log%
echo ----------------------------->>%my_archive_log%
rem finalize
@echo on
call %my_basedir%\run_complement_newbuild.bat %my_WINPYDIRBASE%
echo end of step 2/3
echo end of step 2/3>>%my_archive_log%
rem pause
rem *****************************
rem 2021-03-20 : track successes packages combination are archived for future contraint update
rem *****************************
echo -----------------------------
echo 2.9 archive success
echo %date% %time%
echo -----------------------------
echo ----------------------------->>%my_archive_log%
echo 2.9 archive success >>%my_archive_log%
echo %date% %time% >>%my_archive_log%
echo ----------------------------->>%my_archive_log%
echo %target_python_exe% -m pip freeze>%my_archive_log%.packages_versions.txt>>%my_archive_log%
%target_python_exe% -m pip freeze>%my_archive_log%.packages_versions.txt
echo -----------------------------
echo 3.0 Generate Changelog and binaries
echo -----------------------------
echo ----------------------------->>%my_archive_log%
echo 3.0 Generate Changelog and binaries >>%my_archive_log%
echo %date% %time% >>%my_archive_log%
echo ----------------------------->>%my_archive_log%
rem build final changelog and binaries, using create_installer='%my_create_installer%', remove_existing=False , remove : requirements, toolsdirs and docdirs
set path=%my_original_path%
echo cd /D %~dp0>>%my_archive_log%
cd /D %~dp0
echo call %my_buildenv%\scripts\env.bat>>%my_archive_log%
call %my_buildenv%\scripts\env.bat
set
echo python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, flavor='%my_flavor%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', create_installer='%my_create_installer%', remove_existing=False, python_target_release='%my_python_target_release%')">>%my_archive_log%
echo python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, flavor='%my_flavor%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', create_installer='%my_create_installer%', remove_existing=False, python_target_release='%my_python_target_release%')"
rem pause
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, flavor='%my_flavor%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', create_installer='%my_create_installer%', remove_existing=False, python_target_release='%my_python_target_release%')">>%my_archive_log%
echo ===============
echo END OF creation
echo ===============
echo ===============>>%my_archive_log%
echo END OF creation>>%my_archive_log%
echo %date% %time% >>%my_archive_log%
echo ===============>>%my_archive_log%
rem show logs
start notepad.exe %my_archive_log%
rem 2021-03-20 : track successes packages combination are archived for future contraint update
start notepad.exe %my_archive_log%.packages_versions.txt
set path=%my_original_path%
rem pause