Skip to content

1.1a3/b2 does not detect installed packages as git #2730

@wakemaster39

Description

@wakemaster39
  • [ x] I am on the latest Poetry version.
  • [ x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x ] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: MacOs 10.15
  • Poetry version: 1.1a3/b2

Issue

This issues was found trying to validate the change set presented in #2327. In 1.0.9 where the PR was inititated, the

if pkg.source_type == "git" and package.source_type == "git":
pkg.source_type value was git, in the current master and develop, the pkg.source is returning None.

Back tracking this issue, lead me to the InstalledRepository load method,

for distribution in sorted(
metadata.distributions(path=[entry]), key=lambda d: str(d._path),
):

I have a test test up where my only dependency is a test git repo, I added the following to try and diagnose the problem.

        for entry in reversed(env.sys_path):
            print(entry, list(metadata.distributions(path=[entry])))
            for distribution in sorted(
                metadata.distributions(path=[entry]), key=lambda d: str(d._path),
            ):

The output is:

/Users/cahurst/code/test2/.venv/src/test-abc/src []
/Users/cahurst/code/test2/.venv/lib/python3.8/site-packages [<importlib.metadata.PathDistribution object at 0x109a84af0>, <importlib.metadata.PathDistribution object at 0x109a84a90>, <importlib.metadata.PathDistribution object at 0x109a84c70>, <importlib.metadata.PathDistribution object at 0x109a84dc0>, <importlib.metadata.PathDistribution object at 0x109a84c40>]
/Users/cahurst/.pyenv/versions/3.8.0/lib/python3.8/lib-dynload []
/Users/cahurst/.pyenv/versions/3.8.0/lib/python3.8 []
/Users/cahurst/.pyenv/versions/3.8.0/lib/python38.zip []
 []

My test repo is not returning any metadata distributions and during the next loop, the dist-info file is being detected and the package is being treated as a standard package and things try and get updated based on that.

Forcibly adding the following if condition to see if they is the root cause resolves the issue and pkg.source_type is being properly populated.

            for distribution in sorted(
                metadata.distributions(path=[entry]), key=lambda d: str(d._path),
            ):
                name = distribution.metadata["name"]
                path = Path(str(distribution._path))
                if name == "test-abc":
                    path = Path("/Users/cahurst/code/test2/.venv/src/test-abc/src")

Unfortunately, metadata.distributions is out of my knowledge base and I am unsure what should be changed here as I looked to try and see if something further in the chain might be wrong as well but this following gate fails unless that first entry is passed in and set.

try:
path.relative_to(src_path)
from poetry.core.vcs.git import Git
git = Git()

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions