aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Ganssle <paul@ganssle.io>2019-01-27 12:31:28 -0500
committerPaul Ganssle <paul@ganssle.io>2019-02-03 12:25:06 -0500
commitfd3b06dae1a33b3131cf96ddb9d7938430b9d8b5 (patch)
tree238faab80b143585fb4c6c03ec38527491cbf405
parenta114112ea5e6df87a826e0fa2927cffd2472aec1 (diff)
downloadexternal_python_setuptools-fd3b06dae1a33b3131cf96ddb9d7938430b9d8b5.tar.gz
external_python_setuptools-fd3b06dae1a33b3131cf96ddb9d7938430b9d8b5.tar.bz2
external_python_setuptools-fd3b06dae1a33b3131cf96ddb9d7938430b9d8b5.zip
Add build_meta_legacy backend
This is part of the solution to GH #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.
-rw-r--r--setuptools/build_meta_legacy.py44
-rw-r--r--setuptools/tests/test_build_meta.py1
2 files changed, 44 insertions, 1 deletions
diff --git a/setuptools/build_meta_legacy.py b/setuptools/build_meta_legacy.py
new file mode 100644
index 00000000..7eed41f1
--- /dev/null
+++ b/setuptools/build_meta_legacy.py
@@ -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
diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py
index 5d97ebce..b29d6f29 100644
--- a/setuptools/tests/test_build_meta.py
+++ b/setuptools/tests/test_build_meta.py
@@ -258,7 +258,6 @@ class TestBuildMetaBackend:
build_backend.build_sdist("temp")
-@pytest.mark.xfail
class TestBuildMetaLegacyBackend(TestBuildMetaBackend):
backend_name = 'setuptools.build_meta_legacy'