|
39 | 39 | from _packagedcode.pypi import PythonSetupPyHandler |
40 | 40 | from _packagedcode.pypi import SetupCfgHandler |
41 | 41 | from _packagedcode.pypi import can_process_dependent_package |
| 42 | +from python_inspector import pyinspector_settings as settings |
42 | 43 | from python_inspector import utils_pypi |
43 | 44 | from python_inspector.error import NoVersionsFound |
44 | 45 | from python_inspector.setup_py_live_eval import iter_requirements |
@@ -107,7 +108,7 @@ def get_deps_from_distribution( |
107 | 108 | deps = [] |
108 | 109 | for package_data in handler.parse(location): |
109 | 110 | dependencies = package_data.dependencies |
110 | | - deps.extend(dependencies) |
| 111 | + deps.extend(dependencies=dependencies) |
111 | 112 | return deps |
112 | 113 |
|
113 | 114 |
|
@@ -211,21 +212,21 @@ async def fetch_and_extract_sdist( |
211 | 212 | def get_sdist_file_path_from_filename(sdist): |
212 | 213 | if sdist.endswith(".tar.gz"): |
213 | 214 | sdist_file = sdist.rstrip(".tar.gz") |
214 | | - with tarfile.open(os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, sdist)) as file: |
| 215 | + with tarfile.open(os.path.join(settings.CACHE_THIRDPARTY_DIR, sdist)) as file: |
215 | 216 | file.extractall( |
216 | | - os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, "extracted_sdists", sdist_file) |
| 217 | + os.path.join(settings.CACHE_THIRDPARTY_DIR, "extracted_sdists", sdist_file) |
217 | 218 | ) |
218 | 219 | elif sdist.endswith(".zip"): |
219 | 220 | sdist_file = sdist.rstrip(".zip") |
220 | | - with ZipFile(os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, sdist)) as zip: |
| 221 | + with ZipFile(os.path.join(settings.CACHE_THIRDPARTY_DIR, sdist)) as zip: |
221 | 222 | zip.extractall( |
222 | | - os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, "extracted_sdists", sdist_file) |
| 223 | + os.path.join(settings.CACHE_THIRDPARTY_DIR, "extracted_sdists", sdist_file) |
223 | 224 | ) |
224 | 225 |
|
225 | 226 | else: |
226 | 227 | raise Exception(f"Unable to extract sdist {sdist}") |
227 | 228 |
|
228 | | - return os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, "extracted_sdists", sdist_file, sdist_file) |
| 229 | + return os.path.join(settings.CACHE_THIRDPARTY_DIR, "extracted_sdists", sdist_file, sdist_file) |
229 | 230 |
|
230 | 231 |
|
231 | 232 | def get_requirements_from_dependencies( |
@@ -444,7 +445,7 @@ async def _get_versions_for_package_from_pypi_json_api(self, name: str) -> List[ |
444 | 445 | api_url = f"https://pypi.org/pypi/{name}/json" |
445 | 446 | resp = await get_response_async(api_url) |
446 | 447 | if not resp: |
447 | | - self.versions_by_package[name] = [] |
| 448 | + return [] |
448 | 449 | releases = resp.get("releases") or {} |
449 | 450 | return releases.keys() or [] |
450 | 451 |
|
@@ -497,7 +498,7 @@ async def _get_requirements_for_package_from_pypi_simple( |
497 | 498 |
|
498 | 499 | if wheels: |
499 | 500 | for wheel in wheels: |
500 | | - wheel_location = os.path.join(utils_pypi.CACHE_THIRDPARTY_DIR, wheel) |
| 501 | + wheel_location = os.path.join(settings.CACHE_THIRDPARTY_DIR, wheel) |
501 | 502 | requirements = get_requirements_from_distribution( |
502 | 503 | handler=PypiWheelHandler, |
503 | 504 | location=wheel_location, |
@@ -596,7 +597,8 @@ def _iter_matches( |
596 | 597 | name = remove_extras(identifier=identifier) |
597 | 598 | bad_versions = {c.version for c in incompatibilities[identifier]} |
598 | 599 | extras = {e for r in requirements[identifier] for e in r.extras} |
599 | | - versions = self.get_versions_for_package(name) |
| 600 | + versions = [] |
| 601 | + versions.extend(self.get_versions_for_package(name=name)) |
600 | 602 |
|
601 | 603 | if not versions: |
602 | 604 | if self.ignore_errors: |
|
0 commit comments