10000 Merge pull request #1665 from stonebig/master · winpython/winpython@0e412aa · GitHub
[go: up one dir, main page]

Skip to content

Commit 0e412aa

Browse files
authored
Merge pull request #1665 from stonebig/master
duplicate zip login in wppm
2 parents c6262c8 + 399c64e commit 0e412aa

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

make.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@
2323
assert CHANGELOGS_DIRECTORY.is_dir(), f"Changelogs directory not found: {CHANGELOGS_DIRECTORY}"
2424
assert PORTABLE_DIRECTORY.is_dir(), f"Portable directory not found: {PORTABLE_DIRECTORY}"
2525

26-
def find_7zip_executable() -> str:
27-
"""Locates the 7-Zip executable (7z.exe)."""
28-
possible_program_files = [r"C:\Program Files", r"C:\Program Files (x86)", Path(sys.prefix).parent / "t"]
29-
for base_dir in possible_program_files:
30-
if (executable_path := Path(base_dir) / "7-Zip" / "7z.exe").is_file():
31-
return str(executable_path)
32-
raise RuntimeError("7ZIP is not installed on this computer.")
33-
3426
def copy_items(source_directories: list[Path], target_directory: Path, verbose: bool = False):
3527
"""Copies items from source directories to the target directory."""
3628
target_directory.mkdir(parents=True, exist_ok=True)
@@ -138,7 +130,7 @@ def create_installer_7zip(self, installer_type: str = "exe", compression= "mx5")
138130
sfx_option = "-sfx7z.sfx" if installer_type == "exe" else ""
139131
zip_option = "-tzip" if installer_type == "zip" else ""
140132
compress_level = "mx5" if compression == "" else compression
141-
command = f'"{find_7zip_executable()}" {zip_option} -{compress_level} a "{fullfilename}" "{DISTDIR}" {sfx_option}'
133+
command = f'"{utils.find_7zip_executable()}" {zip_option} -{compress_level} a "{fullfilename}" "{DISTDIR}" {sfx_option}'
142134
print(f'Executing 7-Zip script: "{command}"')
143135
try:
144136
subprocess.run(command, shell=True, check=True, stderr=sys.stderr, stdout=sys.stderr)
@@ -224,7 +216,6 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
224216
verbose: bool = False, rebuild: bool = True, create_installer: str = "True", install_options=["--no-index"],
225217
flavor: str = "", find_links: str | list[Path] = None,
226218
source_dirs: Path = None, toolsdirs: str | list[Path] = None,
227-
python_target_release: str = None, # e.g. "37101" for 3.7.10
228219
):
229220
"""
230221
Make a WinPython distribution for a given set of parameters:
@@ -240,7 +231,6 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
240231
find_links: package directories (r'D:\Winpython\packages.srcreq')
241232
source_dirs: the python.zip + rebuilt winpython wheel package directory
242233
toolsdirs: Directory with development tools r'D:\WinPython\basedir34\t.Slim'
243-
python_target_release: Target Python release (str).
244234
"""
245235
assert basedir_wpy is not None, "The *winpython_dirname* directory must be specified"
246236

@@ -261,10 +251,6 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
261251
install_options=install_options_list + find_links_options,
262252
flavor=flavor
263253
)
264-
# define the directory where to create the distro
265-
python_minor_version_str = "".join(builder.python_name.replace(".amd64", "").split(".")[-2:-1])
266-
while not python_minor_version_str.isdigit() and len(python_minor_version_str) > 0:
267-
python_minor_version_str = python_minor_version_str[:-1]
268254

269255
builder.build(rebuild=rebuild, winpy_dir=winpy_dir)
270256

wppm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

31-
__version__ = '17.1.20250705'
31+
__version__ = '17.1.20250705a1'
3232
__license__ = __doc__
3333
__project_url__ = 'http://winpython.github.io/'

wppm/utils.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,35 @@ def zip_directory(folder_path, output_zip_path):
312312
if file.is_file():
313313
arcname = file.relative_to(folder_path)
314314
zipf.write(file, arcname)
315-
315+
316+
def find_7zip_executable() -> str:
317+
"""Locates the 7-Zip executable (7z.exe)."""
318+
possible_program_files = [r"C:\Program Files", r"C:\Program Files (x86)", Path(sys.prefix).parent / "t"]
319+
for base_dir in possible_program_files:
320+
if (executable_path := Path(base_dir) / "7-Zip" / "7z.exe").is_file():
321+
return str(executable_path)
322+
raise RuntimeError("7ZIP is not installed on this computer.")
323+
324+
def create_installer_7zip(origin, destination, filename_stem, installer_type: str = "exe", compression= "mx5"):
325+
"""Creates a WinPython installer using 7-Zip: "exe", "7z", "zip")"""
326+
fullfilename = destination / (filename_stem + "." + installer_type)
327+
if installer_type not in ["exe", "7z", "zip"]:
328+
return
329+
sfx_option = "-sfx7z.sfx" if installer_type == "exe" else ""
330+
zip_option = "-tzip" if installer_type == "zip" else ""
331+
compress_level = "mx5" if compression == "" else compression
332+
command = f'"{find_7zip_executable()}" {zip_option} -{compress_level} a "{fullfilename}" "{origin}" {sfx_option}'
333+
print(f'Executing 7-Zip script: "{command}"')
334+
try:
335+
subprocess.run(command, shell=True, check=True, stderr=sys.stderr, stdout=sys.stderr)
336+
except subprocess.CalledProcessError as e:
337+
print(f"Error executing 7-Zip script: {e}", file=sys.stderr)
338+
339+
def command_installer_7zip(origin, destination, filename_stem, create_installer: str = "exe"):
340+
for commmand in create_installer.lower().replace("7zip",".exe").split('.'):
341+
installer_type, compression = (commmand + "-").split("-")[:2]
342+
create_installer_7zip(Path(origin), Path(destination), filename_stem, installer_type, compression)
343+
316344
if __name__ == '__main__':
317345
print_box("Test")
318346
dname = sys.prefix

0 commit comments

Comments
 (0)
0