Skip to content

Commit b9d5d40

Browse files
committed
TST: simplify pep518 test setup
This also makes the test work on Cygwin where a ninja wheel is not available and needs to be built from the source distribution.
1 parent b8385f5 commit b9d5d40

File tree

2 files changed

+13
-44
lines changed

2 files changed

+13
-44
lines changed

tests/conftest.py

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -126,47 +126,17 @@ def fixture(tmp_dir_session):
126126
@pytest.fixture(scope='session')
127127
def pep518_wheelhouse(tmpdir_factory):
128128
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-
)
129+
meson_python = str(package_dir.parent.parent)
130+
# Populate wheelhouse with wheel for the following packages and
131+
# their dependencies. Wheels are downloaded from PyPI or built
132+
# from the source distribution as needed. Sources or wheels in
133+
# the pip cache are used when available.
134+
packages = [
135+
meson_python,
136+
'build',
137+
'wheel',
138+
]
139+
subprocess.check_call([sys.executable, '-m', 'pip', 'wheel', '--wheel-dir', str(wheelhouse), *packages])
170140
return str(wheelhouse)
171141

172142

tests/test_pep518.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
@pytest.mark.parametrize(
1616
'build_arg', ['', '--wheel'], ids=['sdist_to_wheel', 'wheel_directly']
1717
)
18-
@pytest.mark.xfail(sys.platform.startswith('cygwin'), reason='ninja pip package not available on cygwin', strict=True)
1918
def test_pep518(pep518, package, build_arg, tmp_path):
2019
dist = tmp_path / 'dist'
2120

22-
with cd_package(package) as package_dir, in_git_repo_context():
21+
with cd_package(package), in_git_repo_context():
2322
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)
23+
subprocess.check_call([sys.executable, '-m', 'build', '--outdir', str(dist), *build_args])

0 commit comments

Comments
 (0)