-
Notifications
You must be signed in to change notification settings - Fork 263
Error on creation of wheel with a name that already exists, and add Py_LIMITED_API to the docs' FAQ #569
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
Closed
Closed
Error on creation of wheel with a name that already exists, and add Py_LIMITED_API to the docs' FAQ #569
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
40b63f5
Test for the creation of an already existing output wheel, and print …
YannickJadoul c74989d
Add successful test building with Py_LIMITED_API
YannickJadoul 419270e
Add py_limited_api to setup.cfg in tests
YannickJadoul 0e4580a
How does PyPy react to limited API?
YannickJadoul 8b0db9d
Don't test PyPy in test_limited_api, and add a test using PIP_BUILD_O…
YannickJadoul 2920e75
Add check on duplicate wheel error
YannickJadoul 77d94cc
Capturing the output of a command helps, if you want to do something …
YannickJadoul cc0991a
Debug pytest
YannickJadoul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import subprocess | ||
import textwrap | ||
|
||
import pytest | ||
|
||
from . import test_projects, utils | ||
|
||
limited_api_project = test_projects.new_c_project( | ||
setup_cfg_add=textwrap.dedent(r''' | ||
[bdist_wheel] | ||
py_limited_api=cp36 | ||
''') | ||
) | ||
|
||
|
||
def test_setup_cfg(tmp_path): | ||
project_dir = tmp_path / 'project' | ||
limited_api_project.generate(project_dir) | ||
|
||
# build the wheels | ||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={ | ||
'CIBW_BUILD': 'cp27-* cp36-*', # PyPy does not have a Py_LIMITED_API equivalent | ||
YannickJadoul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) | ||
|
||
# check that the expected wheels are produced | ||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0', limited_api='cp36') | ||
if '-pp' not in w] | ||
assert set(actual_wheels) == set(expected_wheels) | ||
|
||
|
||
def test_build_option_env(tmp_path, capfd): | ||
project_dir = tmp_path / 'project' | ||
test_projects.new_c_project().generate(project_dir) | ||
|
||
# build the wheels | ||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={ | ||
'CIBW_ENVIRONMENT': 'PIP_BUILD_OPTION="--py-limited-api=cp36"', | ||
'CIBW_BUILD': 'cp27-* cp36-*', # PyPy does not have a Py_LIMITED_API equivalent | ||
}) | ||
|
||
# check that the expected wheels are produced | ||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0', limited_api='cp36') | ||
if '-pp' not in w] | ||
assert set(actual_wheels) == set(expected_wheels) | ||
|
||
|
||
def test_duplicate_wheel_error(tmp_path, capfd): | ||
project_dir = tmp_path / 'project' | ||
limited_api_project.generate(project_dir) | ||
|
||
with pytest.raises(subprocess.CalledProcessError): | ||
utils.cibuildwheel_run(project_dir, add_env={ | ||
'CIBW_BUILD': 'cp36-* cp37-*', | ||
}) | ||
|
||
captured = capfd.readouterr() | ||
print('out', captured.out) | ||
print('err', captured.err) | ||
assert "already exists in output directory" in captured.err | ||
assert "It looks like you are building wheels against Python's limited API" in captured.err |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we want
sys.exit
, or an exception? Or downgrade this to just a warning (though Windows will error, anyway?).And if
sys.exit
: just1
, or a new/specific error code?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.
How hard would it be to just skip the build here and go directly to tests when a
abi3
wheel is already built? It should likely also be an error if tests are empty, as you should not "build" with multiple versions but not test? That would provide the "full support" solution.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.
We've already done the build at this point. To do the 'full support' thing, we'd need to predict the produced wheel name without actually doing the build.
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.
The first time, you just build like normal. Then you could register that you produced a abi3 wheel, and future builds would skip building. For python-requires, you have to read the config, since you don't know what you are allowed to produce. For ABI3, you could just use the technique above and react to the built, rather than trying to compute what will happen first.
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.
True, that should be possible! The main question is how close this is to
cibuildwheel
's other behavior. Most of the time, you have to explicitly opt-in to things andcibuildwheel
won't say "ah, you probably meant ...".On a more practical note: how would you decide which Python version to build on? I don't fully understand
Py_LIMITED_API
, but it seems to also include a "minimum version"?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.
Via Requires-Python and/or build selectors.
cibuildwheel
builds the oldest Python selected, and works it's way forward. Say it builds 2.7, normal wheel. 3.5, normal wheel. Then 3.6 is a stable ABI build. From then on, it just tests the existing wheel: 3.7, 3.8, and 3.9 are just tests of the ABI wheel.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.
This would even work if someone had special logic in setup.py for the limited_abi only working after some version of minimum required Python, while any other non-reactive method would not. You don't need to worry about the other direction (yet?), since the limited ABI works on all future Pythons (at least until Python 4).
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.
Right, OK, that could work, indeed :-)
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.
I like this idea, yeah! Avoiding the metadata read would be great.