Skip to content

Commit

Permalink
TST: simplify pep518 test setup
Browse files Browse the repository at this point in the history
This also makes the test work on Cygwin where a ninja wheel is not
available and needs to be built from the source distribution.
  • Loading branch information
dnicolodi committed Nov 17, 2022
1 parent b8385f5 commit 2592309
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 45 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ dynamic = [

[project.optional-dependencies]
test = [
'build',
'pytest',
'pytest-cov',
'pytest-mock',
Expand Down
52 changes: 11 additions & 41 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,47 +126,17 @@ def fixture(tmp_dir_session):
@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,
)
meson_python = str(package_dir.parent.parent),
# Populate wheelhouse with wheel for the following packages and
# their dependencies. Wheels are downloaded from PyPI or built
# from the source distribution as needed. Sources or wheels in
# the pip cache are used when available.
packages = [
meson_python,
'build',
'wheel',
]
subprocess.check_call([sys.executable, '-m', 'pip', 'wheel', '--wheel-dir', str(wheelhouse), *packages])
return str(wheelhouse)


Expand Down
5 changes: 2 additions & 3 deletions tests/test_pep518.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
@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)
def test_pep518(pep518, package, build_arg, tmp_path):
dist = tmp_path / 'dist'

with cd_package(package) as package_dir, in_git_repo_context():
with cd_package(package), 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)
subprocess.check_call([sys.executable, '-m', 'build', f'--outdir={dist}', *build_args])

0 comments on commit 2592309

Please sign in to comment.