Skip to content

Commit aa9ca12

Browse files
committed
Wheelhouses and how to raise them
1 parent 64a41c3 commit aa9ca12

File tree

6 files changed

+144
-51
lines changed

6 files changed

+144
-51
lines changed

generate_a_winpython_distro.bat

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ rem generate_a_winpython_distro.bat: to be launched from a winpython directory,
22
@echo on
33

44
REM Initialize variables
5-
if "%my_release_level%"=="" set my_release_level=b2
5+
if "%my_release_level%"=="" set my_release_level=b3
66
if "%my_create_installer%"=="" set my_create_installer=True
77

88
rem Set archive directory and log file
@@ -101,21 +101,47 @@ echo -------------------------------------- >>%my_archive_log%
101101
python -m pip install -r %my_requirements% -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links% >>%my_archive_log%
102102
python -c "from winpython import wppm;dist=wppm.Distribution(r'%WINPYDIR%');dist.patch_standard_packages('spyder', to_movable=True)"
103103

104-
REM Archive success
104+
REM Add Wheelhouse (to replace per pip lock direct ? would allow paralellism)
105105
echo -------------------------------------- >>%my_archive_log%
106-
echo "(%date% %time%) Archive success">>%my_archive_log%
106+
echo "(%date% %time%) Add lockfile wheels">>%my_archive_log%
107107
echo -------------------------------------- >>%my_archive_log%
108-
%target_python_exe% -m pip freeze > %my_archive_log%.packages_versions.txt
109-
110-
REM Generate changelog and binaries
111-
echo "(%date% %time%) Generate changelog and binaries">>%my_archive_log%
112108
set path=%my_original_path%
113-
cd /D %~dp0
114-
call %my_buildenv%\scripts\env.bat
115-
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%', rebuild=False, python_target_release='%my_python_target_release%')" >> %my_archive_log%
109+
@echo on
110+
call %my_WINPYDIRBASE%\scripts\env.bat
111+
@echo on
112+
set WINPYVERLOCK=%WINPYVER2:.=_%
113+
set pylockinclude=%my_root_dir_for_builds%\bd%my_python_target%\bu%addlockfile%\pylock.%addlockfile%-%WINPYARCH%bit-%WINPYVERLOCK%.toml
114+
echo pylockinclude="%pylockinclude%"
115+
if not "Z%addlockfile%Z"=="ZZ" if exist "%pylockinclude%" (
116+
echo %my_WINPYDIRBASE%\python\scripts\wppm.exe "%pylockinclude%" -ws "%my_find_links%" -wd "%my_WINPYDIRBASE%\wheelhouse\included.wheels">>%my_archive_log%
117+
%my_WINPYDIRBASE%\python\scripts\wppm.exe "%pylockinclude%" -ws "%my_find_links%" -wd "%my_WINPYDIRBASE%\wheelhouse\included.wheels"
118+
)
116119

117-
echo -------------------------------------- >>%my_archive_log%
118-
echo "(%date% %time%) generate pylock.tomle files and requirement_with_hash.txt files">>%my_archive_log%
120+
@echo on
121+
echo wheelhousereq=%wheelhousereq%
122+
set LOCKDIR=%WINPYDIRBASE%\..\
123+
set pip_lock_includedlocal=%LOCKDIR%pylock.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_includedwheelslocal.toml
124+
set pip_lock_includedweb=%LOCKDIR%pylock.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_includedwheels.toml
125+
set req_lock_includedlocal=%LOCKDIR%requirement.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_includedwheelslocal.txt
126+
set req_lock_includedweb=%LOCKDIR%requirement.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_includedwheels.txt
127+
128+
if not "Z%wheelhousereq%Z"=="ZZ" if exist "%wheelhousereq%" (
129+
echo JOYYYwheelhousereq=%wheelhousereq%
130+
echo z%pip_lock_includedlocal%z=%pip_lock_includedlocal%
131+
rem no winpython in it naturally, with deps
132+
python.exe -m pip lock --no-index --trusted-host=None --find-links=%my_find_links% -c C:\WinP\constraints.txt -r "%wheelhousereq%" -o %pip_lock_includedlocal%
133+
rem generating also classic requirement with hash-256, from obtained pylock.toml
134+
python.exe -c "from winpython import wheelhouse as wh;wh.pylock_to_req(r'%pip_lock_includedlocal%', r'%req_lock_includedlocal%')"
135+
136+
rem same with frozen web from local
137+
python.exe -m pip lock --no-deps --require-hashes -c C:\WinP\constraints.txt -r "%req_lock_includedlocal%" -o %pip_lock_includedweb%
138+
139+
echo %my_WINPYDIRBASE%\python\scripts\wppm.exe "%pip_lock_includedweb%" -ws "%my_find_links%" -wd "%my_WINPYDIRBASE%\wheelhouse\included.wheels">>%my_archive_log%
140+
%my_WINPYDIRBASE%\python\scripts\wppm.exe "%pip_lock_includedweb%" -ws "%my_find_links%" -wd "%my_WINPYDIRBASE%\wheelhouse\included.wheels"
141+
)
142+
143+
echo -------------------------------------- >>%my_archive_log%;
144+
echo "(%date% %time%) generate pylock.toml files and requirement.txt with hash files">>%my_archive_log%
119145
echo -------------------------------------- >>%my_archive_log%
120146

