Skip to content

Commit 1aff3c6

Browse files
committed
Port verify_distribution.py into pythonbuild
We move the custom `unittest` based tests from this file into a new `pythonbuild/disttests` package, deleting `src/verify_distribution.py` in the process. We teach the new `pythonbuild.testdist` code to run our custom unittests given an extracted Python distribution. They now run by default. Rust code for executing the Python in the distribution has been removed. CI tests have been updated to invoke `test-distribution.py` when we support running the interpreter. Behavior of `test-distribution.py` / `pythonbuild.disttests` has been changed so stdlib tests are no longer run by default. This is necessary to preserve backwards compatibility to keep CI passing.
1 parent 735714e commit 1aff3c6

11 files changed

Lines changed: 108 additions & 215 deletions

File tree

.github/workflows/linux.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,18 +317,19 @@ jobs:
317317
run: |
318318
chmod +x build/pythonbuild
319319
320+
build/pythonbuild validate-distribution dist/*.tar.zst
321+
320322
if [ "${MATRIX_RUN}" == "true" ]; then
321323
if [ "${MATRIX_LIBC}" == "musl" ]; then
322324
sudo apt install musl-dev
323-
325+
324326
# GitHub's setup-python action sets `LD_LIBRARY_PATH` which overrides `RPATH`
325327
# as used in the musl builds.
326328
unset LD_LIBRARY_PATH
327329
fi
328-
EXTRA_ARGS="--run"
330+
331+
./test-distribution.py dist/*.tar.zst
329332
fi
330-
331-
build/pythonbuild validate-distribution ${EXTRA_ARGS} dist/*.tar.zst
332333
env:
333334
MATRIX_RUN: ${{ matrix.run }}
334335
MATRIX_LIBC: ${{ matrix.libc }}

.github/workflows/macos.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ jobs:
177177
run: |
178178
chmod +x build/pythonbuild
179179
180+
build/pythonbuild validate-distribution --macos-sdks-path macosx-sdks dist/*.tar.zst
181+
180182
if [ "${MATRIX_RUN}" == "true" ]; then
181-
EXTRA_ARGS="--run"
183+
./test-distribution.py dist/*.tar.zst
182184
fi
183-
184-
build/pythonbuild validate-distribution --macos-sdks-path macosx-sdks ${EXTRA_ARGS} dist/*.tar.zst
185185
env:
186186
MATRIX_RUN: ${{ matrix.run }}

.github/workflows/windows.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: windows
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [ main ]
66
pull_request:
77

88
concurrency:
@@ -12,7 +12,7 @@ concurrency:
1212
env:
1313
FORCE_COLOR: 1
1414

15-
permissions: {}
15+
permissions: { }
1616

1717
jobs:
1818
crate-build:
@@ -184,4 +184,7 @@ jobs:
184184
if: ${{ ! matrix.dry-run }}
185185
run: |
186186
$Dists = Resolve-Path -Path "dist/*.tar.zst" -Relative
187-
.\pythonbuild.exe validate-distribution --run $Dists
187+
.\pythonbuild.exe validate-distribution $Dists
188+
uv run --python cpython-%MATRIX_PYTHON% test-distribution.py $Dists
189+
env:
190+
MATRIX_PYTHON: ${{ matrix.python }}

Cargo.lock

Lines changed: 1 addition & 136 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ aws-config = { version = "1", features = ["behavior-version-latest"] }
1111
aws-sdk-s3 = "1"
1212
bytes = "1.11.0"
1313
clap = "4.5.52"
14-
duct = "1.1.1"
1514
flate2 = "1.1.5"
1615
futures = "0.3.30"
1716
goblin = "0.10.3"
@@ -26,7 +25,7 @@ rayon = "1.11.0"
2625
reqwest = { version = "0.13", features = ["rustls", "stream"] }
2726
reqwest-middleware = "0.5"
2827
reqwest-retry = "0.9"
29-
rustls = { version = "0.23" , default-features = false, features = ["aws_lc_rs"] }
28+
rustls = { version = "0.23", default-features = false, features = ["aws_lc_rs"] }
3029
semver = "1.0.27"
3130
serde = { version = "1.0.228", features = ["derive"] }
3231
serde_json = "1.0.145"

docs/status.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ This repository contains ``test-distribution.py`` script that can be
4141
used to run the Python test harness from a distribution archive.
4242

4343
Here, we track the various known failures when running
44-
``test-distribution.py /path/to/distribution.tar.zst -u all``.
44+
``test-distribution.py --stdlib -- /path/to/distribution.tar.zst -u all``.
4545

4646
``test__locale``
4747
----------------
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import tempfile
1111
import unittest
1212
from pathlib import Path
13+
from typing import Optional
1314

1415
TERMINFO_DIRS = [
1516
"/etc/terminfo",
@@ -123,12 +124,12 @@ def test_hashlib(self):
123124
"_testcapi not available on statically-linked distributions",
124125
)
125126
def test_testcapi(self):
126-
import _testcapi
127+
import _testcapi # type: ignore
127128

128129
self.assertIsNotNone(_testcapi)
129130

130131
if sys.version_info[0:2] >= (3, 13):
131-
import _testlimitedcapi
132+
import _testlimitedcapi # type: ignore
132133

133134
self.assertIsNotNone(_testlimitedcapi)
134135

@@ -235,7 +236,7 @@ def test_gil_disabled(self):
235236
"zstd is only available in 3.14+",
236237
)
237238
def test_zstd_multithreaded(self):
238-
from compression import zstd
239+
from compression import zstd # type: ignore
239240

240241
max_threads = zstd.CompressionParameter.nb_workers.bounds()[1]
241242
assert max_threads > 0, (
@@ -294,7 +295,7 @@ def assertLibc(value):
294295
)
295296
@unittest.skipIf(os.name == "nt", "no symlinks or argv[0] on Windows")
296297
def test_getpath(self):
297-
def assertPythonWorks(path: Path, argv0: str = None):
298+
def assertPythonWorks(path: Path, argv0: Optional[str] = None):
298299
output = subprocess.check_output(
299300
[argv0 or path, "-c", "print(42)"], executable=path, text=True
300301
)

0 commit comments

Comments
 (0)