1
1
rem generate_a_winpython_distro.bat: to be launched from a winpython directory, where 'make.py' is
2
2
@ echo on
3
3
4
- REM === Step 01:Set default values if not already defined ===
4
+ REM === Initialize default values ===
5
5
if not defined my_release_level set " my_release_level = b1"
6
6
if not defined my_create_installer set " my_create_installer = True"
7
7
if not defined my_constraints set " my_constraints = C:\WinP\constraints.txt"
8
8
if not defined target_python_exe set " target_python_exe = python.exe"
9
+ if not defined mandatory_requirements set " mandatory_requirements = %~dp0 \mandatory_requirements.txt"
9
10
10
- REM === Define archive directory ===
11
11
set " my_archive_dir = %~dp0 WinPython_build_logs"
12
12
if not exist " %my_archive_dir% " mkdir " %my_archive_dir% "
13
13
14
- REM === Format current time for use in log file ===
14
+ REM === Format log timestamp ===
15
15
set " my_time = %time:~0 ,5 % "
16
16
set " my_time = %my_time:: =_ % "
17
17
set " my_time = %my_time: =0 % "
18
18
19
- REM === Define archive log file path ===
20
19
set " my_archive_log = %my_archive_dir% \build_%my_pyver% _%my_release%%my_flavor% _%my_release_level% _of_%date:/ =- % at_%my_time% .txt"
21
20
22
- REM === Step 02:Set Python version and release ===
23
- if " %my_python_target% " == " 311" (
24
- set " my_python_target_release = 3119"
25
- set " my_release = 2"
26
- ) else if " %my_python_target% " == " 312" (
27
- set " my_python_target_release = 31210"
28
- set " my_release = 2"
29
- ) else if " %my_python_target% " == " 313" (
30
- set " my_python_target_release = 3135"
31
- set " my_release = 1"
32
- ) else if " %my_python_target% " == " 314" (
33
- set " my_python_target_release = 3140"
34
- set " my_release = 1"
35
- )
21
+ REM === Determine Python target version ===
22
+ if " %my_python_target% " == " 311" (set " my_python_target_release=3119" & set " my_release = 2" )
23
+ if " %my_python_target% " == " 312" (set " my_python_target_release=31210" & set " my_release = 2" )
24
+ if " %my_python_target% " == " 313" (set " my_python_target_release=3135" & set " my_release = 1" )
25
+ if " %my_python_target% " == " 314" (set " my_python_target_release=3140" & set " my_release = 1" )
36
26
37
- REM === Step 03: Define base build and distribution paths ===
27
+ REM === Define base build and distribution paths ===
38
28
set " my_basedir = %my_root_dir_for_builds% \bd%my_python_target% "
39
29
set " my_WINPYDIRBASE = %my_basedir% \bu%my_flavor% \WPy%my_arch% -%my_python_target_release%%my_release%%my_release_level% "
40
30
41
-
42
31
rem a building env need is a Python with packages: WinPython + build + flit + packaging + mkshim400.py
43
- set my_buildenv = C:\WinPdev\WPy64-310111
32
+ set " my_buildenv = C:\WinPdev\WPy64-310111"
44
33
45
- call :log_section preparing winPython for %my_pyver% (%my_python_target% )release %my_release%%m y_flavor% (%my_release_level% ) *** %my_arch% bit ***
34
+ call :log_section Preparing WinPython for %my_pyver% (%my_python_target% )release %my_release%%m y_flavor% (%my_release_level% ) *** %my_arch% bit ***
46
35
47
- REM === Step 04: Pre- clear previous build infrastructure ===
36
+ REM === Optionally clear previous build ===
48
37
if /i " %my_preclear_build_directory% " == " Yes" (
49
38
call :log_section Pre-clear previous build infrastructure
50
-
51
39
REM Delete Jupyter config if it exists
52
- if exist " %userprofile% \.jupyter\jupyter_notebook_config.py" (
53
- del /f /q " %userprofile% \.jupyter\jupyter_notebook_config.py"
54
- )
55
-
56
- REM Navigate to build directory
40
+ del /f /q " %userprofile% \.jupyter\jupyter_notebook_config.py"
41
+ REM Navigate to build directory and Rename previous build folder if it exists
57
42
cd /D " %my_root_dir_for_builds% \bd%my_python_target% "
58
-
59
- REM Rename previous build folder if it exists
60
- if exist " bu%my_flavor% " (
43
+ if exist " bu%my_flavor% " (
61
44
ren " bu%my_flavor% " " bu%my_flavor% _old"
62
45
rmdir /s /q " bu%my_flavor% _old"
63
46
)
64
47
)
65
48
66
- REM === Step 05: Create new build ===
67
- call :log_section Create a new build
49
+ REM === Begin Build ===
50
+ call :log_section Creating Build Infrastructure
51
+ call :activate_env " %my_buildenv% "
68
52
69
- REM Activate base build environment
70
- cd /D " %~dp0 "
71
- set " path = %my_original_path% "
72
- call " %my_buildenv% \scripts\env.bat"
73
-
74
- REM Call make_all to create basic infrastructure
75
- call :log_section Create basic build infrastructure
76
53
python.exe -c " from make import make_all; make_all(%my_release% , '%my_release_level% ', basedir_wpy=r'%my_WINPYDIRBASE% ', verbose=True, flavor='%my_flavor% ', source_dirs=r'%my_source_dirs% ', toolsdirs=r'%my_toolsdirs% ')" >> " %my_archive_log% "
77
54
78
55
79
- REM === Check infrastructure exists ===
80
- call :log_section Check infrastructure
81
-
56
+ REM === Check env.bat has been created ===
82
57
set " WINPYDIRBASE = %my_WINPYDIRBASE% "
83
58
84
59
if not exist " %WINPYDIRBASE% \scripts\env.bat" (
85
- echo ERROR: %WINPYDIRBASE% \scripts\env.bat does not exist
86
- echo Please verify:
87
- echo my_arch=%my_arch%
88
- echo my_python_target_release=%my_python_target_release%
89
- echo my_release=%my_release%
90
- echo my_release_level=%my_release_level%
60
+ echo ERROR: %WINPYDIRBASE% \scripts\env.bat script not found
61
+ echo Please verify: my_arch=%my_arch% my_python_target_release=%my_python_target_release%
62
+ echo my_release=%my_release% my_release_level=%my_release_level%
91
63
pause
92
64
exit /b 1
93
65
)
94
66
95
- REM === Step 06: Add pre-requisite packages ===
96
- call :log_section Add pre-requisite packages
67
+ REM === Install Prerequisites ===
68
+ call :pip_install " %my_WINPYDIRBASE% " " %mandatory_requirements% " " Mandatory requirements"
69
+ call :pip_install " %my_WINPYDIRBASE% " " %my_requirements_pre% " " Pre-requirements"
70
+ call :pip_install " %my_WINPYDIRBASE% " " %my_requirements% " " Main requirements"
97
71
98
- set " path = %my_original_path% "
99
- call " %my_WINPYDIRBASE% \scripts\env.bat"
100
-
101
- rem python -m ensurepip
102
- REM Upgrade essential pip tools
103
- python -m pip install --upgrade pip setuptools wheel wppm -c " %my_constraints% " --pre --no-index --trusted-host=None --find-links=" %my_find_links% " >> " %my_archive_log% "
72
+ REM === Patch WinPython ===
73
+ python -c " from wppm import wppm; wppm.Distribution(r'%WINPYDIR% ').patch_standard_packages('', to_movable=True)"
104
74
105
- REM Install additional pre-requirements if specified
106
- if defined my_requirements_pre (
107
- if not defined my_find_links_pre set " my_find_links_pre = %my_find_links% "
108
- python -m pip install -r " %my_requirements_pre% " -c " %my_constraints% " --pre --no-index --trusted-host=None --find-links=" %my_find_links_pre% " >> " %my_archive_log% "
109
- ) else (
110
- echo No pre-requisite packages specified >> " %my_archive_log% "
111
- )
112
-
113
- REM === Step 07: Install main requirement packages ===
114
- call :log_section Add main requirement packages
115
- python -m pip install -r " %my_requirements% " -c " %my_constraints% " --pre --no-index --trusted-host=None --find-links=" %my_find_links% " >> " %my_archive_log% "
116
-
117
- REM Patch installed packages to be portable (WinPython style)
118
- python -c " from wppm import wppm;dist=wppm.Distribution(r'%WINPYDIR% ');dist.patch_standard_packages('', to_movable=True)"
119
-
120
- REM === Step 08: Define lockfile paths for included wheels ===
75
+ REM === Lock files and requirements ===
121
76
set " WINPYVERLOCK = %WINPYVER2:. =_ % "
122
77
set " LOCKDIR = %WINPYDIRBASE% \..\"
123
78
@@ -126,7 +81,7 @@ set "pip_lock_includedweb=%LOCKDIR%pylock.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%
126
81
set " req_lock_includedlocal = %LOCKDIR% requir.%WINPYARCH% -%WINPYVERLOCK%%my_flavor%%my_release_level% _wheelslocal.txt"
127
82
set " req_lock_includedweb = %LOCKDIR% requir.%WINPYARCH% -%WINPYVERLOCK%%my_flavor%%my_release_level% _wheels.txt"
128
83
129
- REM === Step 09: Add lockfile wheels for the Wheelhouse (optional) ===
84
+ REM === Add lockfile wheels for the Wheelhouse (optional) ===
130
85
if defined wheelhousereq if exist " %wheelhousereq% " (
131
86
call :log_section Add wheels for the Wheelhouse
132
87
@@ -143,11 +98,7 @@ if defined wheelhousereq if exist "%wheelhousereq%" (
143
98
" %my_WINPYDIRBASE% \python\scripts\wppm.exe" " %pip_lock_includedweb% " -ws " %my_find_links% " -wd " %my_WINPYDIRBASE% \wheelhouse\included.wheels"
144
99
)
145
100
146
- rem set path=%my_original_path%
147
- rem call %my_WINPYDIRBASE%\scripts\env.bat
148
-
149
-
150
- REM === Step 10: Freeze environment and generate final lockfiles ===
101
+ REM === Freeze environment and generate final lockfiles ===
151
102
call :log_section Freeze environment and generate lockfiles
152
103
153
104
set " req = %LOCKDIR% requirement.%my_flavor% -%WINPYARCH% bit-%WINPYVERLOCK% _raw.txt"
@@ -188,45 +139,54 @@ copy /Y "%req_lock_web%" "%my_changelog_reqfile%"
188
139
189
140
call :log_section Archive success
190
141
191
- REM === Step 11: Generate changelog and binaries ===
192
- call :log_section Generate changelog and binaries
193
-
194
- REM Define markdown changelog filenames
195
- set " mdn = WinPython%my_flavor% -%my_arch% bit-%WINPYVER2% .md"
196
- set " out = WinPython%my_flavor% -%my_arch% bit-%WINPYVER2% _History.md"
197
-
198
- REM Create markdown package list
199
- %target_python_exe% -m wppm -md > " %my_WINPYDIRBASE% \..\%mdn% "
200
- copy /Y " %my_WINPYDIRBASE% \..\%mdn% " " %~dp0 changelogs\%mdn% "
142
+ REM === Generate changelog and history ===
143
+ call :log_section Generate changelog
144
+ call :generate_changelog
201
145
202
- REM Generate historical diff
203
- %target_python_exe% -c " from wppm import diff; result = diff.compare_package_indexes('%WINPYVER2% ', searchdir=r'%~dp0 changelogs', flavor=r'%my_flavor% ', architecture=%my_arch% ); open(r'%my_WINPYDIRBASE% \..\%out% ', 'w', encoding='utf-8').write(result)"
204
- copy /Y " %my_WINPYDIRBASE% \..\%out% " " %~dp0 changelogs\%out% "
205
-
206
- REM === Step 13b: Compress distribution to .7z or installer ===
146
+ REM === Create installer ===
147
+ call :log_section Creating installer
207
148
set " stem = WinPython%my_arch% -%WINPYVER2%%my_flavor%%my_release_level% "
208
149
%target_python_exe% -c " from wppm import utils; utils.command_installer_7zip(r'%my_WINPYDIRBASE% ', r'%my_WINPYDIRBASE% \..', r'%stem% ', r'%my_create_installer% ')"
209
150
210
- REM === Step 12: Final logs and cleanup ===
151
+ REM === Archive and cleanup ===
211
152
call :log_section Final logs and cleanup
212
153
213
- REM Restore environment
214
- set " path = %my_original_path% "
215
- call " %my_WINPYDIRBASE% \scripts\env.bat"
216
-
217
154
REM Freeze final package versions to archive
218
155
%target_python_exe% -m pip freeze > " %my_archive_log% .packages_versions.txt"
219
156
220
- call :log_section END OF CREATION
221
-
222
157
REM Open log files in Notepad for review
223
158
start notepad.exe " %my_archive_log% "
224
159
start notepad.exe " %my_archive_log% .packages_versions.txt"
160
+ pause
161
+ exit /b
225
162
226
- REM Restore path again (in case env.bat changed it)
163
+ :: ----------------------------------------
164
+ :activate_env
165
+ cd /D " %~dp0 "
227
166
set " path = %my_original_path% "
228
- pause
229
- exit
167
+ call " %~1 \scripts\env.bat"
168
+ exit /b
169
+
170
+ :pip_install
171
+ call :log_section Installing %~3
172
+ call :activate_env " %~1 "
173
+ if not " %~2 " == " " (
174
+ python -m pip install -r " %~2 " -c " %my_constraints% " --pre --no-index --trusted-host=None --find-links=" %my_find_links% " >> " %my_archive_log% "
175
+ ) else (
176
+ echo No %~3 specified >> " %my_archive_log% "
177
+ )
178
+
179
+ exit /b
180
+
181
+ :generate_changelog
182
+ REM Create markdown file and diff history
183
+ set " mdn = WinPython%my_flavor% -%my_arch% bit-%WINPYVER2% .md"
184
+ set " out = WinPython%my_flavor% -%my_arch% bit-%WINPYVER2% _History.md"
185
+ %target_python_exe% -m wppm -md > " %my_WINPYDIRBASE% \..\%mdn% "
186
+ copy /Y " %my_WINPYDIRBASE% \..\%mdn% " " %~dp0 changelogs\%mdn% "
187
+ %target_python_exe% -c " from wppm import diff; result = diff.compare_package_indexes('%WINPYVER2% ', searchdir=r'%~dp0 changelogs', flavor=r'%my_flavor% ', architecture=%my_arch% ); open(r'%my_WINPYDIRBASE% \..\%out% ', 'w', encoding='utf-8').write(result)"
188
+ copy /Y " %my_WINPYDIRBASE% \..\%out% " " %~dp0 changelogs\%out% "
189
+ exit /b
230
190
231
191
:log_section
232
192
echo . >> %my_archive_log%
0 commit comments