Skip to content

Proof of Concept: Add support for bootstrap backend #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pep517/_in_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,25 @@ def __init__(self, traceback):
self.traceback = traceback


def _backend_importer(mod_path):
if mod_path == '<bootstrap-backend>':
sys.path.insert(0, '')
mod = import_module('__bootstrap_backend__')
sys.path[:] = sys.path[1:]
else:
mod = import_module(mod_path)

return mod


def _build_backend():
"""Find and load the build backend"""
ep = os.environ['PEP517_BUILD_BACKEND']

mod_path, _, obj_path = ep.partition(':')

try:
obj = import_module(mod_path)
obj = _backend_importer(mod_path)
except ImportError:
raise BackendUnavailable(traceback.format_exc())
if obj_path:
Expand Down
19 changes: 19 additions & 0 deletions tests/samples/bootstrap_pkg/__bootstrap_backend__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# A "bootstrap backend" for testing purposes
def get_requires_for_build_wheel(*args, **kwargs):
return ['wheel', 'sentinel']


def get_requires_for_build_sdist(*args, **kwargs):
return ['sdist_sentinel']


def prepare_metadata_for_build_wheel(*args, **kwargs):
pass


def build_wheel(*args, **kwargs):
pass


def build_sdist(*args, **kwargs):
pass
3 changes: 3 additions & 0 deletions tests/samples/bootstrap_pkg/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires=[]
build-backend="<bootstrap-backend>"
10 changes: 10 additions & 0 deletions tests/test_call_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,13 @@ def test_build_sdist_unsupported():
with modified_env({'PYTHONPATH': BUILDSYS_PKGS}):
with pytest.raises(UnsupportedOperation):
hooks.build_sdist(sdistdir, {'test_unsupported': True})


def test_bootstrap_backend():
hooks = get_hooks('bootstrap_pkg')
with modified_env({'PYTHONPATH': ''}):
wheel_reqs = hooks.get_requires_for_build_wheel({})
assert wheel_reqs == ['wheel', 'sentinel']

sdist_reqs = hooks.get_requires_for_build_sdist({})
assert sdist_reqs == ['sdist_sentinel']