Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use package name from metadata file as package name #4

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

AGiantSquid
Copy link
Contributor

@AGiantSquid AGiantSquid commented Jul 28, 2023

When evaluating local package names in PyPackage.install(), a package's "canonical_name" should reference the package name from the metadata file, not the parent directory of the package.

Motivation

I tried linking a library to another library using namespace packages (eg acme.lib-a). The existing install() function compared the pkg.canonical_name with the name listed in the dependencies. The pkg.canonical_name was returning the parent directory of the package, relying on the package parent directory to have the same name as the python package. This is not always going to be the same as the package name, as some developers have different parent directory names than their project name. I added a property to the metadata classes to provide the package name as reported by the metadata file. I called this property package_name, as name was already a property for the class. I considered renaming the existing name property to something else, like type, but didn't want to create too many changes. It's a bit confusing that the Metadata classes contain properties that describe the metadata file itself (eg "name" and "filename") and properties that describe the python package (like "version")

I also updated a test case that was creating demo packages that all had the name "foo". This caused the tests to "add" a dependency fail, because adding "foo" to any project would cause a circular dependency (since all demo projects were named "foo" in their metadata file.)

This highlights that guardrails should probably be added that prevent self dependencies, or circular dependencies.

When evaluating local package names in PyPackage.install(), a
package's "canonical_name" should reference the package name
from the metadata file, not the parent directory of the project.
@AGiantSquid AGiantSquid changed the title fix: allow namespace packages as local dependencies fix: use package name from metadata file as package name Aug 4, 2023
@frostming frostming merged commit 0b04b33 into frostming:main Aug 4, 2023
12 checks passed
@AGiantSquid AGiantSquid deleted the allow-for-namespace-packages branch August 4, 2023 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants