Open MatthijsBurgh opened 8 months ago
I think my issue is caused in the following lines: https://github.com/python-poetry/poetry-core/blob/37d310ed5255a4a40f59ee9b84a6890a2a439127/src/poetry/core/packages/path_dependency.py#L42-L43
>>> from pathlib import Path
>>> import os.path
>>> base = Path("/ws/root_pkg") # Assume it is linked to /dir1/dir2/dir3/root_pkg
>>> path = Path("../other_pkg")
>>> full_path = base.jointpath(path)
>>> print(full_path)
PosixPath('/ws/root_pkg/../other_pkg')
>>> full_path.absolute()
PosixPath('/ws/root_pkg/../other_pkg')
>>> full_path.resolve()
PosixPath('/dir1/dir2/dir3/other_pkg') # This doesn't exist as other_pkg is linked from somewhere else
>>> full_path_raw = full_path.as_posix()
>>> print(full_path_raw)
/ws/root_pkg/../other_pkg
>>> os.path.abspath(full_path_raw)
/ws/other_pkg # This is desired output in my case
>>> os.path.realpath(full_path_raw)
/dir1/dir2/dir3/other_pkg
Friendly ping @sdispater @radoering @abn @dimbleby
I'm not sure about the right path. Intuitively, I had the same expectation as you. However, according to the pathlib PEP:
Many os.path functions are tied by backwards compatibility to confusing or plain wrong behaviour (for example, the fact that os.path.abspath() simplifies “..” path components without resolving symlinks first).
and
The resolve() method makes a path absolute, resolving any symlink on the way (like the POSIX realpath() call). It is the only operation which will remove “..” path components.
-vvv
option) and have included the output below.Issue
My root project is a symlinked directory in a workspace. So that workspace might look like this
The
root_pkg
has a path dependency onother_pkg
via the path../other_pkg
. I run Poetry from theroot_pkg
folder. Poetry doesn't resolve the path dependency relative to the current PWD, but resolves the PWD to the realpath of PWD and then tries to find theother_pkg
Though the path dependency is only valid relative to the path in the workspace.So Poetry should honor the the directory structure in my workspace and not resolve all paths to their
realpath
. I don't know whether this is the desired behaviour, but an option to disable it would also be very helpful.poetry lock -vvv
orpoetry lock -vvv -C "/absolute_path_to_workspace/root_pkg"
(Same output, except fromLoading configuration file...
line)