Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/pyproject_hooks/_in_process/_in_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def find_distributions(self, context=None):
# Delayed import: Python 3.7 does not contain importlib.metadata
from importlib.metadata import DistributionFinder, MetadataPathFinder

context = DistributionFinder.Context(path=self.backend_path)
name = context.name if context else None
context = DistributionFinder.Context(name=name, path=self.backend_path)
return MetadataPathFinder.find_distributions(context=context)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Name: _pkg
Version: 0.0.1
6 changes: 6 additions & 0 deletions tests/samples/distribution_mismatch/backend/intree_backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from importlib.metadata import distribution


def get_requires_for_build_sdist(config_settings):
dist = distribution("setuptools") # not present in backend-path
return [dist.version]
3 changes: 3 additions & 0 deletions tests/samples/distribution_mismatch/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
build-backend = 'intree_backend'
backend-path = ['backend']
7 changes: 7 additions & 0 deletions tests/test_inplace_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ def test_intree_backend_importlib_metadata_interoperation():
]


def test_distribution_mismatch():
pytest.importorskip("importlib.metadata")

hooks = get_hooks("distribution_mismatch")
assert hooks.get_requires_for_build_sdist({}) != ["0.0.1"]


def install_finder_with_sitecustomize(directory, mapping):
finder = f"""
import sys
Expand Down
Loading