fix: directory is not package unless contains metadata file #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thepackage_paths
property.iter_packages
will scan thepackage_paths
, and check if each one is a directory before turning it into aPyPackage
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 apyproject.toml
file, and if one is not found, it will set its metadata to an empty dict. TheSetupCfgMetadata
class'smatch
function will returnTrue
if provided such an empty dict. This means an empty directory scanned byiter_packages
will be initialized as a valid setupcfg project, even in there is no matchingsetup.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.