Skip to content

Commit b9421de

Browse files
committed
Address review comments
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent a9f94ca commit b9421de

2 files changed

Lines changed: 24 additions & 21 deletions

File tree

src/python_inspector/resolution.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ def get_response(url):
5252
return None
5353

5454

55-
def get_requirements_from_distribution(handler, path, resolved_requirements):
55+
def get_requirements_from_distribution(handler, location, resolved_requirements):
5656
"""
5757
Return a list of requirements from a distribution.
5858
"""
59-
if not os.path.exists(path):
59+
if not os.path.exists(location):
6060
return []
61-
deps = list(handler.parse(path))
61+
deps = list(handler.parse(location))
6262
assert len(deps) == 1
6363
return list(
6464
get_requirements_from_dependencies(
@@ -293,56 +293,58 @@ def get_requirements_for_package_from_pypi_simple(self, candidate):
293293
has_wheels = False
294294

295295
for wheel in wheels:
296-
wheel_path = os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, wheel)
296+
wheel_location = os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, wheel)
297297
deps = get_requirements_from_distribution(
298298
handler=PypiWheelHandler,
299-
path=wheel_path,
299+
location=wheel_location,
300300
resolved_requirements=self.resolved_requirements,
301301
)
302302
if deps:
303303
has_wheels = True
304304
yield from deps
305-
print(has_wheels, candidate)
305+
306306
if not has_wheels:
307-
sdist_file = fetch_and_extract_sdist(
307+
sdist_location = fetch_and_extract_sdist(
308308
repos=self.repos, candidate=candidate, python_version=python_version
309309
)
310310

311-
if sdist_file:
312-
setup_py_path = os.path.join(
313-
sdist_file,
311+
if sdist_location:
312+
setup_py_location = os.path.join(
313+
sdist_location,
314314
"setup.py",
315315
)
316-
setup_cfg_path = os.path.join(
317-
sdist_file,
316+
setup_cfg_location = os.path.join(
317+
sdist_location,
318318
"setup.cfg",
319319
)
320320

321-
path_by_sdist_parser = {
322-
PythonSetupPyHandler: setup_py_path,
323-
SetupCfgHandler: setup_cfg_path,
321+
location_by_sdist_parser = {
322+
PythonSetupPyHandler: setup_py_location,
323+
SetupCfgHandler: setup_cfg_location,
324324
}
325325

326326
deps_in_setup = False
327327

328-
for handler, path in path_by_sdist_parser.items():
328+
for handler, location in location_by_sdist_parser.items():
329329
deps = get_requirements_from_distribution(
330-
handler=handler, path=path, resolved_requirements=self.resolved_requirements
330+
handler=handler,
331+
location=location,
332+
resolved_requirements=self.resolved_requirements,
331333
)
332334
if deps:
333335
deps_in_setup = True
334336
yield from deps
335337

336-
requirement_path = os.path.join(
337-
sdist_file,
338+
requirement_location = os.path.join(
339+
sdist_location,
338340
"requirements.txt",
339341
)
340342
if not deps_in_setup and is_requirements_file_in_setup_files(
341-
setup_files=[setup_py_path, setup_cfg_path]
343+
setup_files=[setup_py_location, setup_cfg_location]
342344
):
343345
deps = get_requirements_from_distribution(
344346
hanlder=PipRequirementsFileHandler,
345-
path=requirement_path,
347+
location=requirement_location,
346348
resolved_requirements=self.resolved_requirements,
347349
)
348350
if deps:

src/python_inspector/resolve_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ def resolve(direct_dependencies, environment, repos=tuple(), as_tree=False, max_
281281

282282
for dependency in direct_dependencies:
283283
# FIXME We are skipping editable requirements for now
284+
# https://github.com/nexB/python-inspector/issues/41
284285
if dependency.extra_data.get("is_editable"):
285286
continue
286287
requirement = Requirement(requirement_string=dependency.extracted_requirement)

0 commit comments

Comments
 (0)