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 1d31d51

Browse filesBrowse files
committed
simplify
1 parent a496b25 commit 1d31d51
Copy full SHA for 1d31d51

File tree

Expand file treeCollapse file tree

1 file changed

+38
-64
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+38
-64
lines changed

‎make.py

Copy file name to clipboardExpand all lines: make.py
+38-64Lines changed: 38 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,9 @@ class WinPythonDistributionBuilder:
127127

128128
NODEJS_RELATIVE_PATH = r"\n" # Relative path within WinPython dir
129129

130-
def __init__(
131-
self,
132-
build_number: int,
133-
release_level: str,
134-
target_directory: Path,
135-
wheels_directory: Path,
136-
tools_directories: list[Path] = None,
137-
documentation_directories: list[Path] = None,
138-
verbose: bool = False,
139-
base_directory: Path = None,
140-
install_options: list[str] = None,
141-
flavor: str = "",
142-
):
130+
def __init__(self, build_number: int, release_level: str, target_directory: Path, wheels_directory: Path,
131+
tools_directories: list[Path] = None, documentation_directories: list[Path] = None, verbose: bool = False,
132+
base_directory: Path = None, install_options: list[str] = None, flavor: str = ""):
143133
"""
144134
Initializes the WinPythonDistributionBuilder.
145135
@@ -269,7 +259,7 @@ def python_executable_directory(self) -> str:
269259
if python_path_directory and python_path_directory.is_dir():
270260
return str(python_path_directory)
271261
else:
272-
python_path_executable = self.winpython_directory / self.python_name if self.winpython_directory else None # Fallback for older structure
262+
python_path_executable = self.winpython_directory / self.python_name if self.winpython_directory else None
273263
return str(python_path_executable) if python_path_executable else ""
274264

275265
@property
@@ -321,15 +311,12 @@ def _print_action(self, text: str):
321311
def _extract_python_archive(self):
322312
"""Extracts the Python zip archive to create the base Python environment."""
323313
self._print_action("Extracting Python archive")
324-
utils.extract_archive(
325-
str(self.python_zip_file),
326-
targetdir=str(self.winpython_directory), # Extract directly to winpython_directory
327-
)
314+
utils.extract_archive(self.python_zip_file, self.winpython_directory)
328315
# Relocate to /python subfolder if needed (for newer structure) #2024-12-22 to /python
329316
expected_python_directory = self.winpython_directory / self.python_directory_name
330317
if self.python_directory_name != self.python_name and not expected_python_directory.is_dir():
331318
os.rename(self.winpython_directory / self.python_name, expected_python_directory)
332-
319+
333320
def _copy_essential_files(self):
334321
"""Copies pre-made objects"""
335322
self._print_action("Copying default scripts")
@@ -347,11 +334,9 @@ def _copy_essential_files(self):
347334
_copy_items(self.tools_directories, tools_target_directory, self.verbose)
348335

349336
# Special handling for Node.js to move it up one level
350-
nodejs_current_directory = tools_target_directory / "n"
351-
nodejs_target_directory = self.winpython_directory / self.NODEJS_RELATIVE_PATH
352-
if nodejs_current_directory != nodejs_target_directory and nodejs_current_directory.is_dir():
337+
if (nodejs_current_directory := tools_target_directory / "n").is_dir():
353338
try:
354-
shutil.move(nodejs_current_directory, nodejs_target_directory)
339+
shutil.move(nodejs_current_directory, self.winpython_directory / self.NODEJS_RELATIVE_PATH)
355340
except Exception as e:
356341
print(f"Error moving Node.js directory: {e}")
357342

@@ -380,14 +365,13 @@ def _create_initial_batch_scripts(self):
380365

381366
def build(self, rebuild: bool = True, requirements_files_list=None, winpy_dirname: str = None):
382367
"""Make or finalise WinPython distribution in the target directory"""
383-
384-
python_zip_filename = self.python_zip_file.name
385-
print(f"Building WinPython with Python archive: {python_zip_filename}")
368+
print(f"Building WinPython with Python archive: {self.python_zip_file.name}")
386369

387370
if winpy_dirname is None:
388371
raise RuntimeError("WinPython base directory to create is undefined")
389372
else:
390373
self.winpython_directory = self.target_directory / winpy_dirname # Create/re-create the WinPython base directory
374+
391375
if rebuild:
392376
self._print_action(f"Creating WinPython {self.winpython_directory} base directory")
393377
if self.winpython_directory.is_dir():
@@ -448,37 +432,32 @@ def rebuild_winpython_package(source_directory: Path, target_directory: Path, ar
448432
utils.buildflit_wininst(source_directory, copy_to=target_directory, verbose=verbose)
449433

450434

451-
def make_all(
452-
build_number: int,
453-
release_level: str,
454-
pyver: str,
455-
architecture: int,
456-
basedir: Path,
457-
verbose: bool = False,
458-
rebuild: bool = True,
459-
create_installer: str = "True",
460-
install_options=["--no-index"],
461-
flavor: str = "",
462-
requirements: str | list[Path] = None,
463-
find_links: str | list[Path] = None,
464-
source_dirs: Path = None,
465-
toolsdirs: str | list[Path] = None,
466-
docsdirs: str | list[Path] = None,
467-
python_target_release: str = None, # e.g. "37101" for 3.7.10
435+
def make_all(build_number: int, release_level: str, pyver: str, architecture: int, basedir: Path,
436+
verbose: bool = False, rebuild: bool = True, create_installer: str = "True", install_options=["--no-index"],
437+
flavor: str = "", requirements: str | list[Path] = None, find_links: str | list[Path] = None,
438+
source_dirs: Path = None, toolsdirs: str | list[Path] = None, docsdirs: str | list[Path] = None,
439+
python_target_release: str = None, # e.g. "37101" for 3.7.10
468440
):
469-
"""Make a WinPython distribution for a given set of parameters:
470-
`build_number`: build number [int]
471-
`release_level`: release level (e.g. 'beta1', '') [str]
472-
`pyver`: python version ('3.4' or 3.5')
473-
`architecture`: [int] (32 or 64)
474-
`basedir`: where to create the build (r'D:\Winpython\basedir34')
475-
`requirements`: package lists for pip (r'D:\requirements.txt')
476-
`install_options`: pip options (r'--no-index --pre --trusted-host=None')
477-
`find_links`: package directories (r'D:\Winpython\packages.srcreq')
478-
`source_dirs`: the python.zip + rebuilt winpython wheel package directory
479-
`toolsdirs`: r'D:\WinPython\basedir34\t.Slim'
480-
`docsdirs`: r'D:\WinPython\basedir34\docs.Slim'"""
481-
441+
"""
442+
Make a WinPython distribution for a given set of parameters:
443+
Args:
444+
build_number: build number [int]
445+
release_level: release level (e.g. 'beta1', '') [str]
446+
pyver: python version ('3.4' or 3.5')
447+
architecture: [int] (32 or 64)
448+
basedir: where to create the build (r'D:\Winpython\basedir34')
449+
verbose: Enable verbose output (bool).
450+
rebuild: Whether to rebuild the distribution (bool).
451+
create_installer: Type of installer to create (str).
452+
install_options: pip options (r'--no-index --pre --trusted-host=None')
453+
flavor: WinPython flavor (str).
454+
requirements: package lists for pip (r'D:\requirements.txt')
455+
find_links: package directories (r'D:\Winpython\packages.srcreq')
456+
source_dirs: the python.zip + rebuilt winpython wheel package directory
457+
toolsdirs: Directory with development tools r'D:\WinPython\basedir34\t.Slim'
458+
docsdirs: Directory with documentation r'D:\WinPython\basedir34\docs.Slim'
459+
python_target_release: Target Python release (str).
460+
"""
482461
assert basedir is not None, "The *basedir* directory must be specified"
483462
assert architecture in (32, 64)
484463

@@ -492,24 +471,19 @@ def make_all(
492471
build_directory = str(Path(basedir) / ("bu" + flavor))
493472

494473
if rebuild:
495-
# Rebuild Winpython Wheel Package
496474
utils.print_box(f"Making WinPython {architecture}bits at {Path(basedir) / ('bu' + flavor)}")
497475
os.makedirs(Path(build_directory), exist_ok=True)
498476
# use source_dirs as the directory to re-build Winpython wheel
499477
winpython_source_dir = Path(__file__).resolve().parent
500478
rebuild_winpython_package(winpython_source_dir, source_dirs, architecture, verbose)
501479

502480
builder = WinPythonDistributionBuilder(
503-
build_number,
504-
release_level,
505-
build_directory,
506-
wheels_directory=source_dirs,
481+
build_number, release_level, build_directory, wheels_directory=source_dirs,
507482
tools_directories=[Path(d) for d in tools_dirs_list],
508483
documentation_directories=[Path(d) for d in docs_dirs_list],
509-
verbose=verbose,
510-
base_directory=basedir,
484+
verbose=verbose, base_directory=basedir,
511485
install_options=install_options_list + find_links_options,
512-
flavor=flavor,
486+
flavor=flavor
513487
)
514488
# define the directory where to create the distro
515489
python_minor_version_str = "".join(builder.python_name.replace(".amd64", "").split(".")[-2:-1])

0 commit comments

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