Let the CI Python distribution locate its packaging interpreter
This commit is contained in:
1 parent
3ea497d38a
commit
ebf33b62dc
2 files changed
+30
-13
No files matched your search
@@ -28,13 +28,6 @@ try {
|
||||
if ($LASTEXITCODE -ne 0) { throw "Windows build failed ($LASTEXITCODE)." }
|
||||
$binary = Join-Path $env:CARGO_TARGET_DIR 'x86_64-pc-windows-msvc\release\rusty-path-of-building.exe'
|
||||
|
||||
$venv = Join-Path $work.FullName 'py'
|
||||
python -m venv $venv
|
||||
if ($LASTEXITCODE -ne 0) { throw "Could not create the packaging environment ($LASTEXITCODE)." }
|
||||
$packagingPython = Join-Path $venv 'Scripts\python.exe'
|
||||
& $packagingPython -m pip install --disable-pip-version-check --no-input --require-hashes -r packaging/windows/requirements.txt
|
||||
if ($LASTEXITCODE -ne 0) { throw "Windows packaging dependency installation failed ($LASTEXITCODE)." }
|
||||
|
||||
# A third-party DLL can itself use the VC runtime. Use the selected toolset's
|
||||
# app-local redistributables when needed, even on a host with a global redist.
|
||||
if ($env:VCToolsRedistDir) {
|
||||
@@ -43,12 +36,8 @@ try {
|
||||
$dllDirs += @(Get-ChildItem -LiteralPath $x64 -Directory -Filter 'Microsoft.VC*.CRT' | ForEach-Object { $_.FullName })
|
||||
}
|
||||
}
|
||||
$packageArgs = @('packaging/package.py', 'windows', $binary, '--output', $destination, '--require-static-crt')
|
||||
foreach ($dir in $dllDirs) { $packageArgs += @('--dll-dir', $dir) }
|
||||
& $packagingPython @packageArgs
|
||||
if ($LASTEXITCODE -ne 0) { throw "Windows packaging failed ($LASTEXITCODE)." }
|
||||
& $packagingPython packaging/check_windows_release.py $destination
|
||||
if ($LASTEXITCODE -ne 0) { throw "Packaged Windows executable failed verification ($LASTEXITCODE)." }
|
||||
python packaging/windows/package_release.py $work.FullName $binary $destination @dllDirs
|
||||
if ($LASTEXITCODE -ne 0) { throw "Windows package creation or verification failed ($LASTEXITCODE)." }
|
||||
} finally {
|
||||
Pop-Location
|
||||
Remove-Item -LiteralPath $work.FullName -Recurse -Force -ErrorAction Continue
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
"""Build and smoke-test the release packages with an isolated Python interpreter."""
|
||||
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import venv
|
||||
|
||||
|
||||
def main(work, binary, destination, dll_dirs):
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
directory = str(Path(work).resolve() / "py")
|
||||
builder = venv.EnvBuilder(with_pip=True)
|
||||
builder.create(directory)
|
||||
# CPython distributions use different executable names and venv layouts on Windows.
|
||||
python = builder.ensure_directories(directory).env_exec_cmd
|
||||
print(f"Packaging with {python} ({sys.platform})", flush=True)
|
||||
subprocess.run([python, "-m", "pip", "install", "--disable-pip-version-check", "--no-input",
|
||||
"--require-hashes", "-r", root / "packaging/windows/requirements.txt"], check=True)
|
||||
args = [python, root / "packaging/package.py", "windows", binary,
|
||||
"--output", destination, "--require-static-crt"]
|
||||
for directory in dll_dirs:
|
||||
args.extend(["--dll-dir", directory])
|
||||
subprocess.run(args, check=True)
|
||||
subprocess.run([python, root / "packaging/check_windows_release.py", destination], check=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(*sys.argv[1:4], sys.argv[4:])
|
||||
Reference in new issue
Block a user