Skip to content

Commit

Permalink
Properly extract msvcrt100.dll when installing python on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
roblabla committed Dec 12, 2023
1 parent 8f865e6 commit b867a84
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions scripts/create_devenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ def cmd_quote(s):
return '"' + s.replace("\\", "\\\\").replace('"', '"') + '"'


def run_msiextract_win32(msi_file_path: Path, output_dir: Path) -> int:
def run_msiextract_win32(
msi_file_path: Path, output_dir: Path, transforms: Optional[list] = None
) -> int:
transforms_str = ""
if transforms and len(transforms) != 0:
transforms_str = "TRANSFORMS=" + cmd_quote(";".join(transforms))
return subprocess.check_call(
"msiexec /a "
+ cmd_quote(str(msi_file_path))
+ " /qb TARGETDIR="
+ cmd_quote(str(output_dir)),
+ cmd_quote(str(output_dir))
+ transforms_str,
cwd=str(output_dir),
# We need to use shell=True as msiexec does some very funky parsing of the command line arguments.
shell=True,
Expand All @@ -52,11 +58,12 @@ def translate_msiextract_name(raw_name: str) -> "Optional[str]":
return name


def msiextract(msi_file_path: Path, output_dir: Path) -> int:
def msiextract(
msi_file_path: Path, output_dir: Path, transforms: Optional[list] = None
) -> int:
os.makedirs(str(output_dir), exist_ok=True)
if sys.platform == "win32":
run_msiextract_win32(msi_file_path, output_dir)

run_msiextract_win32(msi_file_path, output_dir, transforms=transforms)
return

run_msiextract(msi_file_path, output_dir)
Expand Down Expand Up @@ -340,7 +347,11 @@ def install_python(
print("Installing Python")
shutil.rmtree(str(tmp_dir), ignore_errors=True)
os.makedirs(str(tmp_dir), exist_ok=True)
msiextract(python_installer_path, tmp_dir)
msiextract(
python_installer_path,
tmp_dir,
windows_transforms=[SCRIPTS_DIR / "python344_privatecrt.mst"],
)
python_dst_dir = output_path / "python"
shutil.rmtree(str(python_dst_dir), ignore_errors=True)
shutil.move(str(tmp_dir), str(python_dst_dir))
Expand Down
Binary file added scripts/python344_privatecrt.mst
Binary file not shown.

0 comments on commit b867a84

Please sign in to comment.