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

Add Python 3.10 support to _distutils_hack #2361

Merged
merged 1 commit into from Sep 1, 2020
Merged

Add Python 3.10 support to _distutils_hack #2361

merged 1 commit into from Sep 1, 2020

Conversation

vstinner
Copy link
Contributor

Get the 'Loader' abstract class from importlib.abc rather than
importlib.util.abc (alias removed in Python 3.10).

Summary of changes

Closes

Pull Request Checklist

  • Changes have tests
  • News fragment added in changelog.d. See documentation for details

@vstinner
Copy link
Contributor Author

"import _distutils_hack" on Python 3.10 fails with:

Traceback (most recent call last):
  File "/home/vstinner/python/master/Doc/venv/bin/sphinx-build", line 5, in <module>
    from sphinx.cmd.build import main
  File "/home/vstinner/python/master/Doc/venv/lib/python3.10/site-packages/sphinx/cmd/build.py", line 25, in <module>
    from sphinx.application import Sphinx
  File "/home/vstinner/python/master/Doc/venv/lib/python3.10/site-packages/sphinx/application.py", line 31, in <module>
    from sphinx.config import Config
  File "/home/vstinner/python/master/Doc/venv/lib/python3.10/site-packages/sphinx/config.py", line 24, in <module>
    from sphinx.util import logging
  File "/home/vstinner/python/master/Doc/venv/lib/python3.10/site-packages/sphinx/util/__init__.py", line 39, in <module>
    from sphinx.util import smartypants  # noqa
  File "/home/vstinner/python/master/Doc/venv/lib/python3.10/site-packages/sphinx/util/smartypants.py", line 33, in <module>
    from sphinx.util.docutils import __version_info__ as docutils_version
  File "/home/vstinner/python/master/Doc/venv/lib/python3.10/site-packages/sphinx/util/docutils.py", line 15, in <module>
    from distutils.version import LooseVersion
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 982, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 925, in _find_spec
  File "/home/vstinner/python/master/Doc/venv/lib/python3.10/site-packages/_distutils_hack/__init__.py", line 74, in find_spec
    return method()
  File "/home/vstinner/python/master/Doc/venv/lib/python3.10/site-packages/_distutils_hack/__init__.py", line 79, in spec_for_distutils
    class DistutilsLoader(importlib.util.abc.Loader):
AttributeError: module 'importlib.util' has no attribute 'abc'

The "abc" submodule must be imported from importlib, not get from importlib.util.abc: https://docs.python.org/dev/library/importlib.html#module-importlib.abc

@pganssle
Copy link
Member

@vstinner This looks good to me, though it needs a news fragment.

@vstinner
Copy link
Contributor Author

vstinner commented Sep 1, 2020

@vstinner This looks good to me, though it needs a news fragment.

I added the changelog.d/2361.bugfix.rst file manually. Is it the expected filename and content?

Note: I failed to find a setuptools documentation explaining how to contribute to setuptools. I discovered that setuptools uses towncrier, but I failed to find a documentation explaining how to add a towncrier changelog entry :-( I'm used to blurb tool which opens a text editor and then creates the news entry.

@pganssle
Copy link
Member

pganssle commented Sep 1, 2020

Get the 'Loader' abstract class from importlib.abc rather than
importlib.util.abc (alias removed in Python 3.10).
@vstinner
Copy link
Contributor Author

vstinner commented Sep 1, 2020

https://setuptools.readthedocs.io/en/latest/developer-guide.html

Oh, thanks! It seems like "2361.bugfix.rst" is not an accepted filename, so I renamed it to "2361.change.rst". Is it better? I also squashed my commits.

@vstinner
Copy link
Contributor Author

vstinner commented Sep 1, 2020

I may be interesting to mention https://setuptools.readthedocs.io/ and/or https://setuptools.readthedocs.io/en/latest/developer-guide.html in the README file. I can write a second PR for that, once this PR is merged. (I'm stupid and forgot to name my local branch, I abused the "master" branch. I prefer to wait until this PR is merged.)

@pganssle
Copy link
Member

pganssle commented Sep 1, 2020

I may be interesting to mention https://setuptools.readthedocs.io/ and/or https://setuptools.readthedocs.io/en/latest/developer-guide.html in the README file. I can write a second PR for that, once this PR is merged. (I'm stupid and forgot to name my local branch, I abused the "master" branch. I prefer to wait until this PR is merged.)

Yeah, it would probably also be a good idea to rename the incredibly similar-seeming "Developer's Guide" and "Developer's Guide for Setuptools":

Screenshot of the setuptools documentation demonstrating the top link "Building and Distributing Packages with Setuptools", with its first subhead, "Developer's Guide"

Screenshot of the setuptools documentation demonstrating the header "Development on Setuptools" and its first subhead "Developer's Guide for Setuptools"

Probably that is best addressed as part of the #2093 revamp (though adding something to the README would be good too). It seems slightly easier in the latest iteration (though the confusing headings are still there, just more hidden).

@pganssle pganssle requested a review from jaraco September 1, 2020 15:12
Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

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

Thanks!

@jaraco
Copy link
Member

jaraco commented Sep 1, 2020

I'll probably rename the changelog from change to misc so it implies an 0.0.1 bump, but good enough. Thanks Victor.

@jaraco jaraco merged commit 48e250a into pypa:master Sep 1, 2020
jaraco added a commit that referenced this pull request Sep 1, 2020
@vstinner
Copy link
Contributor Author

vstinner commented Sep 1, 2020

Thanks Victor.

You're welcome. Good luck with fixing setuptools 50.0 regressions. I'm a strong supporter of burying distutils! So I will try to help to make it possible.

vstinner added a commit to python/cpython that referenced this pull request Sep 2, 2020
xzy3 pushed a commit to xzy3/cpython that referenced this pull request Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants