Skip to content

Commit c3681c7

Browse files
committed
move essential package installation out of make.py
1 parent 6337c91 commit c3681c7

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

generate_a_winpython_distro.bat

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ call %my_buildenv%\scripts\env.bat
6161

6262
REM Create basic build infrastructure
6363
echo "(%date% %time%) Create basic build infrastructure">>%my_archive_log%
64-
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', basedir_wpy=r'%my_WINPYDIRBASE%', 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%')">>%my_archive_log%
64+
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', basedir_wpy=r'%my_WINPYDIRBASE%', verbose=True, flavor='%my_flavor%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%')">>%my_archive_log%
6565

6666
REM Check infrastructure is in place
6767
echo "(%date% %time%) Check infrastructure">>%my_archive_log%
@@ -87,7 +87,11 @@ echo -------------------------------------- >>%my_archive_log%
8787
set path=%my_original_path%
8888
call %my_WINPYDIRBASE%\scripts\env.bat
8989

90-
rem Install pre-requirements if any
90+
rem python -m ensurepip
91+
rem insta essential packages
92+
python -m pip install --upgrade pip setuptools wheel wppm -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links% >>%my_archive_log%
93+
94+
rem Install complementary pre-requirements if any
9195
if not "Z%my_requirements_pre%Z"=="ZZ" (
9296
if "%my_find_links_pre%"=="" set my_find_links_pre=%my_find_links%
9397
python -m pip install -r %my_requirements_pre% -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links_pre% >> %my_archive_log%
@@ -100,7 +104,7 @@ echo -------------------------------------- >>%my_archive_log%
100104
echo "(%date% %time%) Add requirement packages">>%my_archive_log%
101105
echo -------------------------------------- >>%my_archive_log%
102106
python -m pip install -r %my_requirements% -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links% >>%my_archive_log%
103-
python -c "from wppm import wppm;dist=wppm.Distribution(r'%WINPYDIR%');dist.patch_standard_packages('spyder', to_movable=True)"
107+
python -c "from wppm import wppm;dist=wppm.Distribution(r'%WINPYDIR%');dist.patch_standard_packages('', to_movable=True)"
104108

105109
REM Add Wheelhouse (to replace per pip lock direct ? would allow paralellism)
106110
echo -------------------------------------- >>%my_archive_log%

make.py

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
# Define constant paths for clarity
1616
PORTABLE_DIRECTORY = Path(__file__).parent / "portable"
17-
18-
# Ensure necessary directories exist at the start
1917
assert PORTABLE_DIRECTORY.is_dir(), f"Portable directory not found: {PORTABLE_DIRECTORY}"
2018

2119
def copy_items(source_directories: list[Path], target_directory: Path, verbose: bool = False):
@@ -46,7 +44,7 @@ class WinPythonDistributionBuilder:
4644

4745
def __init__(self, build_number: int, release_level: str, target_directory: Path, wheels_directory: Path,
4846
tools_directories: list[Path] = None, verbose: bool = False,
49-
install_options: list[str] = None, flavor: str = ""):
47+
flavor: str = ""):
5048
"""
5149
Initializes the WinPythonDistributionBuilder.
5250
Args:
@@ -56,7 +54,6 @@ def __init__(self, build_number: int, release_level: str, target_directory: Path
5654
wheels_directory: Directory containing wheel files for packages.
5755
tools_directories: List of directories containing development tools to include.
5856
verbose: Enable verbose output.
59-
install_options: Additional pip install options.
6057
flavor: WinPython flavor (e.g., "Barebone").
6158
"""
6259
self.build_number = build_number
@@ -67,7 +64,6 @@ def __init__(self, build_number: int, release_level: str, target_directory: Path
6764
self.verbose = verbose
6865
self.winpython_directory: Path | None = None
6966
self.distribution: wppm.Distribution | None = None
70-
self.install_options = install_options or []
7167
self.flavor = flavor
7268
self.python_zip_file: Path = self._get_python_zip_file()
7369
self.python_name = self.python_zip_file.stem
@@ -141,12 +137,10 @@ def _create_initial_batch_scripts(self):
141137
def build(self, winpy_dir: Path = None):
142138
"""Make or finalise WinPython distribution in the target directory"""
143139
print(f"Building WinPython with Python archive: {self.python_zip_file.name}")
144-
if winpy_dir is None:
145-
raise RuntimeError("WinPython base directory to create is undefined")
146140
self.winpython_directory = winpy_dir
147141

148142
self._print_action(f"Creating WinPython {self.winpython_directory} base directory")
149-
if self.winpython_directory.is_dir():
143+
if self.winpython_directory.is_dir() and len(self.winpython_directory.parts)>=4:
150144
shutil.rmtree(self.winpython_directory)
151145
os.makedirs(self.winpython_directory, exist_ok=True)
152146
# preventive re-Creation of settings directory
@@ -157,18 +151,10 @@ def build(self, winpy_dir: Path = None):
157151

158152
self._copy_essential_files()
159153
self._create_initial_batch_scripts()
160-
utils.python_execmodule("ensurepip", self.distribution.target)
161-
self.distribution.patch_standard_packages("pip")
162-
essential_packages = ["pip", "setuptools", "wheel", "wppm"]
163-
for package_name in essential_packages:
164-
actions = ["install", "--upgrade", "--pre", package_name] + self.install_options
165-
self._print_action(f"Piping: {' '.join(actions)}")
166-
self.distribution.do_pip_action(actions)
167-
self.distribution.patch_standard_packages(package_name)
168154

169155
def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
170-
verbose: bool = False, install_options=["--no-index"],
171-
flavor: str = "", find_links: str | list[Path] = None,
156+
verbose: bool = False,
157+
flavor: str = "",
172158
source_dirs: Path = None, toolsdirs: str | list[Path] = None,
173159
):
174160
"""
@@ -178,18 +164,13 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
178164
release_level: release level (e.g. 'beta1', '') [str]
179165
basedir_wpy: top directory of the build (c:\...\Wpy...)
180166
verbose: Enable verbose output (bool).
181-
install_options: pip options (r'--no-index --pre --trusted-host=None')
182167
flavor: WinPython flavor (str).
183-
find_links: package directories (r'D:\Winpython\packages.srcreq')
184-
source_dirs: the python.zip + rebuilt winpython wheel package directory
168+
source_dirs: the python.zip
185169
toolsdirs: Directory with development tools r'D:\WinPython\basedir34\t.Slim'
186170
"""
187171
assert basedir_wpy is not None, "The *winpython_dirname* directory must be specified"
188172

