From ef30e8e0f6fa65a2a89b26bf0800dd168dce9899 Mon Sep 17 00:00:00 2001 From: Vytautas Liuolia Date: Tue, 22 Oct 2024 19:17:41 +0200 Subject: [PATCH 1/4] fix(dist): only detect `falcon*` as packages --- .github/workflows/test-dist.yaml | 48 +++++++++++++++++++++++++++++ .github/workflows/tox-sdist.yaml | 2 +- docs/_newsfragments/2384.bugfix.rst | 4 +++ pyproject.toml | 2 +- tools/test_dist.py | 33 ++++++++++++++++---- 5 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/test-dist.yaml create mode 100644 docs/_newsfragments/2384.bugfix.rst diff --git a/.github/workflows/test-dist.yaml b/.github/workflows/test-dist.yaml new file mode 100644 index 000000000..4513f3f43 --- /dev/null +++ b/.github/workflows/test-dist.yaml @@ -0,0 +1,48 @@ +# Test source distribution and pure-Python wheel. +name: test-dist + +on: + push: + branches: + - "*" + pull_request: + branches: + - master + +jobs: + test-dist: + name: test-${{build}} + runs-on: ubuntu-latest + matrix: + build: + - sdist + - wheel + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Build dist + env: + FALCON_DISABLE_CYTHON: "Y" + run: | + pip install --upgrade pip + pip install --upgrade build + python -m build --${{ matrix.build }} + + - name: Test sdist + if: matrix.build == 'sdist' + run: | + tools/test_dist.py dist/*.tar.gz + + - name: Test pure-Python wheel + if: matrix.build == 'wheel' + run: | + tools/test_dist.py dist/*.whl diff --git a/.github/workflows/tox-sdist.yaml b/.github/workflows/tox-sdist.yaml index d890223f1..bcccd9e5e 100644 --- a/.github/workflows/tox-sdist.yaml +++ b/.github/workflows/tox-sdist.yaml @@ -9,7 +9,7 @@ on: jobs: run_tox: - name: tox (default envlist on ${{matrix.python-version}}) + name: tox (python${{ matrix.python-version }}) runs-on: "ubuntu-latest" strategy: fail-fast: false diff --git a/docs/_newsfragments/2384.bugfix.rst b/docs/_newsfragments/2384.bugfix.rst new file mode 100644 index 000000000..897fefd86 --- /dev/null +++ b/docs/_newsfragments/2384.bugfix.rst @@ -0,0 +1,4 @@ +Installing Falcon 4.0.0 unexpectly copies many unintended directories from the +source tree to the venv's ``site-packages``. The issue has been rectified, and +our CI has been extended with new tests (that verify what is actually installed +from the distribution) to make sure this regression does not resurface. diff --git a/pyproject.toml b/pyproject.toml index a848647dc..ac71c10c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,7 @@ zip-safe = false version = {attr = "falcon.version.__version__"} [tool.setuptools.packages.find] -exclude = ["examples", "tests"] +include = ["falcon*"] [tool.mypy] exclude = [ diff --git a/tools/test_dist.py b/tools/test_dist.py index a0dc967b5..6b35f6e9b 100755 --- a/tools/test_dist.py +++ b/tools/test_dist.py @@ -15,22 +15,43 @@ REQUIREMENTS = FALCON_ROOT / 'requirements' / 'cibwtest' TESTS = FALCON_ROOT / 'tests' +EXPECTED_SCRIPTS = set({'falcon-bench', 'falcon-inspect-app', 'falcon-print-routes'}) +EXPECTED_PACKAGES = set({'falcon'}) + def test_package(package): with tempfile.TemporaryDirectory() as tmpdir: venv = pathlib.Path(tmpdir) / 'venv' + venv_bin = venv / 'bin' + venv_pip = venv_bin / 'pip' subprocess.check_call((sys.executable, '-m', 'venv', venv)) logging.info(f'Created a temporary venv in {venv}.') - subprocess.check_call((venv / 'bin' / 'pip', 'install', '--upgrade', 'pip')) - subprocess.check_call((venv / 'bin' / 'pip', 'install', '-r', REQUIREMENTS)) + subprocess.check_call((venv_pip, 'install', '--upgrade', 'pip')) + subprocess.check_call((venv_pip, 'install', '-r', REQUIREMENTS)) logging.info(f'Installed test requirements in {venv}.') - subprocess.check_call( - (venv / 'bin' / 'pip', 'install', package), - ) + + (venv_site_pkg,) = venv.glob('lib/python*/site-packages') + bin_before = {path.name for path in venv_bin.iterdir()} + pkg_before = {path.name for path in venv_site_pkg.iterdir()} + + subprocess.check_call((venv_pip, 'install', package)) logging.info(f'Installed {package} into {venv}.') - subprocess.check_call((venv / 'bin' / 'pytest', TESTS), cwd=venv) + bin_after = {path.name for path in venv_bin.iterdir()} + assert bin_after - bin_before == EXPECTED_SCRIPTS, ( + f'Unexpected scripts installed in {venv_bin} from {package}: ' + f'{bin_after - bin_before - EXPECTED_SCRIPTS}' + ) + pkg_after = { + path.name for path in venv_site_pkg.iterdir() if path.suffix != '.dist-info' + } + assert pkg_after - pkg_before == EXPECTED_PACKAGES, ( + f'Unexpected packages installed in {venv_site_pkg} from {package}: ' + f'{pkg_after - pkg_before - EXPECTED_PACKAGES}' + ) + + subprocess.check_call((venv_bin / 'pytest', TESTS), cwd=venv) logging.info(f'{package} passes tests.') From 7c34ab31380da71783160a1343c8a27de9c30966 Mon Sep 17 00:00:00 2001 From: Vytautas Liuolia Date: Tue, 22 Oct 2024 19:21:50 +0200 Subject: [PATCH 2/4] fix: fix test-dist action --- .github/workflows/test-dist.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-dist.yaml b/.github/workflows/test-dist.yaml index 4513f3f43..28fbc18e1 100644 --- a/.github/workflows/test-dist.yaml +++ b/.github/workflows/test-dist.yaml @@ -11,7 +11,7 @@ on: jobs: test-dist: - name: test-${{build}} + name: test-${{ matrix.build }} runs-on: ubuntu-latest matrix: build: From 2be05e2765034666edb0289976b090c47910122c Mon Sep 17 00:00:00 2001 From: Vytautas Liuolia Date: Tue, 22 Oct 2024 19:24:19 +0200 Subject: [PATCH 3/4] fix(workflows): one more fix for test-dist... --- .github/workflows/test-dist.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-dist.yaml b/.github/workflows/test-dist.yaml index 28fbc18e1..ad4bc1b92 100644 --- a/.github/workflows/test-dist.yaml +++ b/.github/workflows/test-dist.yaml @@ -13,10 +13,11 @@ jobs: test-dist: name: test-${{ matrix.build }} runs-on: ubuntu-latest - matrix: - build: - - sdist - - wheel + strategy: + matrix: + build: + - sdist + - wheel steps: - name: Checkout repository From 4a6092689eea2ec91e456aba42519cd6ebc3352a Mon Sep 17 00:00:00 2001 From: Vytautas Liuolia Date: Tue, 22 Oct 2024 19:29:54 +0200 Subject: [PATCH 4/4] chore: run the new gate only on master merge --- .github/workflows/test-dist.yaml | 3 --- docs/_newsfragments/2384.bugfix.rst | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test-dist.yaml b/.github/workflows/test-dist.yaml index ad4bc1b92..5f64e176a 100644 --- a/.github/workflows/test-dist.yaml +++ b/.github/workflows/test-dist.yaml @@ -5,9 +5,6 @@ on: push: branches: - "*" - pull_request: - branches: - - master jobs: test-dist: diff --git a/docs/_newsfragments/2384.bugfix.rst b/docs/_newsfragments/2384.bugfix.rst index 897fefd86..7f724e80c 100644 --- a/docs/_newsfragments/2384.bugfix.rst +++ b/docs/_newsfragments/2384.bugfix.rst @@ -1,4 +1,4 @@ Installing Falcon 4.0.0 unexpectly copies many unintended directories from the -source tree to the venv's ``site-packages``. The issue has been rectified, and +source tree to the venv's ``site-packages``. This issue has been rectified, and our CI has been extended with new tests (that verify what is actually installed from the distribution) to make sure this regression does not resurface.