diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2022-01-16 18:21:04 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2022-01-16 18:21:04 -0500 |
| commit | 448b84062e84ed918818d4d56fb3571f3f045848 (patch) | |
| tree | 5b3ddb5c33ab4d92d3b5c18881d70fbfabf020fc | |
| parent | ecfcf0787fadb38b6b93c1c6e33fff985efd7f8c (diff) | |
| download | python-setuptools-git-448b84062e84ed918818d4d56fb3571f3f045848.tar.gz | |
Refactor to generalize script detection.
| -rw-r--r-- | _distutils_hack/__init__.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index 834a062c..399d22f1 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -135,9 +135,9 @@ class DistutilsMetaFinder: a stubbed spec to represent setuptools being present without invoking any behavior. - Workaround for pypa/get-pip#137. + Workaround for pypa/get-pip#137. Ref #2993. """ - if not self.is_get_pip(): + if not self.is_script('get-pip'): return import importlib @@ -166,14 +166,11 @@ class DistutilsMetaFinder: for frame, line in traceback.walk_stack(None) ) - @classmethod - def is_get_pip(cls): - """ - Detect if get-pip is being invoked. Ref #2993. - """ + @staticmethod + def is_script(name): try: import __main__ - return os.path.basename(__main__.__file__) == 'get-pip.py' + return os.path.basename(__main__.__file__) == f'{name}.py' except AttributeError: pass |
