Skip to content

Commit 8a62944

Browse files
committed
Demonstrate one possible way to use pypa/pyproject-hooks#26 load metadata for a local package. Ref #42.
1 parent c124a26 commit 8a62944

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

importlib_metadata/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,18 @@ def _discover_resolvers():
199199

200200
@classmethod
201201
def find_local(cls):
202+
return cls._from_pyproject() or cls._heuristic_local()
203+
204+
@staticmethod
205+
def _from_pyproject():
206+
with suppress(Exception):
207+
from pep517.build_meta import build_meta_as_zip
208+
return PathDistribution(build_meta_as_zip())
209+
210+
@classmethod
211+
def _heuristic_local(cls):
202212
dists = itertools.chain.from_iterable(
203-
resolver(path=['.'])
213+
resolver(path=['.', 'src'])
204214
for resolver in cls._discover_resolvers()
205215
)
206216
dist, = dists

0 commit comments

Comments
 (0)