121147
set path=%my_original_path%
@@ -125,17 +151,17 @@ rem generate pip freeze requirements
125151
echo %date% %time%
126152
set LOCKDIR=%WINPYDIRBASE%\..\
127153

128-
set WINPYVERLOCK=%WINPYVER:.=_%
129-
set req=%LOCKDIR%requirement.%WINPYVERLOCK%_raw.txt
130-
set wanted_req=%LOCKDIR%requirement.%WINPYVERLOCK%.txt
131-
set pip_lock_web=%LOCKDIR%pylock.%WINPYVERLOCK%.toml
132-
set pip_lock_local=%LOCKDIR%pylock.%WINPYVER%_local.toml
133-
set req_lock_web=%LOCKDIR%requirement_with_hash.%WINPYVERLOCK%.txt
134-
set req_lock_local=%LOCKDIR%requirement_with_hash.%WINPYVERLOCK%_local.txt
154+
set WINPYVERLOCK=%WINPYVER2:.=_%
155+
set req=%LOCKDIR%requirement.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_raw.txt
156+
set wanted_req=%LOCKDIR%requirement.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%.txt
157+
set pip_lock_web=%LOCKDIR%pylock.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%.toml
158+
set pip_lock_local=%LOCKDIR%pylock.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_local.toml
159+
set req_lock_web=%LOCKDIR%requirement.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%.txt
160+
set req_lock_local=%LOCKDIR%requirement.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_local.txt
135161

136-
set my_archive_lockfile=%my_archive_dir%\pylock.%WINPYVERLOCK%_%date:/=-%at_%my_time%.toml
137-
set my_archive_lockfile_local=%my_archive_dir%\pylock.%WINPYVERLOCK%_%date:/=-%at_%my_time%.local.toml
138-
set my_changelog_lockfile=%~dp0changelogs\pylock.%WINPYVERLOCK%.toml
162+
set my_archive_lockfile=%my_archive_dir%\pylock.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_%date:/=-%at_%my_time%.toml
163+
set my_archive_lockfile_local=%my_archive_dir%\pylock.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_%date:/=-%at_%my_time%.local.toml
164+
set my_changelog_lockfile=%~dp0changelogs\pylock.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%.toml
139165

140166
python.exe -m pip freeze>%req%
141167
findstr /v "winpython" %req% > %wanted_req%
@@ -157,6 +183,25 @@ fc "%req_lock_web%" "%req_lock_local%"
157183
copy/Y %pip_lock_web% %my_archive_lockfile%
158184
copy/Y %pip_lock_web% %my_changelog_lockfile%
159185