189173
tools_dirs_list = parse_list_argument(toolsdirs, ",")
190-
install_options_list = parse_list_argument(install_options, " ")
191-
find_links_dirs_list = parse_list_argument(find_links, ",")
192-
find_links_options = [f"--find-links={link}" for link in find_links_dirs_list + [source_dirs]]
193174
winpy_dir = Path(basedir_wpy)
194175

195176
utils.print_box(f"Making WinPython at {winpy_dir}")
@@ -198,7 +179,6 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
198179
build_number, release_level, winpy_dir.parent, wheels_directory=source_dirs,
199180
tools_directories=[Path(d) for d in tools_dirs_list],
200181
verbose=verbose,
201-
install_options=install_options_list + find_links_options,
202182
flavor=flavor
203183
)
204184
builder.build(winpy_dir=winpy_dir)
@@ -212,8 +192,6 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
212192
basedir_wpy=r"D:\WinPython\bd314\budot\WPy64-31401b3",
213193
verbose=True,
214194
flavor="dot",
215-
install_options=r"--no-index --pre --trusted-host=None",
216-
find_links=r"D:\Winpython\packages.srcreq",
217195
source_dirs=r"D:\WinPython\bd314\packages.win-amd64",
218196
toolsdirs=r"D:\WinPython\bd314\t.Slim",
219197
)

0 commit comments

Comments
 (0)