From bd8d4dbd9638988f09b061f5d94a678c0fd80f25 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 31 Dec 2021 09:32:20 -0800 Subject: [PATCH] set origin= for distutils.__spec__ set origin so spec finding reports the correct location -- https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec --- _distutils_hack/__init__.py | 4 +++- changelog.d/2990.change.rst | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog.d/2990.change.rst diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index 75bc4463bb..cc62dcf68c 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -118,7 +118,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): """ diff --git a/changelog.d/2990.change.rst b/changelog.d/2990.change.rst new file mode 100644 index 0000000000..bb6e6032f4 --- /dev/null +++ b/changelog.d/2990.change.rst @@ -0,0 +1 @@ +Set the ``.origin`` attribute of the ``distutils`` module to the module's ``__file__``.