Skip to content

Commit a44f137

Browse files
committed
fix(dist): only detect falcon* as packages (#2385)
* fix(dist): only detect `falcon*` as packages * fix: fix test-dist action * fix(workflows): one more fix for test-dist... * chore: run the new gate only on master merge
1 parent d872d92 commit a44f137

File tree

5 files changed

+79
-8
lines changed

5 files changed

+79
-8
lines changed

.github/workflows/test-dist.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Test source distribution and pure-Python wheel.
2+
name: test-dist
3+
4+
on:
5+
push:
6+
branches:
7+
- "*"
8+
9+
jobs:
10+
test-dist:
11+
name: test-${{ matrix.build }}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
build:
16+
- sdist
17+
- wheel
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 2
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.12"
29+
30+
- name: Build dist
31+
env:
32+
FALCON_DISABLE_CYTHON: "Y"
33+
run: |
34+
pip install --upgrade pip
35+
pip install --upgrade build
36+
python -m build --${{ matrix.build }}
37+
38+
- name: Test sdist
39+
if: matrix.build == 'sdist'
40+
run: |
41+
tools/test_dist.py dist/*.tar.gz
42+
43+
- name: Test pure-Python wheel
44+
if: matrix.build == 'wheel'
45+
run: |
46+
tools/test_dist.py dist/*.whl

.github/workflows/tox-sdist.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
run_tox:
12-
name: tox (default envlist on ${{matrix.python-version}})
12+
name: tox (python${{ matrix.python-version }})
1313
runs-on: "ubuntu-latest"
1414
strategy:
1515
fail-fast: false
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Installing Falcon 4.0.0 unexpectly copies many unintended directories from the
2+
source tree to the venv's ``site-packages``. This issue has been rectified, and
3+
our CI has been extended with new tests (that verify what is actually installed
4+
from the distribution) to make sure this regression does not resurface.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ zip-safe = false
7878
version = {attr = "falcon.version.__version__"}
7979

8080
[tool.setuptools.packages.find]
81-
exclude = ["examples", "tests"]
81+
include = ["falcon*"]
8282

8383
[tool.mypy]
8484
exclude = [

tools/test_dist.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,43 @@
1515
REQUIREMENTS = FALCON_ROOT / 'requirements' / 'cibwtest'
1616
TESTS = FALCON_ROOT / 'tests'
1717

18+
EXPECTED_SCRIPTS = set({'falcon-bench', 'falcon-inspect-app', 'falcon-print-routes'})
19+
EXPECTED_PACKAGES = set({'falcon'})
20+
1821

1922
def test_package(package):
2023
with tempfile.TemporaryDirectory() as tmpdir:
2124
venv = pathlib.Path(tmpdir) / 'venv'
25+
venv_bin = venv / 'bin'
26+
venv_pip = venv_bin / 'pip'
2227
subprocess.check_call((sys.executable, '-m', 'venv', venv))
2328
logging.info(f'Created a temporary venv in {venv}.')
2429

25-
subprocess.check_call((venv / 'bin' / 'pip', 'install', '--upgrade', 'pip'))
26-
subprocess.check_call((venv / 'bin' / 'pip', 'install', '-r', REQUIREMENTS))
30+
subprocess.check_call((venv_pip, 'install', '--upgrade', 'pip'))
31+
subprocess.check_call((venv_pip, 'install', '-r', REQUIREMENTS))
2732
logging.info(f'Installed test requirements in {venv}.')
28-
subprocess.check_call(
29-
(venv / 'bin' / 'pip', 'install', package),
30-
)
33+
34+
(venv_site_pkg,) = venv.glob('lib/python*/site-packages')
35+
bin_before = {path.name for path in venv_bin.iterdir()}
36+
pkg_before = {path.name for path in venv_site_pkg.iterdir()}
37+
38+
subprocess.check_call((venv_pip, 'install', package))
3139
logging.info(f'Installed {package} into {venv}.')
3240

33-
subprocess.check_call((venv / 'bin' / 'pytest', TESTS), cwd=venv)
41+
bin_after = {path.name for path in venv_bin.iterdir()}
42+
assert bin_after - bin_before == EXPECTED_SCRIPTS, (
43+
f'Unexpected scripts installed in {venv_bin} from {package}: '
44+
f'{bin_after - bin_before - EXPECTED_SCRIPTS}'
45+
)
46+
pkg_after = {
47+
path.name for path in venv_site_pkg.iterdir() if path.suffix != '.dist-info'
48+
}
49+
assert pkg_after - pkg_before == EXPECTED_PACKAGES, (
50+
f'Unexpected packages installed in {venv_site_pkg} from {package}: '
51+
f'{pkg_after - pkg_before - EXPECTED_PACKAGES}'
52+
)
53+
54+
subprocess.check_call((venv_bin / 'pytest', TESTS), cwd=venv)
3455
logging.info(f'{package} passes tests.')
3556

3657

0 commit comments

Comments
 (0)