Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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.

@AGiantSquid AGiantSquid force-pushed the allow-for-namespace-packages branch from 948dffe to 95732f8 Compare August 3, 2023 00:49
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 force-pushed the allow-for-namespace-packages branch from 95732f8 to 10fc852 Compare August 4, 2023 00:45
@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
@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