Skip to content

Commit 6399269

Browse files
committed
Prevent duplicated package versions
The function get_versions_for_package_from_repo might return duplicated package versions in case the specified version is present both as wheel and as sdist package. Duplicated entries cause the package resolution to take longer. The new behavior is that the package version is considered if the package is present as either whel or sdist package. Signed-off-by: Stefano Bennati <[email protected]>
1 parent a5891f4 commit 6399269

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/python_inspector/resolution.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,20 +367,20 @@ def get_versions_for_package_from_repo(
367367
get_python_version_from_env_tag(python_version=self.environment.python_version)
368368
)
369369
wheels = list(package.get_supported_wheels(environment=self.environment))
370+
valid_wheel_present = False
371+
pypi_valid_python_version = False
370372
if wheels:
371-
valid_wheel_present = False
372373
for wheel in wheels:
373374
if utils_pypi.valid_python_version(
374375
python_requires=wheel.python_requires, python_version=python_version
375376
):
376377
valid_wheel_present = True
377-
if valid_wheel_present:
378-
versions.append(version)
379378
if package.sdist:
380-
if utils_pypi.valid_python_version(
379+
pypi_valid_python_version = utils_pypi.valid_python_version(
381380
python_requires=package.sdist.python_requires, python_version=python_version
382-
):
383-
versions.append(version)
381+
)
382+
if valid_wheel_present or pypi_valid_python_version:
383+
versions.append(version)
384384
return versions
385385

386386
def get_versions_for_package_from_pypi_json_api(self, name: str) -> List[Version]:

0 commit comments

Comments
 (0)