Skip to content
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

Fix install_requires following PEP-508 #3114

Merged
merged 6 commits into from Jul 10, 2018
Merged

Fix install_requires following PEP-508 #3114

merged 6 commits into from Jul 10, 2018

Conversation

item4
Copy link
Contributor

@item4 item4 commented Jun 30, 2018

What do these changes do?

pipenv can not support code-based deps list.
this PR change install requires list following PEP-508

Please see pypa/pipenv#2473 for details.

Are there changes in behavior for the user?

no, there is only change to installation

Related issue number

pypa/pipenv#2473

Checklist

Please help me to check below. I do not check it myself

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

pipenv can not support code-based deps list

Please see pypa/pipenv#2473
for details.
@codecov-io
Copy link

codecov-io commented Jun 30, 2018

Codecov Report

Merging #3114 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3114   +/-   ##
=======================================
  Coverage   98.06%   98.06%           
=======================================
  Files          43       43           
  Lines        7837     7837           
  Branches     1354     1354           
=======================================
  Hits         7685     7685           
  Misses         56       56           
  Partials       96       96

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5bbc255...3a17df4. Read the comment docs.

@uranusjr
Copy link

Another related issue: #2703. The approach used here is considered the best way currently available to specify environment-specific requirements. Both the Python-based (currently in use) and extra_requires (mentioned in #2703) are no longer recommended, as they may cause problems in dependency resolution in package managers, and could provide incorrect metadata reporting on PyPI.

setup.py Outdated
'multidict>=4.0,<5.0',
'async_timeout>=3.0,<4.0',
'yarl>=1.0,<2.0',
'idna-ssl>=1.0;python_version<"3.7"',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR pip (setuptools?) doesn't support this kind of notation in install_requires (at least in certain range of versions).
I'd say it's better to go for extras-based syntax:

extra_requires = {
    ':python_version<"3.7"': [
        'idna-ssl>=1.0',
    ],
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to test this? There have been quite a few improvements in this area in pip v10.x, and support for PEP 508 came up more than once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@webknjaz it does today. And at least bundled pip for 3.5 support that. For older I think we shouldn't care.

In anyway, rule of thumb is: before install anything in new virtualenv, upgrade pip and setuptools first.

@webknjaz webknjaz self-assigned this Jun 30, 2018
@webknjaz
Copy link
Member

@uranusjr while it might be not recommended we target a wider range of envs and extras-based notation is better in this case. I'll need to check feature-support first.

@uranusjr
Copy link

uranusjr commented Jul 1, 2018

@webknjaz Unfortunately extra_requires also has issues during detection. I generally do not recommend sticking to the old syntax, since the current recommendation has been stable for more than a year, and newer versions of Setuptools is available to everyone to upgrade.

If Setuptools compatibility is an issue, Pytest’s approach may be more appropriate:
https://github.com/pytest-dev/pytest/blob/master/setup.py#L26

I would also like to mention that I have not seen any real-life reports on Setuptools support on installs_require markers being an issue.

@Victor-Savu
Copy link

@uranusjr I only saw the warning at the bottom of this wheel documentation section but I don't know if it is still valid.

@uranusjr
Copy link

uranusjr commented Jul 1, 2018

@Victor-Savu The warning only applies for extra; environment markers do work in pip 9.


Update: There is a table in the middle of the PEP document listing available markers. All of them except extra work in relatively up-to-date Setuptools and pip.

https://www.python.org/dev/peps/pep-0508/

@kxepal
Copy link
Member

kxepal commented Jul 1, 2018

I'm +1 this patch. While I share @webknjaz concerns about old setuptools/pip, today that shouldn't be a problem and, in general, I think we shouldn't let them slow down us, because users may easily upgrade them at any moment for free.

-1 for extras - that's not right solution, because:

  • It's easy to forget about that extra (how would you know about it without reading the sources?)
  • You will break all the packages that depends on aiohttp - they don't have any extras in own install_requires list, so they wouldn't get that package
  • All downstreams would have to maintain own if-condition: if 3.5, then use aiohttp's extra, if not - don't. Not cool.

@item4
Copy link
Contributor Author

item4 commented Jul 5, 2018

I changed code. please review again.

Copy link
Member

@kxepal kxepal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This iteration requires some additional work, but, honestly, we don't have to:

  1. Copy code from third-party project and deal with licenses;
  2. Have such wide/universal setuptools support - modern ones are enough and their upgrade is not a big deal for users.
  3. Complicated setup.py means complicated support of it. I think we shouldn't add additional rare cases by our own unless there would be bug reports about.

setup.py Outdated
* https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies
"""
try:
version = pkg_resources.parse_version(setuptools.__version__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot the import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix it

setup.py Outdated
version = pkg_resources.parse_version(setuptools.__version__)
if version >= pkg_resources.parse_version("36.2.2"):
return 2
if version >= pkg_resources.parse_version("0.7.2"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we care about such old versions? I think we shouldn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

setup.py Outdated
install_requires.append('idna-ssl>=1.0')
def get_environment_marker_support_level():
"""
Copied from https://github.com/pytest-dev/pytest/blob/master/setup.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you copy code from third party project, you need to add this reference to NOTICE file as ASF license stands for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will drop this copied code

kxepal
kxepal previously requested changes Jul 8, 2018
setup.py Outdated

if sys.version_info < (3, 7):
install_requires.append('idna-ssl>=1.0')
if setuptools_version >= (36, 2, 2):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

environment markers are supported since 20.5 version, but really get worked since 21.0. No need to require such high setuptools version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, version 21.0 released two years ago. Once again, do we need any checks against setuptools version at all? Unlikely any sane user will install latest aiohttp having legacy package management toolset.

setup.py Outdated
'async_timeout>=3.0,<4.0',
'yarl>=1.0,<2.0',
]
extras_require = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extras seems to be unused.

@item4
Copy link
Contributor Author

item4 commented Jul 8, 2018

@kxepal I think checking setupools version is useless and I want to reset --hard to first commit. but someone commented setuptools versioni issue. I want to hear opinion of member of aiohttp

@kxepal
Copy link
Member

kxepal commented Jul 8, 2018

@webknjaz
Are you ok to not check setuptools version?

@asvetlov
Copy link
Member

asvetlov commented Jul 9, 2018

Dropping setuptools version check is ok for me: env markers support is pretty old.

@webknjaz
Copy link
Member

Alright, I'm okay with that. It's just me having a habit to target maximum compatibility :)

Since we chose to not care about compatibility with ancient setuptools.
@webknjaz webknjaz merged commit ce50b03 into aio-libs:master Jul 10, 2018
@item4 item4 deleted the pep508 branch July 10, 2018 05:32
@lock
Copy link

lock bot commented Oct 28, 2019

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.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants