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: directory is not package unless contains metadata file #7

Conversation

AGiantSquid
Copy link
Contributor

iter_packages previously considered any directory in a package_path to be a package.
This adds a check that the metadata.path is a file before considering the directory to be a package.

When monas loads its configuration from the top level pyproject.toml, it reads the "packages" field to find local packages via the package_paths property.
iter_packages will scan the package_paths, and check if each one is a directory before turning it into a PyPackage class and yielding it as one of the local monorepo packages.

The PyPackage class will initialize just fine when provided an empty directory. This behavior starts with a check if there is a pyproject.toml file, and if one is not found, it will set its metadata to an empty dict. The SetupCfgMetadata class's match function will return True if provided such an empty dict. This means an empty directory scanned by iter_packages will be initialized as a valid setupcfg project, even in there is no matching setup.cfg file contained in the directory.

I think there may be an argument to preventing this class from initializing at all if there is not a valid setup.cfg file contained in the directory. I wasn't sure if the existing logic was intentional, so I didn't change it.

Instead, I just added a check to iter_packages that verifies that the expected metadata file exists before returning it as a package.

iter_packages previously considered any directory in a package_path
to be a package.
This adds a check that the metadata.path is a file before considering
the directory to be a package.
@frostming frostming merged commit 917ce0d into frostming:main Aug 3, 2023
12 checks passed
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.

None yet

2 participants