Skip to content

TST: adding isolated build test #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-sage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
# Extra packages to install as system packages
extra_sage_packages: "liblzma bzip2 libffi libpng python3 ninja_build"
# Sage distribution packages to build
targets: SAGE_CHECK=no SAGE_CHECK_PACKAGES="meson_python" meson_python
targets: SAGE_CHECK=no SAGE_CHECK_PACKAGES="meson_python" python_build meson_python
# Standard setting: Test the current beta release of Sage:
sage_repo: sagemath/sage
sage_ref: develop
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dynamic = [

[project.optional-dependencies]
test = [
'build',
'pytest',
'pytest-cov',
'pytest-mock',
Expand Down
55 changes: 55 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import re
import shutil
import subprocess
import sys
import tempfile

from venv import EnvBuilder
Expand Down Expand Up @@ -120,3 +121,57 @@ def fixture(tmp_dir_session):
globals()[f'package_{normalized}'] = generate_package_fixture(package)
globals()[f'sdist_{normalized}'] = generate_sdist_fixture(package)
globals()[f'wheel_{normalized}'] = generate_wheel_fixture(package)


@pytest.fixture(scope='session')
def pep518_wheelhouse(tmpdir_factory):
wheelhouse = tmpdir_factory.mktemp('wheelhouse')
dist = tmpdir_factory.mktemp('dist')
subprocess.run(
[sys.executable, '-m', 'build', '--wheel', '--outdir', str(dist)],
cwd=str(package_dir.parent.parent),
check=True,
)
(wheel_path,) = dist.visit('*.whl')
subprocess.run(
[
sys.executable,
'-m',
'pip',
'download',
'-q',
'-d',
str(wheelhouse),
str(wheel_path),
],
check=True,
)
subprocess.run(
[
sys.executable,
'-m',
'pip',
'download',
'-q',
'-d',
str(wheelhouse),
'build',
'colorama',
'meson',
'ninja',
'patchelf',
'pyproject-metadata',
'tomli',
'typing-extensions',
'wheel',
],
check=True,
)
return str(wheelhouse)


@pytest.fixture
def pep518(pep518_wheelhouse, monkeypatch):
monkeypatch.setenv('PIP_FIND_LINKS', pep518_wheelhouse)
monkeypatch.setenv('PIP_NO_INDEX', 'true')
return pep518_wheelhouse
24 changes: 24 additions & 0 deletions tests/test_pep518.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import subprocess
import sys

import pytest

from .conftest import cd_package, in_git_repo_context


@pytest.mark.parametrize(
('package'),
[
'purelib-and-platlib',
]
)
@pytest.mark.parametrize(
'build_arg', ['', '--wheel'], ids=['sdist_to_wheel', 'wheel_directly']
)
@pytest.mark.xfail(sys.platform.startswith('cygwin'), reason='ninja pip package not available on cygwin', strict=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this fails on Cygwin in this branch (no ninja package), and passes in #175 - it's great to see this test does exactly what is supposed to do! :)

def test_pep518(pep518, package, build_arg, tmp_path):
dist = tmp_path / 'dist'

with cd_package(package) as package_dir, in_git_repo_context():
build_args = [build_arg] if build_arg else []
subprocess.run([sys.executable, '-m', 'build', f'--outdir={dist}', *build_args], cwd=package_dir, check=True)