|
| 1 | +"""Compatibility backend for setuptools |
| 2 | +
|
| 3 | +This is a version of setuptools.build_meta that endeavors to maintain backwards |
| 4 | +compatibility with pre-PEP 517 modes of invocation. It exists as a temporary |
| 5 | +bridge between the old packaging mechanism and the new packaging mechanism, |
| 6 | +and will eventually be removed. |
| 7 | +""" |
| 8 | + |
| 9 | +import sys |
| 10 | + |
| 11 | +from setuptools.build_meta import _BuildMetaBackend |
| 12 | +from setuptools.build_meta import SetupRequirementsError |
| 13 | + |
| 14 | + |
| 15 | +__all__ = ['get_requires_for_build_sdist', |
| 16 | + 'get_requires_for_build_wheel', |
| 17 | + 'prepare_metadata_for_build_wheel', |
| 18 | + 'build_wheel', |
| 19 | + 'build_sdist', |
| 20 | + 'SetupRequirementsError'] |
| 21 | + |
| 22 | + |
| 23 | +class _BuildMetaLegacyBackend(_BuildMetaBackend): |
| 24 | + def run_setup(self, setup_script='setup.py'): |
| 25 | + # In order to maintain compatibility with scripts assuming that |
| 26 | + # the setup.py script is in a directory on the PYTHONPATH, inject |
| 27 | + # '' into sys.path. (pypa/setuptools#1642) |
| 28 | + sys_path = list(sys.path) # Save the old path |
| 29 | + if '' not in sys.path: |
| 30 | + sys.path.insert(0, '') |
| 31 | + |
| 32 | + super(_BuildMetaLegacyBackend, |
| 33 | + self).run_setup(setup_script=setup_script) |
| 34 | + |
| 35 | + sys.path = sys_path # Restore the old path |
| 36 | + |
| 37 | + |
| 38 | +_BACKEND = _BuildMetaLegacyBackend() |
| 39 | + |
| 40 | +get_requires_for_build_wheel = _BACKEND.get_requires_for_build_wheel |
| 41 | +get_requires_for_build_sdist = _BACKEND.get_requires_for_build_sdist |
| 42 | +prepare_metadata_for_build_wheel = _BACKEND.prepare_metadata_for_build_wheel |
| 43 | +build_wheel = _BACKEND.build_wheel |
| 44 | +build_sdist = _BACKEND.build_sdist |
0 commit comments