Skip to content

Commit 5f47941

Browse files
henryiiiFFY00
authored andcommitted
TST: adding isolated build test
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 4bdb1d2 commit 5f47941

File tree

4 files changed

+81
-1
lines changed

4 files changed

+81
-1
lines changed

Diff for: .github/workflows/ci-sage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
# Extra packages to install as system packages
110110
extra_sage_packages: "liblzma bzip2 libffi libpng python3 ninja_build"
111111
# Sage distribution packages to build
112-
targets: SAGE_CHECK=no SAGE_CHECK_PACKAGES="meson_python" meson_python
112+
targets: SAGE_CHECK=no SAGE_CHECK_PACKAGES="meson_python" python_build meson_python
113113
# Standard setting: Test the current beta release of Sage:
114114
sage_repo: sagemath/sage
115115
sage_ref: develop

Diff for: pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dynamic = [
3939

4040
[project.optional-dependencies]
4141
test = [
42+
'build',
4243
'pytest',
4344
'pytest-cov',
4445
'pytest-mock',

Diff for: tests/conftest.py

+55
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import re
88
import shutil
99
import subprocess
10+
import sys
1011
import tempfile
1112

1213
from venv import EnvBuilder
@@ -120,3 +121,57 @@ def fixture(tmp_dir_session):
120121
globals()[f'package_{normalized}'] = generate_package_fixture(package)
121122
globals()[f'sdist_{normalized}'] = generate_sdist_fixture(package)
122123
globals()[f'wheel_{normalized}'] = generate_wheel_fixture(package)
124+
125+
126+
@pytest.fixture(scope='session')
127+
def pep518_wheelhouse(tmpdir_factory):
128+
wheelhouse = tmpdir_factory.mktemp('wheelhouse')
129+
dist = tmpdir_factory.mktemp('dist')
130+
subprocess.run(
131+
[sys.executable, '-m', 'build', '--wheel', '--outdir', str(dist)],
132+
cwd=str(package_dir.parent.parent),
133+
check=True,
134+
)
135+
(wheel_path,) = dist.visit('*.whl')
136+
subprocess.run(
137+
[
138+
sys.executable,
139+
'-m',
140+
'pip',
141+
'download',
142+
'-q',
143+
'-d',
144+
str(wheelhouse),
145+
str(wheel_path),
146+
],
147+
check=True,
148+
)
149+
subprocess.run(
150+
[
151+
sys.executable,
152+
'-m',
153+
'pip',
154+
'download',
155+
'-q',
156+
'-d',
157+
str(wheelhouse),
158+
'build',
159+
'colorama',
160+
'meson',
161+
'ninja',
162+
'patchelf',
163+
'pyproject-metadata',
164+
'tomli',
165+
'typing-extensions',
166+
'wheel',
167+
],
168+
check=True,
169+
)
170+
return str(wheelhouse)
171+
172+
173+
@pytest.fixture
174+
def pep518(pep518_wheelhouse, monkeypatch):
175+
monkeypatch.setenv('PIP_FIND_LINKS', pep518_wheelhouse)
176+
monkeypatch.setenv('PIP_NO_INDEX', 'true')
177+
return pep518_wheelhouse

Diff for: tests/test_pep518.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import subprocess
2+
import sys
3+
4+
import pytest
5+
6+
from .conftest import cd_package, in_git_repo_context
7+
8+
9+
@pytest.mark.parametrize(
10+
('package'),
11+
[
12+
'purelib-and-platlib',
13+
]
14+
)
15+
@pytest.mark.parametrize(
16+
'build_arg', ['', '--wheel'], ids=['sdist_to_wheel', 'wheel_directly']
17+
)
18+
@pytest.mark.xfail(sys.platform.startswith('cygwin'), reason='ninja pip package not available on cygwin', strict=True)
19+
def test_pep518(pep518, package, build_arg, tmp_path):
20+
dist = tmp_path / 'dist'
21+
22+
with cd_package(package) as package_dir, in_git_repo_context():
23+
build_args = [build_arg] if build_arg else []
24+
subprocess.run([sys.executable, '-m', 'build', f'--outdir={dist}', *build_args], cwd=package_dir, check=True)

0 commit comments

Comments
 (0)