summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-01-08 14:38:08 -0500
committerGitHub <noreply@github.com>2022-01-08 14:38:08 -0500
commitd514fa1acc0efa9cfb5735134fc827be975bdde2 (patch)
tree0bd289feabd6ab8c0015a0b067c3c50bb56980aa
parent82b9723caf47415aebd2a2371edb81e2f5a996c4 (diff)
parentbd8d4dbd9638988f09b061f5d94a678c0fd80f25 (diff)
downloadpython-setuptools-git-d514fa1acc0efa9cfb5735134fc827be975bdde2.tar.gz
Merge pull request #2990 from asottile/distutils-hack-set-origin
set origin= for distutils.__spec__
-rw-r--r--_distutils_hack/__init__.py4
-rw-r--r--changelog.d/2990.change.rst1
-rw-r--r--setuptools/tests/test_distutils_adoption.py7
3 files changed, 11 insertions, 1 deletions
diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py
index 0307734d..ab462f95 100644
--- a/_distutils_hack/__init__.py
+++ b/_distutils_hack/__init__.py
@@ -125,7 +125,9 @@ class DistutilsMetaFinder:
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):
"""
diff --git a/changelog.d/2990.change.rst b/changelog.d/2990.change.rst
new file mode 100644
index 00000000..bb6e6032
--- /dev/null
+++ b/changelog.d/2990.change.rst
@@ -0,0 +1 @@
+Set the ``.origin`` attribute of the ``distutils`` module to the module's ``__file__``.
diff --git a/setuptools/tests/test_distutils_adoption.py b/setuptools/tests/test_distutils_adoption.py
index 70075483..366f2928 100644
--- a/setuptools/tests/test_distutils_adoption.py
+++ b/setuptools/tests/test_distutils_adoption.py
@@ -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