Skip to content

Commit

Permalink
Fixed incorrect handling of main packages in pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Nov 15, 2024
1 parent 0b6c152 commit 33acdc8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
9 changes: 8 additions & 1 deletion komodo/check_unused_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ def check_for_unused_package(
repository: RepositoryFile,
builtin_python_versions: Dict[str, str],
):
all_dependencies = dict(release_file.content.items())
pypi_dependencies = {
name: version
for name, version in all_dependencies.items()
if repository_file.content.get(name, {}).get(version, {}).get("source")
== "pypi"
}
package_status = load_yaml(package_status_file)
public_and_plugin_packages = [
(pkg, version)
Expand All @@ -28,7 +35,7 @@ def check_for_unused_package(
full_python_version = builtin_python_versions[python_version]

dependencies = PypiDependencies(
release_file.content, python_version=full_python_version
pypi_dependencies, all_dependencies, python_version=full_python_version
)
for name, version in release_file.content.items():
metadata = repository.content.get(name, {}).get(version, {})
Expand Down
5 changes: 3 additions & 2 deletions komodo/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ def lint(
maintainers.append(komodo_exception.error)

if check_dependencies:
all_dependencies = dict(release_file.content.items())
pypi_dependencies = {
name: version
for name, version in release_file.content.items()
for name, version in all_dependencies.items()
if repository_file.content.get(name, {}).get(version, {}).get("source")
== "pypi"
}
Expand All @@ -105,7 +106,7 @@ def lint(
full_python_version = yaml.safe_load(f)[python_version]

dependencies = PypiDependencies(
pypi_dependencies, python_version=full_python_version
pypi_dependencies, all_dependencies, python_version=full_python_version
)
for name, version in release_file.content.items():
if (
Expand Down
9 changes: 6 additions & 3 deletions komodo/pypi_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def format_full_version(info) -> str:
class PypiDependencies:
def __init__(
self,
pypi_dependencies: Dict[str, str],
to_install: Dict[str, str],
python_version: str,
cachefile: str = "./pypi_dependencies.yml",
Expand All @@ -51,9 +52,11 @@ def __init__(
self._failed_requirements: Dict[Requirement, str] = {}
self._used_packages = set()

self._to_install = to_install

self._install_names = {canonicalize_name(name): name for name in to_install}
self._pypi_dependencies = {
canonicalize_name(name): version
for name, version in pypi_dependencies.items()
}
self._to_install = {
canonicalize_name(name): version for name, version in to_install.items()
}
Expand All @@ -70,7 +73,7 @@ def __init__(
self._user_specified = {}

def _update_package_sets(self, packages=None):
for package_name, version in packages or self._to_install.items():
for package_name, version in packages or self._pypi_dependencies.items():
requirements = self._get_requirements(package_name, version)
self._used_packages.add(package_name)
for r in requirements:
Expand Down

0 comments on commit 33acdc8

Please sign in to comment.