-
Notifications
You must be signed in to change notification settings - Fork 75
TST: simplify pep518 test setup #212
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,11 +48,11 @@ def in_git_repo_context(path=os.path.curdir): | |
path = os.path.abspath(path) | ||
shutil.rmtree(os.path.join(path, '.git'), ignore_errors=True) | ||
try: | ||
subprocess.check_call(['git', 'init', '-b', 'main', path]) | ||
subprocess.check_call(['git', 'config', 'user.email', '[email protected]'], cwd=path) | ||
subprocess.check_call(['git', 'config', 'user.name', 'A U Thor'], cwd=path) | ||
subprocess.check_call(['git', 'add', '*'], cwd=path) | ||
subprocess.check_call(['git', 'commit', '-q', '-m', 'Test'], cwd=path) | ||
subprocess.run(['git', 'init', '-b', 'main', path], check=True) | ||
subprocess.run(['git', 'config', 'user.email', '[email protected]'], cwd=path, check=True) | ||
subprocess.run(['git', 'config', 'user.name', 'A U Thor'], cwd=path, check=True) | ||
subprocess.run(['git', 'add', '*'], cwd=path, check=True) | ||
subprocess.run(['git', 'commit', '-q', '-m', 'Test'], cwd=path, check=True) | ||
yield | ||
finally: | ||
# PermissionError raised on Windows. | ||
|
@@ -123,50 +123,28 @@ def fixture(tmp_dir_session): | |
globals()[f'wheel_{normalized}'] = generate_wheel_fixture(package) | ||
|
||
|
||
@pytest.fixture(autouse=True, scope='session') | ||
def disable_pip_version_check(): | ||
# Cannot use the 'monkeypatch' fixture because of scope mismatch. | ||
mpatch = pytest.MonkeyPatch() | ||
yield mpatch.setenv('PIP_DISABLE_PIP_VERSION_CHECK', '1') | ||
mpatch.undo() | ||
|
||
|
||
@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.run([sys.executable, '-m', 'pip', 'wheel', '--wheel-dir', str(wheelhouse), *packages], check=True) | ||
return str(wheelhouse) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this removed? The point of the test is to test that this breaks - that is, ninja's not available from PyPI on cygwin. So if this passes on Cygwin before #175 goes in, the test doesn't work. That's why it was a strict xfail. I'm not completely sure what changed to make this pass, as this looks similar. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, now I know why it's passing. That's okay, I think - then we can delete There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that if we remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I confirm that once |
||
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.run([sys.executable, '-m', 'build', '--outdir', str(dist), *build_args], check=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, it's building ninja from source on Cygwin here, that's why it's passing below. In my version, it was also building ninja from source in order to build meson, but it wasn't putting it into the wheelhouse.