Skip to content

Commit

Permalink
fix: allow namespace packages as local dependencies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AGiantSquid committed Jul 28, 2023
1 parent 1073b12 commit 948dffe
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/monas/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ def iter_packages(self) -> Iterable[PyPackage]:
for p in self.package_paths:
for package in p.iterdir():
if package.is_dir():
yield PyPackage(self, package)
pypackage = PyPackage(self, package)
if not pypackage.metadata.path.is_file():
# directory has no python metadata file, ignore
continue
yield pypackage


pass_config = click.make_pass_decorator(Config, ensure=True)
5 changes: 5 additions & 0 deletions src/monas/metadata/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ def version(self) -> str:
"""Get the project version"""
pass

@abc.abstractproperty
def package_name(self) -> str:
"""Get the project version"""
pass

@version.setter
def version(self, value: str) -> None:
"""Set the project version"""
Expand Down
4 changes: 4 additions & 0 deletions src/monas/metadata/pep621.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def _write(self) -> None:
def version(self) -> str:
return self._data["project"]["version"]

@property
def package_name(self) -> str:
return self._data["project"]["name"]

@version.setter
def version(self, value: str) -> None:
self._data["project"]["version"] = value
Expand Down
4 changes: 4 additions & 0 deletions src/monas/metadata/setupcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def _write(self) -> None:
def version(self) -> str:
return self._parser.get("metadata", "version")

@property
def package_name(self) -> str:
return self._parser.get("metadata", "name")

@version.setter
def version(self, value: str) -> None:
self._parser["metadata"]["version"] = value
Expand Down
7 changes: 6 additions & 1 deletion src/monas/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ def _get_metadata(self) -> Metadata:
@property
def canonical_name(self) -> str:
"""Get the project name"""
return canonicalize_name(self.path.name)
return canonicalize_name(self.metadata.package_name)

@property
def package_name(self) -> str:
"""Get the project name"""
return self.metadata.package_name

@property
def version(self) -> str:
Expand Down

0 comments on commit 948dffe

Please sign in to comment.