Skip to content

Commit db15e1a

Browse files
authored
Port verify_distribution.py into pythonbuild (#1058)
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. Functionality is still a bit klunky IMO. I'll clean up the CLI UX a bit in future commits.
1 parent dbf06e8 commit db15e1a

11 files changed

Lines changed: 103 additions & 221 deletions

File tree

.github/workflows/linux.yml

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

.github/workflows/macos.yml

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

.github/workflows/windows.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,5 @@ jobs:
185185
if: ${{ ! matrix.dry-run }}
186186
run: |
187187
$Dists = Resolve-Path -Path "dist/*.tar.zst" -Relative
188-
.\pythonbuild.exe validate-distribution --run $Dists
188+
.\pythonbuild.exe validate-distribution $Dists
189+
uv run test-distribution.py $Dists

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ anyhow = "1.0.100"
99
apple-sdk = "0.6.0"
1010
bytes = "1.11.0"
1111
clap = "4.5.52"
12-
duct = "1.1.1"
1312
flate2 = "1.1.5"
1413
futures = "0.3.30"
1514
goblin = "0.10.3"

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)