Skip to content

Commit

Permalink
Restore 'add_shim' as the way to invoke the hook. Avoids compatibilit…
Browse files Browse the repository at this point in the history
…y issues between different versions of Setuptools with the distutils local implementation. Renamed the former 'add_shim' as 'insert_shim'. Fixes #2983
  • Loading branch information
jaraco committed Dec 29, 2021
1 parent b324f92 commit d0da014
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions _distutils_hack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,20 @@ def frame_file_is_setup(frame):
DISTUTILS_FINDER = DistutilsMetaFinder()


def ensure_shim():
DISTUTILS_FINDER in sys.meta_path or add_shim()
def add_shim():
DISTUTILS_FINDER in sys.meta_path or insert_shim()


@contextlib.contextmanager
def shim():
add_shim()
insert_shim()
try:
yield
finally:
remove_shim()


def add_shim():
def insert_shim():
sys.meta_path.insert(0, DISTUTILS_FINDER)


Expand Down
1 change: 1 addition & 0 deletions changelog.d/2983.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Restore 'add_shim' as the way to invoke the hook. Avoids compatibility issues between different versions of Setuptools with the distutils local implementation.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class install_with_pth(install):
import os
var = 'SETUPTOOLS_USE_DISTUTILS'
enabled = os.environ.get(var, 'local') == 'local'
enabled and __import__('_distutils_hack').ensure_shim()
enabled and __import__('_distutils_hack').add_shim()
""").lstrip().replace('\n', '; ')

def initialize_options(self):
Expand Down

0 comments on commit d0da014

Please sign in to comment.