-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Start warning on non compliant pyproject.toml files and rejecting incorrect ones #5512
Start warning on non compliant pyproject.toml files and rejecting incorrect ones #5512
Conversation
src/pip/_internal/req/req_install.py
Outdated
build_system = pp_toml.get('build-system', {}) | ||
if "requires" not in build_system: | ||
raise InstallationError( | ||
"{} does not comply with PEP 518 as it since it's " |
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.
as it since it's
?
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'd use the same format for both messages:
raise InstallationError(
"{} does not comply with PEP 518 as pyproject.toml does"
"not contain a valid [build-system].requires entry: {}"
.format(self, reason) # with reason: 'missing' or 'not a list of strings'
)
```
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.
Also, the function could be simplified to return the list of build requirements or None
if PEP 518 support is not used, no need for the isolate
return value anymore (and the corresponding code in prep_for_dist
simplified too).
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.
Indeed. Let's simplify the error message logic and the function.
#!/usr/bin/env python | ||
from setuptools import setup | ||
|
||
import simplewheel # ensure dependency is installed |
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.
That's not necessary, no?
tests/functional/test_install.py
Outdated
result = script.pip( | ||
'install', | ||
'-f', common_wheels, | ||
'-f', data.find_links, |
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.
Those 2 -f
arguments are unnecessary, no?
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.
Indeed.
tests/functional/test_install.py
Outdated
result = script.pip( | ||
'install', | ||
'-f', common_wheels, | ||
'-f', data.find_links, |
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.
Same as above.
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'd factorize the 2 tests with @pytest.mark.parametrize
.
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.
Nice idea about factorizing the tests.
src/pip/_internal/req/req_install.py
Outdated
|
||
requires = build_system["requires"] | ||
is_list_of_str = isinstance(requires, list) and all( | ||
isinstance(req, str) for req in requires |
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.
- isinstance(req, str) for req in requires
+ isinstance(req, six.string_types) for req in requires
src/pip/_internal/req/req_install.py
Outdated
@@ -571,8 +571,30 @@ def get_pep_518_info(self): | |||
if os.path.isfile(self.pyproject_toml): |
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 about taking the opportunity to simplify the function by getting the non PEP 518 case out of the way first:
if not os.path.isfile(self.pyproject_toml):
return (['setuptools', 'wheel'], False)
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.
Yeps. Good idea.
Thanks for the review @benoit-pierre! Much appreciated. :) |
44841d3
to
7460551
Compare
I really think the PEP should be amended. As it is right now: someone innocently adds black / towncrier / $othertool information in newly created I think now that PEP518 has settled on toml + |
this should be a big red warning for a while, (this is on us as well for not properly researching the pep either) but in the end just rejecting the projects will "break" what was "working" i also disagree with @asottile wrt amending the pep - but pip will have to be graceful since it didnt reject before |
@RonnyPfannschmidt I stated in #5402 (comment) why I think it's better to reject "working"; until the PEP can be updated. |
@asottile The next step for amending the PEP would be to start a new thread on distutils-sig, making a case for why the amendment should be made. |
@pradyunsg this will break various versions of pytest at least as well as plenty of other packages then ^^ |
We're having a discussion about this in 3 places. Can we please move the discussion about dealing with non-compliant pyproject.toml files to #5416? |
this makes the file valid and prepares for pypa/pip#5416 and pypa/pip#5512
ed154a1
to
2b68c79
Compare
From my understanding PEP 518 only states that |
@blueyed I read it differently; I think we're in distutils-sig territory now on this -- amending PEP 518 to remove this ambiguity. |
@pradyunsg |
@pypa/pip-committers Are there any reservations/blockers to merging this?
|
@pradyunsg No reservations from me. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Related to #5416
PEP 518 states:
This PR makes pip warn when installing packages that they do not define
build-system.requires
in theirpyproject.toml
files and error out when it's not a list of strings.