8000 Merge pull request #1661 from stonebig/master · winpython/winpython@4a1cd78 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4a1cd78

Browse files
authored
Merge pull request #1661 from stonebig/master
simplify make.py given parameters
2 parents 425dff3 + 5809dbd commit 4a1cd78

File tree

2 files changed

+25
-35
lines changed

2 files changed

+25
-35
lines changed

generate_a_winpython_distro.bat

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ if %my_python_target%==312 set my_python_target_release=31210& set my_release=2
3030
if %my_python_target%==313 set my_python_target_release=3135& set my_release=1
3131
if %my_python_target%==314 set my_python_target_release=3140& set my_release=1
3232

33+
set my_basedir_wpy=%my_basedir%\bu%my_flavor%\WPy%my_arch%-%my_python_target_release%%my_release%
34+
3335
echo -------------------------------------- >>%my_archive_log%
3436
echo (%date% %time%) preparing winPython for %my_pyver% (%my_python_target%)release %my_release%%my_flavor% (%my_release_level%) *** %my_arch% bit ***>>%my_archive_log%
3537
echo -------------------------------------- >>%my_archive_log%
@@ -59,7 +61,7 @@ call %my_buildenv%\scripts\env.bat
5961

6062
REM Create basic build infrastructure
6163
echo "(%date% %time%) Create basic build infrastructure">>%my_archive_log%
62-
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%', create_installer='False', python_target_release='%my_python_target_release%')">>%my_archive_log%
64+
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', basedir_wpy=r'%my_basedir_wpy%', verbose=True, 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%', create_installer='False', python_target_release='%my_python_target_release%')">>%my_archive_log%
6365

6466
REM Check infrastructure is in place
6567
echo "(%date% %time%) Check infrastructure">>%my_archive_log%
@@ -209,7 +211,7 @@ set path=%my_original_path%
209211
cd /D %~dp0
210212
call %my_buildenv%\scripts\env.bat
211213

212-
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%
214+
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', basedir_wpy=r'%my_basedir_wpy%', verbose=True, 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%
213215

214216

215217
echo -------------------------------------- >>%my_archive_log%

make.py

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,16 @@ class WinPythonDistributionBuilder:
5959

