forked from pypa/setuptools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is part of the solution to GH pypa#1642, it is a backwards-compatibility backend that can be used as a default PEP 517 backend for projects that use setuptools but haven't opted in to build_meta.
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Compatibility backend for setuptools | ||
This is a version of setuptools.build_meta that endeavors to maintain backwards | ||
compatibility with pre-PEP 517 modes of invocation. It exists as a temporary | ||
bridge between the old packaging mechanism and the new packaging mechanism, | ||
and will eventually be removed. | ||
""" | ||
|
||
import sys | ||
|
||
from setuptools.build_meta import _BuildMetaBackend | ||
from setuptools.build_meta import SetupRequirementsError | ||
|
||
|
||
__all__ = ['get_requires_for_build_sdist', | ||
'get_requires_for_build_wheel', | ||
'prepare_metadata_for_build_wheel', | ||
'build_wheel', | ||
'build_sdist', | ||
'SetupRequirementsError'] | ||
|
||
|
||
class _BuildMetaLegacyBackend(_BuildMetaBackend): | ||
def run_setup(self, setup_script='setup.py'): | ||
# In order to maintain compatibility with scripts assuming that | ||
# the setup.py script is in a directory on the PYTHONPATH, inject | ||
# '' into sys.path. (pypa/setuptools#1642) | ||
sys_path = list(sys.path) # Save the old path | ||
if '' not in sys.path: | ||
sys.path.insert(0, '') | ||
|
||
super(_BuildMetaLegacyBackend, | ||
self).run_setup(setup_script=setup_script) | ||
|
||
sys.path = sys_path # Restore the old path | ||
|
||
|
||
_BACKEND = _BuildMetaLegacyBackend() | ||
|
||
get_requires_for_build_wheel = _BACKEND.get_requires_for_build_wheel | ||
get_requires_for_build_sdist = _BACKEND.get_requires_for_build_sdist | ||
prepare_metadata_for_build_wheel = _BACKEND.prepare_metadata_for_build_wheel | ||
build_wheel = _BACKEND.build_wheel | ||
build_sdist = _BACKEND.build_sdist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters