Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9953e4c

Browse filesBrowse files
authored
Merge pull request #1518 from stonebig/master
simplify further
2 parents f10f603 + 942872c commit 9953e4c
Copy full SHA for 9953e4c

File tree

Expand file treeCollapse file tree

1 file changed

+12
-29
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-29
lines changed

‎make.py

Copy file name to clipboardExpand all lines: make.py
+12-29Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
assert CHANGELOGS_DIRECTORY.is_dir(), f"Changelogs directory not found: {CHANGELOGS_DIRECTORY}"
2626
assert PORTABLE_DIRECTORY.is_dir(), f"Portable directory not found: {PORTABLE_DIRECTORY}"
2727

28-
2928
def find_7zip_executable() -> str:
3029
"""Locates the 7-Zip executable (7z.exe)."""
3130
possible_program_files = [
@@ -38,7 +37,6 @@ def find_7zip_executable() -> str:
3837
return str(executable_path)
3938
raise RuntimeError("7ZIP is not installed on this computer.")
4039

41-
4240
def replace_lines_in_file(filepath: Path, replacements: list[tuple[str, str]]):
4341
"""
4442
Replaces lines in a file that start with a given prefix.
@@ -98,10 +96,8 @@ def build_installer_7zip(script_template_path: Path, output_script_path: Path, r
9896
except subprocess.CalledProcessError as e:
9997
print(f"Error executing 7-Zip script: {e}", file=sys.stderr)
10098

101-
10299
def _copy_items(source_directories: list[Path], target_directory: Path, verbose: bool = False):
103100
"""Copies items from source directories to the target directory."""
104-
105101
target_directory.mkdir(parents=True, exist_ok=True)
106102
for source_dir in source_directories:
107103
if not source_dir.is_dir():
@@ -118,7 +114,6 @@ def _copy_items(source_directories: list[Path], target_directory: Path, verbose:
118114
except Exception as e:
119115
print(f"Error copying {source_item} to {target_item}: {e}")
120116

121-
122117
def _parse_list_argument(argument_value: str | list[str], separator=" ") -> list[str]:
123118
"""Parse a separated list argument into a list of strings."""
124119
if argument_value is None:
@@ -127,7 +122,6 @@ def _parse_list_argument(argument_value: str | list[str], separator=" ") -> list
127122
return argument_value.split(separator)
128123
return list(argument_value)
129124

130-
131125
class WinPythonDistributionBuilder:
132126
"""Builds a WinPython distribution."""
133127

@@ -163,19 +157,19 @@ def __init__(
163157
"""
164158
self.build_number = build_number
165159
self.release_level = release_level
166-
self.target_directory = Path(target_directory) # Ensure Path object
167-
self.wheels_directory = Path(wheels_directory) # Ensure Path object
160+
self.target_directory = Path(target_directory)
161+
self.wheels_directory = Path(wheels_directory)
168162
self.tools_directories = tools_directories or []
169163
self.documentation_directories = documentation_directories or []
170164
self.verbose = verbose
171-
self.winpython_directory: Path | None = None # Will be set during build
172-
self.distribution: wppm.Distribution | None = None # Will be set during build
165+
self.winpython_directory: Path | None = None
166+
self.distribution: wppm.Distribution | None = None
173167
self.base_directory = base_directory
174168
self.install_options = install_options or []
175169
self.flavor = flavor
176170
self.python_zip_file: Path = self._get_python_zip_file()
177-
self.python_name = self.python_zip_file.stem # Filename without extension
178-
self.python_directory_name = "python" # Standardized Python directory name
171+
self.python_name = self.python_zip_file.stem
172+
self.python_directory_name = "python"
179173

180174
def _get_python_zip_file(self) -> Path:
181175
"""Finds the Python .zip file in the wheels directory."""
@@ -263,10 +257,7 @@ def winpython_version_name(self) -> str:
263257

264258
@property
265259
def python_full_version(self) -> str:
266-
"""
267-
Retrieves the Python full version string from the distribution.
268-
Will be set after _extract_python is called and distribution is initialized.
269-
"""
260+
"""Retrieves the Python full version string from the distribution."""
270261
if self.distribution is None:
271262
return "0.0.0" # Placeholder before initialization
272263
return utils.get_python_long_version(self.distribution.target)
@@ -286,7 +277,7 @@ def architecture_bits(self) -> int:
286277
"""Returns the architecture (32 or 64 bits) of the distribution."""
287278
if self.distribution:
288279
return self.distribution.architecture
289-
return 64 # Default to 64 if distribution is not initialized yet
280+
return 64
290281

291282
@property
292283
def pre_path_entries(self) -> list[str]:
@@ -308,14 +299,10 @@ def documentation_directories_list(self) -> list[Path]:
308299
return self.documentation_directories
309300

310301
def create_installer_7zip(self, installer_type: str = ".exe"):
311-
"""
312-
Creates a WinPython installer using 7-Zip.
313-
314-
Args: installer_type: Type of installer to create (".exe", ".7z", ".zip").
315-
"""
302+
"""Creates a WinPython installer using 7-Zip: ".exe", ".7z", ".zip")"""
316303
self._print_action(f"Creating WinPython installer ({installer_type})")
317304
template_name = "installer_7zip.bat"
318-
output_name = "installer_7zip-tmp.bat" # temp file to avoid overwriting template
305+
output_name = "installer_7zip-tmp.bat"
319306
if installer_type not in [".exe", ".7z", ".zip"]:
320307
print(f"Warning: Unsupported installer type '{installer_type}'. Defaulting to .exe")
321308
installer_type = ".exe"
@@ -326,14 +313,10 @@ def create_installer_7zip(self, installer_type: str = ".exe"):
326313
("VERSION", f"{self.python_full_version}.{self.build_number}{self.flavor}"),
327314
("VERSION_INSTALL", f'{self.python_full_version.replace(".", "")}{self.build_number}'),
328315
("RELEASELEVEL", self.release_level),
329-
("INSTALLER_OPTION", installer_type), # Pass installer type as option to bat script
316+
("INSTALLER_OPTION", installer_type),
330317
]
331318

332-
build_installer_7zip(
333-
PORTABLE_DIRECTORY / template_name,
334-
PORTABLE_DIRECTORY / output_name,
335-
replacements
336-
)
319+
build_installer_7zip(PORTABLE_DIRECTORY / template_name, PORTABLE_DIRECTORY / output_name, replacements)
337320

338321
def _print_action(self, text: str):
339322
"""Prints an action message with progress indicator."""

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.