prepare addition of MSVC Redist DLLs

This commit is contained in:
Florian Förster 2025-06-25 16:52:45 +02:00
parent 1addbeffda
commit e9b259d4b9
15 changed files with 44 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[project]
name = "pycage"
version = "0.2.5"
version = "0.2.6dev1"
description = "tool to handle standalone Python installations from the CLI"
authors = [
{name = "Florian Förster", email = "f.foerster@d-opt.com"},
@ -78,7 +78,7 @@ directory = "reports/coverage"
[tool.bumpversion]
current_version = "0.2.5"
current_version = "0.2.6dev1"
parse = """(?x)
(?P<major>0|[1-9]\\d*)\\.
(?P<minor>0|[1-9]\\d*)\\.

10
src/pycage/constants.py Normal file
View File

@ -0,0 +1,10 @@
from pathlib import Path
from typing import Final
LIB_ROOT_FOLDER: Final[Path] = Path(__file__)
if not LIB_ROOT_FOLDER.exists():
raise FileNotFoundError(f"Lib root folder not found under: >{LIB_ROOT_FOLDER}<")
MSVC_FOLDER: Final[Path] = LIB_ROOT_FOLDER / "msvc-redist"
if not MSVC_FOLDER.exists():
raise FileNotFoundError(f"Folder for MSVC Redist files not found under: >{MSVC_FOLDER}<")

View File

@ -1,12 +1,14 @@
from __future__ import annotations
import shutil
import subprocess
import sys
from pathlib import Path
import click
from pycage.helpers import get_interpreter
from pycage.constants import MSVC_FOLDER
from pycage.helpers import get_interpreter, path_verify_directory, path_verify_existence
@click.group(help="manage virtual environment with downloaded standalone images")
@ -159,8 +161,37 @@ def remove(
subprocess.run(cmd)
@click.command(
help="add MSVC Redistributable runtime dependencies to the root path of the environment"
)
def add_msvc_redist() -> None:
try:
pth_intp = get_interpreter()
except RuntimeError:
click.echo("Base interpreter path could not be found", err=True)
return
target_path = pth_intp.parent
try:
path_verify_directory(target_path)
except ValueError:
click.echo(f"Target path >{target_path}< does not seem to be a directory", err=True)
return
try:
path_verify_existence(target_path)
except FileNotFoundError:
click.echo(f"Target path >{target_path}< does not seem to exist", err=True)
return
dll_files = MSVC_FOLDER.glob("**/*.dll")
for dll_src in dll_files:
shutil.copy(dll_src, target_path)
venv.add_command(create)
venv.add_command(add)
venv.add_command(upgrade_pip)
venv.add_command(remove)
venv.add_command(upgrade_seeders)
venv.add_command(add_msvc_redist)