186+
187+
REM Archive success
188+
echo -------------------------------------- >>%my_archive_log%
189+
echo "(%date% %time%) Archive success">>%my_archive_log%
190+
echo -------------------------------------- >>%my_archive_log%
191+
set path=%my_original_path%
192+
call %my_WINPYDIRBASE%\scripts\env.bat
193+
194+
%target_python_exe% -m pip freeze > %my_archive_log%.packages_versions.txt
195+
196+
REM Generate changelog and binaries
197+
echo "(%date% %time%) Generate changelog and binaries">>%my_archive_log%
198+
set path=%my_original_path%
199+
cd /D %~dp0
200+
call %my_buildenv%\scripts\env.bat
201+
202+
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%', rebuild=False, python_target_release='%my_python_target_release%')" >> %my_archive_log%
203+
204+
160205
echo -------------------------------------- >>%my_archive_log%
161206
echo "(%date% %time%) END OF CREATION">>%my_archive_log%
162207
echo -------------------------------------- >>%my_archive_log%
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
rem this replace running manually from spyder the make.py
2+
rem to launch from a winpython module 'make' directory
3+
4+
set my_original_path=%path%
5+
6+
set my_root_dir_for_builds=C:\Winp
7+
set my_python_target=313
8+
set my_pyver=3.13
9+
set my_flavor=whl
10+
set my_arch=64
11+
12+
rem settings delegated to generate_a_winpython_distro.bat
13+
set my_release=
14+
set my_release_level=
15+
16+
rem list of installers to create separated per dot: False=none, .zip=zip, .7z=.7z, 7zip=auto-extractible 7z
17+
set my_create_installer=7zip.7z.zip
18+
set my_create_installer=.7z
19+
20+
set my_preclear_build_directory=Yes
21+
22+
set tmp_reqdir=%my_root_dir_for_builds%\bd%my_python_target%
23+
24+
set my_requirements=C:\Winp\bd313\dot_requirements.txt
25+
set my_source_dirs=C:\Winp\bd313\packages.win-amd64
26+
27+
set my_find_links=C:\Winp\packages.srcreq
28+
set my_toolsdirs=C:\Winp\bdTools\Tools.dot
29+
set my_docsdirs=C:\WinP\bdDocs\docs.dot
30+
31+
set my_install_options=--no-index --pre --trusted-host=None
32+
33+
rem set addlockfile=dot
34+
35+
set wheelhousereq=C:\Winp\bd313\requirements64_whl.txt
36+
37+
38+
call %~dp0\generate_a_winpython_distro.bat
39+
40+
pause

make.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def _create_initial_batch_scripts(self):
208208
# Replacements for batch scripts (PyPy compatibility)
209209
executable_name = self.distribution.short_exe if self.distribution else "python.exe" # default to python.exe if distribution is not yet set
210210
init_variables = [('WINPYthon_exe', executable_name), ('WINPYthon_subdirectory_name', self.python_directory_name), ('WINPYVER', self.winpython_version_name)]
211+
init_variables += [('WINPYVER2', f"{self.python_full_version}.{self.build_number}"), ('WINPYFLAVOR', self.flavor), ('WINPYARCH', self.architecture_bits)]
211212
with open(self.winpython_directory / "scripts" / "env.ini", "w") as f:
212213
f.writelines([f'{a}={b}\n' for a, b in init_variables])
213214

