Skip to content

pkg_resources relies on an internal implementation detail of CPython #378

@ghost

Description

Originally reported by: ericsnowcurrently (Bitbucket: ericsnowcurrently, GitHub: ericsnowcurrently)


See https://bitbucket.org/pypa/setuptools/src/da9a12631950997e178e9bea1f2e6bb5859b214e/pkg_resources/__init__.py?at=default#cl-78.

Apparently pkg_resources is importing importlib._bootstrap, which is not meant to be directly imported. It is used later to get SourceFileLoader and FileFinder. I noticed this due to a failing test (test_venv) in the CPython suite when I moved both those classes to a different file (no longer in _bootstrap.py). See http://bugs.python.org/issue23911.

Starting in Python 3.3 the two classes are exposed in importlib.machinery. I'd recommend updating the code to look something like this:

if sys.version_info >= (3, 3) and sys.implementation.name == "cpython": from importlib.machinery import SourceFileLoader, FileFinder else: SourceFileLoader = FileFinder = None 

and update the rest of the file (3 spots) accordingly.


Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions