Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
wakemaster39 opened this issue Jul 27, 2020 · 5 comments · Fixed by #2722
Closed

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

wakemaster39 opened this issue Jul 27, 2020 · 5 comments · Fixed by #2722
Labels
kind/bug Something isn't working as expected

Comments

@wakemaster39
Copy link

wakemaster39 commented Jul 27, 2020

  • [ 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()

@wakemaster39 wakemaster39 added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jul 27, 2020
@abn
Copy link
Member

abn commented Jul 27, 2020

@wakemaster39 can you try the fix in #2722, I think that should resolve this issue.

@wakemaster39
Copy link
Author

@abn no, this isn't resolving the problem. I think it definitely could but there is one problem I am not sure how to best resolve.

My test library is named test-abc, and the .pth file that is being installed is called test_abc.pth

- is not a valid character in python packages so my source folder contains test_abc as its root folder. Now I am not sure if the process is installed based on this name or if the package name is purely getting a replace done on it.

Adjusting line 40 to be pth_file = lib_path.joinpath(name.replace("-", "_")).with_suffix(".pth") fixed the issue for me but I am not sure if this is the right way to do it.

@abn
Copy link
Member

abn commented Jul 30, 2020

@wakemaster39 i have pushed a new fix to that branch

@wakemaster39
Copy link
Author

@abn looks good now :)

@abn abn removed the status/triage This issue needs to be triaged label Sep 25, 2020
Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants