Skip to content

Commit 0c709f3

Browse files
committed
remove useless renaming of variables and changes of parameters order
1 parent 3375635 commit 0c709f3

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

make.py

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright © 2012 Pierre Raybaut
55
# Copyright © 2014-2025+ The Winpython development team https://github.com/winpython/
66
# Licensed under the terms of the MIT License
7-
# (see winpython/__init__.py for details)
7+
# (see wppm/__init__.py for details)
88

99
import os
1010
import re
@@ -40,27 +40,27 @@ def parse_list_argument(argument_value: str | list[str], separator=" ") -> list[
4040
class WinPythonDistributionBuilder:
4141
"""Builds a WinPython distribution."""
4242

43-
def __init__(self, build_number: int, release_level: str, target_directory: Path, wheels_directory: Path,
44-
tools_directories: list[Path] = None, verbose: bool = False,
45-
flavor: str = ""):
43+
def __init__(self, build_number: int, release_level: str, basedir_wpy: Path,
44+
source_dirs: Path, tools_directories: list[Path] = None,
45+
verbose: bool = False, flavor: str = ""):
4646
"""
4747
Initializes the WinPythonDistributionBuilder.
4848
Args:
4949
build_number: The build number (integer).
5050
release_level: The release level (e.g., "beta", "").
51-
target_directory: The base directory below which WinPython will be created.
52-
wheels_directory: Directory containing wheel files for packages.
51+
basedir_wpy: top directory of the build (c:\...\Wpy...)
52+
source_dirs: Directory containing wheel files for packages.
5353
tools_directories: List of directories containing development tools to include.
5454
verbose: Enable verbose output.
5555
flavor: WinPython flavor (e.g., "Barebone").
5656
"""
5757
self.build_number = build_number
5858
self.release_level = release_level
59-
self.target_directory = Path(target_directory)
60-
self.wheels_directory = Path(wheels_directory)
59+
self.winpython_directory = Path(basedir_wpy)
60+
self.target_directory = self.winpython_directory.parent
61+
self.source_dirs = Path(source_dirs)
6162
self.tools_directories = tools_directories or []
6263
self.verbose = verbose
63-
self.winpython_directory: Path | None = None
6464
self.distribution: wppm.Distribution | None = None
6565
self.flavor = flavor
6666
self.python_zip_file: Path = self._get_python_zip_file()
@@ -69,10 +69,10 @@ def __init__(self, build_number: int, release_level: str, target_directory: Path
6969

7070
def _get_python_zip_file(self) -> Path:
7171
"""Finds the Python .zip file in the wheels directory."""
72-
for source_item in self.wheels_directory.iterdir():
72+
for source_item in self.source_dirs.iterdir():
7373
if re.match(r"(pypy3|python-).*\.zip", source_item.name):
7474
return source_item
75-
raise RuntimeError(f"Could not find Python zip package in {self.wheels_directory}")
75+
raise RuntimeError(f"Could not find Python zip package in {self.source_dirs}")
7676

7777
@property
7878
def winpython_version_name(self) -> str:
@@ -108,7 +108,6 @@ def _copy_essential_files(self):
108108

109109
def _create_env_config(self):
110110
"""Creates environment setup"""
111-
self._print_action("Creating env.ini environment setup")
112111
executable_name = self.distribution.short_exe if self.distribution else "python.exe"
113112
config = {
114113
"WINPYthon_exe": executable_name,
@@ -123,10 +122,9 @@ def _create_env_config(self):
123122
self._print_action(f"Creating env.ini environment {env_path}")
124123
env_path.write_text("\n".join(f"{k}={v}" for k, v in config.items()))
125124

126-
def build(self, winpy_dir: Path = None):
125+
def build(self):
127126
"""Make or finalise WinPython distribution in the target directory"""
128127
print(f"Building WinPython with Python archive: {self.python_zip_file.name}")
129-
self.winpython_directory = Path(winpy_dir)
130128
self._print_action(f"Creating WinPython {self.winpython_directory} base directory")
131129
if self.winpython_directory.is_dir() and len(self.winpython_directory.parts)>=4:
132130
shutil.rmtree(self.winpython_directory)
@@ -139,10 +137,8 @@ def build(self, winpy_dir: Path = None):
139137
self._create_env_config()
140138

141139
def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
142-
verbose: bool = False,
143-
flavor: str = "",
144140
source_dirs: Path = None, toolsdirs: str | list[Path] = None,
145-
):
141+
verbose: bool = False, flavor: str = ""):
146142
"""
147143
Make a WinPython distribution for a given set of parameters:
148144
Args:
@@ -157,16 +153,14 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
157153
assert basedir_wpy is not None, "The *winpython_dirname* directory must be specified"
158154

159155
tools_directories = [Path(d) for d in parse_list_argument(toolsdirs, ",")]
160-
winpy_dir = Path(basedir_wpy)
161-
utils.print_box(f"Making WinPython at {winpy_dir}")
162-
os.makedirs(winpy_dir, exist_ok=True)
156+
utils.print_box(f"Making WinPython at {basedir_wpy}")
157+
os.makedirs(basedir_wpy, exist_ok=True)
163158

164159
builder = WinPythonDistributionBuilder(
165-
build_number, release_level, winpy_dir.parent, wheels_directory=source_dirs,
166-
tools_directories=tools_directories,
167-
verbose=verbose, flavor=flavor
168-
)
169-
builder.build(winpy_dir)
160+
build_number, release_level, Path(basedir_wpy),
161+
verbose=verbose, flavor=flavor,
162+
source_dirs=source_dirs, tools_directories=tools_directories)
163+
builder.build()
170164

171165
if __name__ == "__main__":
172166
make_all(

0 commit comments

Comments
 (0)