Skip to content

Commit

Permalink
Merge pull request #2990 from asottile/distutils-hack-set-origin
Browse files Browse the repository at this point in the history
set origin= for distutils.__spec__
  • Loading branch information
jaraco authored Jan 8, 2022
2 parents 82b9723 + bd8d4db commit d514fa1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion _distutils_hack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def create_module(self, spec):
def exec_module(self, module):
pass

return importlib.util.spec_from_loader('distutils', DistutilsLoader())
return importlib.util.spec_from_loader(
'distutils', DistutilsLoader(), origin=mod.__file__
)

def spec_for_pip(self):
"""
Expand Down
1 change: 1 addition & 0 deletions changelog.d/2990.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Set the ``.origin`` attribute of the ``distutils`` module to the module's ``__file__``.
7 changes: 7 additions & 0 deletions setuptools/tests/test_distutils_adoption.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,10 @@ def test_pip_import(venv):
"""
cmd = ['python', '-c', 'import pip']
popen_text(venv.run)(cmd)


def test_distutils_has_origin():
"""
Distutils module spec should have an origin. #2990.
"""
assert __import__('distutils').__spec__.origin

0 comments on commit d514fa1

Please sign in to comment.