python-poetry / python-poetry/poetry

Incorrect root folder path for Windows network drives.

Open
#4,327 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/windows kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • OS version and name: Windows 10
  • Poetry version: 1.1.7

Issue

Poetry creates a .pth file in the site-packages directory that contains the path of the root folder as explained in https://github.com/python-poetry/poetry/issues/4133#issuecomment-853865155. The path is resolved using the resolve() method here: https://github.com/python-poetry/poetry/blob/89575f6f10bed0517521775af335d2630e92bd1a/poetry/masonry/builders/editable.py#L120
The problem is resolve() doesn't work as expected with Windows network drives. If I have my G: drive mapped to C:/projects folder then resolve() will transform G:/projectFoo into C:/projects/projectFoo instead of keeping the same drive (G:/projectFoo). This becomes a significant issue when navigating project code from the G: drive in PyCharm because going to function declaration/usage will open files from the C: drive and PyCharm will think they are not part of the same project.

The issues are explained further at https://discuss.python.org/t/pathlib-absolute-vs-resolve/2573/2.

A recommendation from the above thread is to use Path.cwd() / path, which effectively gets the absolute path, even for Windows network drives. Replacing resolve() with this should fix the issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at poetry/masonry/builders/editable.py around line 120, where the root path for the .pth file is resolved. Reproduce the behavior with a project on a mapped Windows network drive and compare the generated path with the project location. Done means the .pth file preserves the mapped drive path rather than replacing it with its underlying local path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.