Broken Relative Paths when package in subtree of installing package
See original GitHub issue- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).
- OS version and name: MacOS/Linux (windows untested)
- Poetry version: 1.1.17
- Link of a Gist with the contents of your pyproject.toml file: https://github.com/jamtat/poetry-broken-relative-paths
Issue
(copy+pasted from above repo linked)
Broken Relative Paths when package in subtree of installing package
Relative path imports fail when there is a dependency tree such that:
application -> otherlib -> baselib
otherlib
andbaselib
share a filepath with pyproject.toml such that if pyproject.toml is at<path>/pyproject.toml
, other libs are at<path>/<any descendant path>/{otherlib,baselib}
Steps to reproduce
- Have poetry 1.1.17
- Latest pip
- Run:
pushd common/baselib; poetry install; popd
pushd common/otherlib; poetry install; popd
poetry install
Expected result
- In the case that having a package be in the subtree of another package is supported the relative path should be properly adjusted to be relative to the pyproject.toml
- In this case that this behaviour is unsupported a more descriptive error should be raised, possibly referencing this issue and saying something like βPackages may not exist as a subtree of a dependant packageβ
Result
Stack trace:
11 ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/clikit/console_application.py:131 in run
129β parsed_args = resolved_command.args
130β
β 131β status_code = command.handle(parsed_args, io)
132β except KeyboardInterrupt:
133β status_code = 1
10 ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/clikit/api/command/command.py:120 in handle
118β def handle(self, args, io): # type: (Args, IO) -> int
119β try:
β 120β status_code = self._do_handle(args, io)
121β except KeyboardInterrupt:
122β if io.is_debug():
9 ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/clikit/api/command/command.py:163 in _do_handle
161β if self._dispatcher and self._dispatcher.has_listeners(PRE_HANDLE):
162β event = PreHandleEvent(args, io, self)
β 163β self._dispatcher.dispatch(PRE_HANDLE, event)
164β
165β if event.is_handled():
8 ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/clikit/api/event/event_dispatcher.py:22 in dispatch
20β
21β if listeners:
β 22β self._do_dispatch(listeners, event_name, event)
23β
24β return event
7 ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
87β break
88β
β 89β listener(event, event_name, self)
90β
91β def _sort_listeners(self, event_name): # type: (str) -> None
6 ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/poetry/console/config/application_config.py:116 in set_env
114β
115β io = event.io
β 116β poetry = command.poetry
117β
118β env_manager = EnvManager(poetry)
5 ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/poetry/console/commands/command.py:10 in poetry
8β @property
9β def poetry(self):
β 10β return self.application.poetry
11β
12β def reset_poetry(self): # type: () -> None
4 ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/poetry/console/application.py:69 in poetry
67β return self._poetry
68β
β 69β self._poetry = Factory().create_poetry(Path.cwd())
70β
71β return self._poetry
3 ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/poetry/factory.py:33 in create_poetry
31β io = NullIO()
32β
β 33β base_poetry = super(Factory, self).create_poetry(cwd)
34β
35β locker = Locker(
2 ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/poetry/core/factory.py:93 in create_poetry
91β
92β package.add_dependency(
β 93β self.create_dependency(name, constraint, root_dir=package.root_dir)
94β )
95β
1 ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/poetry/core/factory.py:251 in create_dependency
249β base=root_dir,
250β develop=constraint.get("develop", False),
β 251β extras=constraint.get("extras", []),
252β )
253β elif "url" in constraint:
ValueError
Directory ../common/otherlib does not exist
at ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/poetry/core/packages/directory_dependency.py:41 in __init__
37β self._develop = develop
38β self._supports_poetry = False
39β
40β if not self._full_path.exists():
β 41β raise ValueError("Directory {} does not exist".format(self._path))
42β
43β if self._full_path.is_file():
44β raise ValueError("{} is a file, expected a directory".format(self._path))
45β
Directory Structure:
|- pyproject.toml
|- application/
|- __init__.py
|- common
|- baselib/
|- pyproject.toml
|- baselib/
|- __init__.py
|- otherlib/
|- pyproject.toml
|- otherlib/
|- __init__.py
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Relative paths broken for Homebrew install Β· Issue #21 - GitHub
After installing with Homebrew I get this error: βΊ nodenv which node /usr/local/bin/nodenv-package-json-engine: line 42: /usr/local/bin/.
Read more >How are relative paths resolved inside of node packages?
I am making a npm package which, after installation, runs a postinstall script located in the lib/ directory. This postinstall script inΒ ...
Read more >Install GitLab under a relative URL
This document describes how to run GitLab under a relative URL for installations from source. If you are using an Omnibus package, the...
Read more >Working With Files - Gradle User Manual
The problem is that paths often change and the more places you need to change them, the more likely you are to miss...
Read more >install β CMake 3.25.1 Documentation
Specify the directory on disk to which a file will be installed. Arguments can be relative or absolute paths. If a relative path...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I believe this is a duplicate of #4245, which was just fixed by #4246.
@hckr youβre totally right, my mistake there.
Correcting the pyproject.toml does cause poetry to successfully install the root project on 1.20a2, however it fails on 1.1.17.
This bug does seem to be fixed. Thanks for all your help.