@@ -264,7 +265,7 @@ def rebuild_winpython_package(source_directory: Path, target_directory: Path, ar
264265
for file in target_directory.glob("winpython-*"):
265266
if file.suffix in (".exe", ".whl", ".gz"):
266267
file.unlink()
267-
utils.buildflit_wininst(source_directory, copy_to=target_directory, verbose=verbose)
268+
utils.buildflit_wininst(source_directory, copy_to=target_directory, verbose=True)
268269

269270
def make_all(build_number: int, release_level: str, pyver: str, architecture: int, basedir: Path,
270271
verbose: bool = False, rebuild: bool = True, create_installer: str = "True", install_options=["--no-index"],

winpython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

31-
__version__ = '16.1.20250524'
31+
__version__ = '16.1.20250525'
3232
__license__ = __doc__
3333
__project_url__ = 'http://winpython.github.io/'

winpython/wheelhouse.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,20 @@ def run_pip_command(command: List[str], check: bool = True, capture_output=True)
9393
except Exception as e:
9494
return False, f"Unexpected error: {e}"
9595

96-
def get_wheels(requirements: Path, wheeldir: Path, from_local: Optional[Path] = None
96+
def get_wheels(requirements: Path, wheeldrain: Path, wheelorigin: Optional[Path] = None
9797
, only_check: bool = True,post_install: bool = False) -> bool:
9898
"""Download or check Python wheels based on requirements."""
9999
added = []
100-
if from_local:
101-
added += ['--no-index', '--trusted-host=None', f'--find-links={from_local}']
100+
if wheelorigin:
101+
added = ['--no-index', '--trusted-host=None', f'--find-links={wheelorigin}']
102102
pre_checks = [sys.executable, "-m", "pip", "install", "--dry-run", "--no-deps", "--require-hashes", "-r", str(requirements)] + added
103-
instruction = [sys.executable, "-m", "pip", "download", "--no-deps", "--require-hashes", "-r", str(requirements), "--dest", str(wheeldir)] + added
103+
instruction = [sys.executable, "-m", "pip", "download", "--no-deps", "--require-hashes", "-r", str(requirements), "--dest", str(wheeldrain)] + added
104+
if wheeldrain:
105+
added = ['--no-index', '--trusted-host=None', f'--find-links={wheeldrain}']
104106
post_install_cmd = [sys.executable, "-m", "pip", "install", "--no-deps", "--require-hashes", "-r", str(requirements)] + added
105107

106-
# Run pip dry-run, only if a move of directory
107-
if from_local and from_local != wheeldir:
108+
# Run pip dry-run, only if a move of wheels
109+
if wheelorigin and wheelorigin != wheeldrain:
108110
success, output = run_pip_command(pre_checks, check=False)
109111
if not success:
110112
print("❌ Dry-run failed. Here's the output:\n")
@@ -135,43 +137,45 @@ def get_wheels(requirements: Path, wheeldir: Path, from_local: Optional[Path] =
135137

136138
return True
137139

138-
def get_pylock_wheels(wheelhouse: Path, lockfile: Path, from_local: Optional[Path] = None) -> None:
139-
"""Get wheels for a pylock file."""
140+
def get_pylock_wheels(wheelhouse: Path, lockfile: Path, wheelorigin: Optional[Path] = None, wheeldrain: Optional[Path] = None) -> None:
141+
"""Get wheels asked pylock file."""
140142
filename = Path(lockfile).name
141143
wheelhouse.mkdir(parents=True, exist_ok=True)
142144
trusted_wheelhouse = wheelhouse / "included.wheels"
143145
trusted_wheelhouse.mkdir(parents=True, exist_ok=True)
144146

145147
filename_lock = wheelhouse / filename
146-
filename_req = wheelhouse / (Path(lockfile).stem.replace('pylock', 'requirement_with_hash') + '.txt')
148+
filename_req = wheelhouse / (Path(lockfile).stem.replace('pylock', 'requirement') + '.txt')
147149

148150
pylock_to_req(Path(lockfile), filename_req)
149151

150152
if not str(Path(lockfile)) == str(filename_lock):
151153
shutil.copy2(lockfile, filename_lock)
152154

153155
# We create a destination for wheels that is specific, so we can check all is there
154-
destination_wheelhouse = wheelhouse / Path(lockfile).name.replace('.toml', '.wheels')
156+
destination_wheelhouse = Path(wheeldrain) if wheeldrain else wheelhouse / Path(lockfile).name.replace('.toml', '.wheels')
157+
destination_wheelhouse.mkdir(parents=True, exist_ok=True)
158+
# there can be an override
159+
160+
155161
in_trusted = False
156162

157-
if from_local is None:
163+
if wheelorigin is None:
158164
# Try from trusted WheelHouse
159165
print(f"\n\n*** Checking if we can install from our Local WheelHouse: ***\n {trusted_wheelhouse}\n\n")
160-
in_trusted = get_wheels(filename_req, destination_wheelhouse, from_local=trusted_wheelhouse, only_check=True)
166+
in_trusted = get_wheels(filename_req, destination_wheelhouse, wheelorigin=trusted_wheelhouse, only_check=True)
161167
if in_trusted:
162168
print(f"\n\n*** We can install from Local WheelHouse: ***\n {trusted_wheelhouse}\n\n")
163-
user_input = input("Do you want to continue and install from {trusted_wheelhouse} ? (yes/no):")
164-
if user_input.lower() == "yes":
165-
in_installed = get_wheels(filename_req, trusted_wheelhouse, from_local=trusted_wheelhouse, only_check=True, post_install=True)
169+
in_installed = get_wheels(filename_req, trusted_wheelhouse, wheelorigin=trusted_wheelhouse, only_check=True, post_install=True)
166170

167171
if not in_trusted:
168-
post_install = True if from_local and Path(from_local).is_dir and Path(from_local).samefile(destination_wheelhouse) else False
172+
post_install = True if wheelorigin and Path(wheelorigin).is_dir and Path(wheelorigin).samefile(destination_wheelhouse) else False
169173
if post_install:
170174
print(f"\n\n*** Installing from Local WheelHouse: ***\n {destination_wheelhouse}\n\n")
171175
else:
172-
print(f"\n\n*** Re-Checking if we can install from: {'pypi.org' if not from_local or from_local == '' else from_local}\n\n")
176+
print(f"\n\n*** Re-Checking if we can install from: {'pypi.org' if not wheelorigin or wheelorigin == '' else wheelorigin}\n\n")
173177

174-
in_pylock = get_wheels(filename_req, destination_wheelhouse, from_local=from_local, only_check=False, post_install=post_install)
178+
in_pylock = get_wheels(filename_req, destination_wheelhouse, wheelorigin=wheelorigin, only_check=False, post_install=post_install)
175179
if in_pylock:
176180
if not post_install:
177181
print(f"\n\n*** You can now install from this dedicated WheelHouse: ***\n {destination_wheelhouse}")

0 commit comments

Comments
 (0)