Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3bae9b4

Browse files
authored
Merge pull request #1510 from stonebig/master
clarify and remove _create_standard_batch_scripts()
2 parents 1269166 + 2c4cd94 commit 3bae9b4

File tree

1 file changed

+22
-48
lines changed

1 file changed

+22
-48
lines changed

make.py

+22-48
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,6 @@ def _create_initial_batch_scripts(self):
472472
utils.patch_sourcefile(destspe,'{full_path_ps_env_var}', full_path_ps_env_var)
473473

474474

475-
def _create_standard_batch_scripts(self):
476-
"""Creates standard WinPython batch scripts for various actions."""
477-
self._print_action("Creating standard batch scripts")
478-
479-
exe_name = self.distribution.short_exe if self.distribution else "python.exe"
480-
481-
482475
def build(self, rebuild: bool = True, requirements=None, winpy_dirname: str = None):
483476
"""Make WinPython distribution in target directory from the installers
484477
located in wheels_dir
@@ -515,8 +508,9 @@ def build(self, rebuild: bool = True, requirements=None, winpy_dirname: str = No
515508
if rebuild:
516509
self._copy_default_scripts()
517510
self._create_initial_batch_scripts()
518-
self._create_standard_batch_scripts()
519511
self._copy_launchers()
512+
self._copy_tools()
513+
self._copy_documentation()
520514

521515
utils.python_execmodule("ensurepip", self.distribution.target) # Ensure pip is installed for PyPy
522516
self.distribution.patch_standard_packages("pip")
@@ -530,9 +524,6 @@ def build(self, rebuild: bool = True, requirements=None, winpy_dirname: str = No
530524
self.distribution.do_pip_action(actions)
531525
self.distribution.patch_standard_packages(package_name)
532526

533-
self._copy_tools()
534-
self._copy_documentation()
535-
536527
if requirements:
537528
if not list(requirements) == requirements:
538529
requirements = requirements.split(",")
@@ -574,20 +565,15 @@ def rebuild_winpython_package(source_dir: Path, target_dir: Path, architecture:
574565
for filename in os.listdir(target_dir):
575566
if filename.startswith("winpython-") and filename.endswith((".exe", ".whl", ".gz")):
576567
os.remove(Path(target_dir) / filename)
577-
578-
utils.buildflit_wininst(
579-
str(source_dir),
580-
copy_to=str(target_dir),
581-
verbose=verbose,
582-
)
568+
utils.buildflit_wininst(source_dir, copy_to=target_dir, verbose=verbose)
583569

584570

585-
def _parse_list_argument(arg_value: str | list[str]) -> list[str]:
586-
"""Parses a string or comma separated list argument into a list of strings."""
571+
def _parse_list_argument(arg_value: str | list[str], separator=" ") -> list[str]:
572+
"""Parse a separated list argument into a list of strings."""
587573
if arg_value is None:
588574
return []
589575
if isinstance(arg_value, str):
590-
return arg_value.split(",")
576+
return arg_value.split(separator)
591577
return list(arg_value)
592578

593579

@@ -626,49 +612,37 @@ def make_all(
626612

627613
assert basedir is not None, "The *basedir* directory must be specified"
628614
assert architecture in (32, 64)
629-
utils.print_box(
630-
f"Making WinPython {architecture}bits"
631-
+ f" at {Path(basedir) / ('bu' + flavor)}"
632-
)
633615

634-
# Create Build director, where Winpython will be constructed
616+
# Parse list arguments
617+
tools_dirs_list = _parse_list_argument(toolsdirs, ",")
618+
docs_dirs_list = _parse_list_argument(docsdirs, ",")
619+
install_options_list = _parse_list_argument(install_options, " ")
620+
find_links_dirs_list = _parse_list_argument(find_links, ",")
621+
requirements_files_list = [Path(f) for f in _parse_list_argument(requirements, ",") if f] # ensure Path objects
622+
find_links_options = [f"--find-links={link}" for link in find_links_dirs_list + [source_dirs]]
635623
builddir = str(Path(basedir) / ("bu" + flavor))
636-
os.makedirs(Path(builddir), exist_ok=True)
637-
# use source_dirs as the directory to re-build Winpython wheel
638-
wheels_dir = source_dirs
639-
640-
# Rebuild WinPython package
641-
winpython_source_dir = Path(__file__).resolve().parent
642-
rebuild_winpython_package(
643-
source_dir=winpython_source_dir,
644-
target_dir=wheels_dir,
645-
architecture=architecture,
646-
verbose=verbose,
647-
)
648624

649-
# Parse list arguments
650-
tools_dirs_list = _parse_list_argument(toolsdirs)
651-
docs_dirs_list = _parse_list_argument(docsdirs)
652-
install_options_list = _parse_list_argument(install_options)
653-
find_links_dirs_list = _parse_list_argument(find_links)
654-
requirements_files_list = [Path(f) for f in _parse_list_argument(requirements) if f] # ensure Path objects
625+
if rebuild:
626+
# Rebuild Winpython Wheel Package
627+
utils.print_box(f"Making WinPython {architecture}bits at {Path(basedir) / ('bu' + flavor)}")
628+
os.makedirs(Path(builddir), exist_ok=True)
629+
# use source_dirs as the directory to re-build Winpython wheel
630+
winpython_source_dir = Path(__file__).resolve().parent
631+
rebuild_winpython_package(winpython_source_dir, source_dirs, architecture, verbose)
655632

656-
find_links_options = [f"--find-links={link}" for link in find_links_dirs_list + [wheels_dir]]
657633
builder = WinPythonDistributionBuilder(
658634
build_number,
659635
release_level,
660636
builddir,
661-
wheels_dir=wheels_dir,
637+
wheels_dir=source_dirs,
662638
tools_dirs=[Path(d) for d in tools_dirs_list],
663639
docs_dirs=[Path(d) for d in docs_dirs_list],
664640
verbose=verbose,
665641
base_dir=basedir,
666642
install_options=install_options_list + find_links_options,
667643
flavor=flavor,
668644
)
669-
# define a pre-defined winpydir, instead of having to guess
670-
671-
# extract the python subversion to get WPy64-3671b1
645+
# define the directory where to create the distro
672646
my_x = "".join(builder.python_name.replace(".amd64", "").split(".")[-2:-1])
673647
while not my_x.isdigit() and len(my_x) > 0:
674648
my_x = my_x[:-1]

0 commit comments

Comments
 (0)