Skip to content

duplicate zip login in wppm #1665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@
assert CHANGELOGS_DIRECTORY.is_dir(), f"Changelogs directory not found: {CHANGELOGS_DIRECTORY}"
assert PORTABLE_DIRECTORY.is_dir(), f"Portable directory not found: {PORTABLE_DIRECTORY}"

def find_7zip_executable() -> str:
"""Locates the 7-Zip executable (7z.exe)."""
possible_program_files = [r"C:\Program Files", r"C:\Program Files (x86)", Path(sys.prefix).parent / "t"]
for base_dir in possible_program_files:
if (executable_path := Path(base_dir) / "7-Zip" / "7z.exe").is_file():
return str(executable_path)
raise RuntimeError("7ZIP is not installed on this computer.")

def copy_items(source_directories: list[Path], target_directory: Path, verbose: bool = False):
"""Copies items from source directories to the target directory."""
target_directory.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -138,7 +130,7 @@ def create_installer_7zip(self, installer_type: str = "exe", compression= "mx5")
sfx_option = "-sfx7z.sfx" if installer_type == "exe" else ""
zip_option = "-tzip" if installer_type == "zip" else ""
compress_level = "mx5" if compression == "" else compression
command = f'"{find_7zip_executable()}" {zip_option} -{compress_level} a "{fullfilename}" "{DISTDIR}" {sfx_option}'
command = f'"{utils.find_7zip_executable()}" {zip_option} -{compress_level} a "{fullfilename}" "{DISTDIR}" {sfx_option}'
print(f'Executing 7-Zip script: "{command}"')
try:
subprocess.run(command, shell=True, check=True, stderr=sys.stderr, stdout=sys.stderr)
Expand Down Expand Up @@ -224,7 +216,6 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
verbose: bool = False, rebuild: bool = True, create_installer: str = "True", install_options=["--no-index"],
flavor: str = "", find_links: str | list[Path] = None,
source_dirs: Path = None, toolsdirs: str | list[Path] = None,
python_target_release: str = None, # e.g. "37101" for 3.7.10
):
"""
Make a WinPython distribution for a given set of parameters:
Expand All @@ -240,7 +231,6 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
find_links: package directories (r'D:\Winpython\packages.srcreq')
source_dirs: the python.zip + rebuilt winpython wheel package directory
toolsdirs: Directory with development tools r'D:\WinPython\basedir34\t.Slim'
python_target_release: Target Python release (str).
"""
assert basedir_wpy is not None, "The *winpython_dirname* directory must be specified"

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

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

Expand Down
2 changes: 1 addition & 1 deletion wppm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
OTHER DEALINGS IN THE SOFTWARE.
"""

__version__ = '17.1.20250705'
__version__ = '17.1.20250705a1'
__license__ = __doc__
__project_url__ = 'http://winpython.github.io/'
30 changes: 29 additions & 1 deletion wppm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,35 @@ def zip_directory(folder_path, output_zip_path):
if file.is_file():
arcname = file.relative_to(folder_path)
zipf.write(file, arcname)


def find_7zip_executable() -> str:
"""Locates the 7-Zip executable (7z.exe)."""
possible_program_files = [r"C:\Program Files", r"C:\Program Files (x86)", Path(sys.prefix).parent / "t"]
for base_dir in possible_program_files:
if (executable_path := Path(base_dir) / "7-Zip" / "7z.exe").is_file():
return str(executable_path)
raise RuntimeError("7ZIP is not installed on this computer.")

def create_installer_7zip(origin, destination, filename_stem, installer_type: str = "exe", compression= "mx5"):
"""Creates a WinPython installer using 7-Zip: "exe", "7z", "zip")"""
fullfilename = destination / (filename_stem + "." + installer_type)
if installer_type not in ["exe", "7z", "zip"]:
return
sfx_option = "-sfx7z.sfx" if installer_type == "exe" else ""
zip_option = "-tzip" if installer_type == "zip" else ""
compress_level = "mx5" if compression == "" else compression
command = f'"{find_7zip_executable()}" {zip_option} -{compress_level} a "{fullfilename}" "{origin}" {sfx_option}'
print(f'Executing 7-Zip script: "{command}"')
try:
subprocess.run(command, shell=True, check=True, stderr=sys.stderr, stdout=sys.stderr)
except subprocess.CalledProcessError as e:
print(f"Error executing 7-Zip script: {e}", file=sys.stderr)

def command_installer_7zip(origin, destination, filename_stem, create_installer: str = "exe"):
for commmand in create_installer.lower().replace("7zip",".exe").split('.'):
installer_type, compression = (commmand + "-").split("-")[:2]
create_installer_7zip(Path(origin), Path(destination), filename_stem, installer_type, compression)

if __name__ == '__main__':
print_box("Test")
dname = sys.prefix
Expand Down