6060
def __init__(self, build_number: int, release_level: str, target_directory: Path, wheels_directory: Path,
6161
tools_directories: list[Path] = None, verbose: bool = False,
62-
base_directory: Path = None, install_options: list[str] = None, flavor: str = ""):
62+
install_options: list[str] = None, flavor: str = ""):
6363
"""
6464
Initializes the WinPythonDistributionBuilder.
6565
Args:
6666
build_number: The build number (integer).
6767
release_level: The release level (e.g., "beta", "").
68-
target_directory: The base directory where WinPython will be created.
68+
target_directory: The base directory below which WinPython will be created.
6969
wheels_directory: Directory containing wheel files for packages.
7070
tools_directories: List of directories containing development tools to include.
7171
verbose: Enable verbose output.
72-
base_directory: Base directory for building (optional, for relative paths).
7372
install_options: Additional pip install options.
7473
flavor: WinPython flavor (e.g., "Barebone").
7574
"""
@@ -81,7 +80,6 @@ def __init__(self, build_number: int, release_level: str, target_directory: Path
8180
self.verbose = verbose
8281
self.winpython_directory: Path | None = None
8382
self.distribution: wppm.Distribution | None = None
84-
self.base_directory = base_directory
8583
self.install_options = install_options or []
8684
self.flavor = flavor
8785
self.python_zip_file: Path = self._get_python_zip_file()
@@ -132,11 +130,11 @@ def architecture_bits(self) -> int:
132130
def create_installer_7zip(self, installer_type: str = "exe", compression= "mx5"):
133131
"""Creates a WinPython installer using 7-Zip: "exe", "7z", "zip")"""
134132
self._print_action(f"Creating WinPython installer ({installer_type})")
135-
if installer_type not in ["exe", "7z", "zip"]:
136-
return
137133
DISTDIR = self.winpython_directory
138134
filename_stem = f"Winpython{self.architecture_bits}-{self.python_full_version}.{self.build_number}{self.flavor}{self.release_level}"
139135
fullfilename = DISTDIR.parent / (filename_stem + "." + installer_type)
136+
if installer_type not in ["exe", "7z", "zip"]:
137+
return
140138
sfx_option = "-sfx7z.sfx" if installer_type == "exe" else ""
141139
zip_option = "-tzip" if installer_type == "zip" else ""
142140
compress_level = "mx5" if compression == "" else compression
@@ -182,12 +180,12 @@ def _create_initial_batch_scripts(self):
182180
with open(self.winpython_directory / "scripts" / "env.ini", "w") as f:
183181
f.writelines([f'{a}={b}\n' for a, b in init_variables])
184182

185-
def build(self, rebuild: bool = True, winpy_dirname: str = None):
183+
def build(self, rebuild: bool = True, winpy_dir: Path = None):
186184
"""Make or finalise WinPython distribution in the target directory"""
187185
print(f"Building WinPython with Python archive: {self.python_zip_file.name}")
188-
if winpy_dirname is None:
186+
if winpy_dir is None:
189187
raise RuntimeError("WinPython base directory to create is undefined")
190-
self.winpython_directory = self.target_directory / winpy_dirname
188+
self.winpython_directory = winpy_dir
191189

192190
if rebuild:
193191
self._print_action(f"Creating WinPython {self.winpython_directory} base directory")
@@ -222,7 +220,7 @@ def build(self, rebuild: bool = True, winpy_dirname: str = None):
222220
shutil.copyfile(output_markdown_filename, str(Path(CHANGELOGS_DIRECTORY) / Path(output_markdown_filename).name))
223221
diff.write_changelog(self.winpyver2, None, CHANGELOGS_DIRECTORY, self.flavor, self.distribution.architecture, basedir=self.winpython_directory.parent)
224222

225-
def make_all(build_number: int, release_level: str, pyver: str, architecture: int, basedir: Path,
223+
def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
226224
verbose: bool = False, rebuild: bool = True, create_installer: str = "True", install_options=["--no-index"],
227225
flavor: str = "", find_links: str | list[Path] = None,
228226
source_dirs: Path = None, toolsdirs: str | list[Path] = None,
@@ -233,9 +231,7 @@ def make_all(build_number: int, release_level: str, pyver: str, architecture: in
233231
Args:
234232
build_number: build number [int]
235233
release_level: release level (e.g. 'beta1', '') [str]
236-
pyver: python version ('3.4' or 3.5')
237-
architecture: [int] (32 or 64)
238-
basedir: where to create the build (r'D:\Winpython\basedir34')
234+
basedir_wpy: top directory of the build (c:\...\Wpy...)
239235
verbose: Enable verbose output (bool).
240236
rebuild: Whether to rebuild the distribution (bool).
241237
create_installer: Type of installer to create (str).
@@ -246,37 +242,31 @@ def make_all(build_number: int, release_level: str, pyver: str, architecture: in
246242
toolsdirs: Directory with development tools r'D:\WinPython\basedir34\t.Slim'
247243
python_target_release: Target Python release (str).
248244
"""
249-
assert basedir is not None, "The *basedir* directory must be specified"
250-
assert architecture in (32, 64)
245+
assert basedir_wpy is not None, "The *winpython_dirname* directory must be specified"
251246

252247
tools_dirs_list = parse_list_argument(toolsdirs, ",")
253248
install_options_list = parse_list_argument(install_options, " ")
254249
find_links_dirs_list = parse_list_argument(find_links, ",")
255250
find_links_options = [f"--find-links={link}" for link in find_links_dirs_list + [source_dirs]]
256-
build_directory = Path(basedir) / ("bu" + flavor)
251+
winpy_dir = Path(basedir_wpy)
257252

258253
if rebuild:
259-
utils.print_box(f"Making WinPython {architecture}bits at {Path(basedir) / ('bu' + flavor)}")
260-
os.makedirs(build_directory, exist_ok=True)
254+
utils.print_box(f"Making WinPython at {winpy_dir}")
255+
os.makedirs(winpy_dir, exist_ok=True)
261256

262257
builder = WinPythonDistributionBuilder(
263-
build_number, release_level, build_directory, wheels_directory=source_dirs,
258+
build_number, release_level, winpy_dir.parent, wheels_directory=source_dirs,
264259
tools_directories=[Path(d) for d in tools_dirs_list],
265-
verbose=verbose, base_directory=basedir,
260+
verbose=verbose,
266261
install_options=install_options_list + find_links_options,
267262
flavor=flavor
268263
)
269264
# define the directory where to create the distro
270265
python_minor_version_str = "".join(builder.python_name.replace(".amd64", "").split(".")[-2:-1])
271266
while not python_minor_version_str.isdigit() and len(python_minor_version_str) > 0:
272267
python_minor_version_str = python_minor_version_str[:-1]
273-
# simplify for PyPy
274-
if python_target_release is not None:
275-
winpython_dirname = f"WPy{architecture}-{python_target_release}{build_number}{release_level}"
276-
else:
277-
winpython_dirname = f"WPy{architecture}-{pyver.replace('.', '')}{python_minor_version_str}{build_number}{release_level}"
278268

279-
builder.build(rebuild=rebuild, winpy_dirname=winpython_dirname)
269+
builder.build(rebuild=rebuild, winpy_dir=winpy_dir)
280270

281271
for commmand in create_installer.lower().replace("7zip",".exe").split('.'):
282272
installer_type, compression = (commmand + "-").split("-")[:2]
@@ -286,14 +276,12 @@ def make_all(build_number: int, release_level: str, pyver: str, architecture: in
286276
# DO create only one Winpython distribution at a time
287277
make_all(
288278
build_number=1,
289-
release_level="build3",
290-
pyver="3.4",
291-
basedir=r"D:\Winpython\basedir34",
279+
release_level="b3",
280+
basedir_wpy=r"D:\WinPython\bd314\budot\WPy64-31401b3",
292281
verbose=True,
293-
architecture=64,
294-
flavor="Barebone",
282+
flavor="dot",
295283
install_options=r"--no-index --pre --trusted-host=None",
296284
find_links=r"D:\Winpython\packages.srcreq",
297-
source_dirs=r"D:\WinPython\basedir34\packages.win-amd64",
298-
toolsdirs=r"D:\WinPython\basedir34\t.Slim",
285+
source_dirs=r"D:\WinPython\bd314\packages.win-amd64",
286+
toolsdirs=r"D:\WinPython\bd314\t.Slim",
299287
)

0 commit comments

Comments
 (0)
0