File tree Expand file tree Collapse file tree 3 files changed +15
-19
lines changed
Expand file tree Collapse file tree 3 files changed +15
-19
lines changed Original file line number Diff line number Diff line change @@ -198,23 +198,11 @@ def _discover_resolvers():
198198 return filter (None , declared )
199199
200200 @classmethod
201- 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 ):
212- dists = itertools .chain .from_iterable (
213- resolver (path = ['.' , 'src' ])
214- for resolver in cls ._discover_resolvers ()
215- )
216- dist , = dists
217- return dist
201+ def find_local (cls , root = '.' ):
202+ import pep517 .build_meta as bm
203+ system = bm .compat_build_system (root )
204+ builder = functools .partial (bm .build_meta , build_system = system )
205+ return PathDistribution (zipp .Path (bm .build_meta_as_zip (builder )))
218206
219207 @property
220208 def metadata (self ):
Original file line number Diff line number Diff line change @@ -150,11 +150,18 @@ def setUp(self):
150150
151151
152152class LocalPackage :
153+ files = {
154+ "setup.py" : """
155+ import setuptools
156+ setuptools.setup(name="local-pkg", version="2.0.1")
157+ """ ,
158+ }
159+
153160 def setUp (self ):
154161 self .fixtures = ExitStack ()
155162 self .addCleanup (self .fixtures .close )
156163 self .fixtures .enter_context (tempdir_as_cwd ())
157- build_files (EggInfoPkg .files )
164+ build_files (self .files )
158165
159166
160167def build_files (file_defs , prefix = pathlib .Path ()):
Original file line number Diff line number Diff line change @@ -156,4 +156,5 @@ def test_more_complex_deps_requires_text(self):
156156class LocalProjectTests (fixtures .LocalPackage , unittest .TestCase ):
157157 def test_find_local (self ):
158158 dist = local_distribution ()
159- assert dist .metadata ['Name' ] == 'egginfo-pkg'
159+ assert dist .metadata ['Name' ] == 'local-pkg'
160+ assert dist .version == '2.0.1'
You can’t perform that action at this time.
0 commit comments