question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Relative path imports are resolved relative to CWD instead of pyproject.toml

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).

Issue

I have 3 projects in a monorepo situation One has a pyproject.toml in kafkaesque/pyproject.toml It depends on another poetry package defined in config/pyproject.toml Then there’s another project that installs from kafkaesque and config into pyproject.toml like so:

config/pyproject.toml
kafkaesque/pyproject.toml
pyproject.toml

I get the following error:

[EnvCommandError]
Command ['/Users/swistak/Library/Caches/pypoetry/virtualenvs/marmot-api-SV6HPF22-py3.7/bin/pip', 'install', '--no-deps', '-U', '/Users/swistak/code/marmot/api/kafkaesque'] errored with the following return code 1, and output: 
Processing ./kafkaesque
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  Complete output from command /Users/swistak/Library/Caches/pypoetry/virtualenvs/marmot-api-SV6HPF22-py3.7/bin/python /Users/swistak/Library/Caches/pypoetry/virtualenvs/marmot-api-SV6HPF22-py3.7/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/93/78_vw68j75j3xf_z25p29_b80000gn/T/tmpmcyd92s5:
  Traceback (most recent call last):
    File "/Users/swistak/Library/Caches/pypoetry/virtualenvs/marmot-api-SV6HPF22-py3.7/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
      main()
    File "/Users/swistak/Library/Caches/pypoetry/virtualenvs/marmot-api-SV6HPF22-py3.7/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Users/swistak/Library/Caches/pypoetry/virtualenvs/marmot-api-SV6HPF22-py3.7/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 54, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/private/var/folders/93/78_vw68j75j3xf_z25p29_b80000gn/T/pip-build-env-go6yfl9w/overlay/lib/python3.7/site-packages/poetry/masonry/api.py", line 25, in get_requires_for_build_wheel
      poetry = Factory().create_poetry(Path("."))
    File "/private/var/folders/93/78_vw68j75j3xf_z25p29_b80000gn/T/pip-build-env-go6yfl9w/overlay/lib/python3.7/site-packages/poetry/factory.py", line 99, in create_poetry
      package.add_dependency(name, constraint)
    File "/private/var/folders/93/78_vw68j75j3xf_z25p29_b80000gn/T/pip-build-env-go6yfl9w/overlay/lib/python3.7/site-packages/poetry/packages/package.py", line 331, in add_dependency
      develop=constraint.get("develop", True),
    File "/private/var/folders/93/78_vw68j75j3xf_z25p29_b80000gn/T/pip-build-env-go6yfl9w/overlay/lib/python3.7/site-packages/poetry/packages/directory_dependency.py", line 36, in __init__
      raise ValueError("Directory {} does not exist".format(self._path))
  ValueError: Directory ../config does not exist

Note that both kafkaesque/pyproject.toml and pyproject.toml both depend on config/pyproject.toml albeit with a different path in their respective project files

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

12reactions
carloshenrique153commented, Apr 12, 2021

Even though this issue is closed, this is still a bug in poetry 1.1.5.

If you have a monorepo with 3 projects where

  • pyproject.toml of project A has B = { path = "../B" }
  • pyproject.toml of project B has C = { path = "../C" }

Then running poetry update on project A causes: ValueError: Directory ../C does not exist

4reactions
finswimmercommented, Nov 2, 2020

Hello @yanbussieres,

since poetry 1.1 path dependencies are no longer installed in editable mode by default. You will need to add a develop=true to your dependency definitions in the pyproject.toml, e.g. dep1 = {path = "../dep1", develop=true}.

fin swimmer

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to refer to relative paths of resources when working with ...
In Python, paths are relative to the current working directory, which in most cases is the directory from which you run your program....
Read more >
Configuration - Sphinx documentation
Relative paths are taken as relative to the configuration directory. They are copied to the output directory. They will overwrite any existing file...
Read more >
Code - Hatch
path (required), A relative path to a Python file or extension module that will be loaded ; expression, A Python expression that when...
Read more >
PEP 517 Backend bootstrapping - Discussions on Python.org
I propose that we add some mechanism in pyproject.toml for a project to specify that it wants to use a pre-built PEP 517...
Read more >
Flit Documentation
Flit looks for the source of the package by its import name. ... Must be relative paths from the directory containing pyproject.toml.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found