Poetry: Relative path cannot be found

Created on 23 Oct 2020  路  6Comments  路  Source: python-poetry/poetry

  • [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: Windows 10

  • Poetry version: 1.1.3
  • Repo with bug: https://github.com/jonapich/test-poetry-relative-paths

Issue

Depending on a module through a relative path that also depends on a relative path broke between 1.0.10 and 1.1.0.

The issue only seems to occur with nested packages. It works with one relative path, but if this path also contains a relative path dependency, that's when the bug occurs.

Following the steps in the readme of the linked repository will lead to this error:

  Command C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-dloyykXv-py3.8\Scripts\pip.exe install --no-deps -U C:/Users/user/code/test-poetry-relative-paths/test-functools/test-poetry-relative-paths/test-testing errored with the following return code 1, and output:
  Processing c:\users\user\code\test-poetry-relative-paths\test-functools\test-poetry-relative-paths\test-testing
    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 'done'
      Preparing wheel metadata: started
      Preparing wheel metadata: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: 'C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-dloyykXv-py3.8\Scripts\python.exe' 'C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-dloyykXv-py3.8\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\user\AppData\Local\Temp\tmp6_drxiht'
           cwd: C:\Users\user\AppData\Local\Temp\pip-req-build-6vl779_r
      Complete output (16 lines):
      Traceback (most recent call last):
        File "C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-dloyykXv-py3.8\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 280, in <module>
          main()
        File "C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-dloyykXv-py3.8\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 263, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "C:\Users\user\AppData\Local\pypoetry\Cache\virtualenvs\test-functools-dloyykXv-py3.8\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 133, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-8git_pgc\overlay\Lib\site-packages\poetry\core\masonry\api.py", line 34, in prepare_metadata_for_build_wheel
          poetry = Factory().create_poetry(Path(".").resolve())
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-8git_pgc\overlay\Lib\site-packages\poetry\core\factory.py", line 91, in create_poetry
          self.create_dependency(name, constraint, root_dir=package.root_dir)
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-8git_pgc\overlay\Lib\site-packages\poetry\core\factory.py", line 242, in create_dependency
          dependency = DirectoryDependency(
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-8git_pgc\overlay\Lib\site-packages\poetry\core\packages\directory_dependency.py", line 36, in __init__
          raise ValueError("Directory {} does not exist".format(self._path))
      ValueError: Directory ..\test-lib does not exist
Question

All 6 comments

With 1.1.0 Poetry no longer defaults to develop = true for path dependencies.

Please refer to https://python-poetry.org/blog/announcing-poetry-1-1-0.html#directory-dependencies-are-now-non-editable-by-default

In your case poetry attempts a PEP 517 build of your dependency, but since thats are relative files required for the build are not correctly marked for inclusion by the package, they are not copied over into the isolated build environment causing the error.

Appreciate the detailed issue report @jonapich !! :heart:

馃槷

Hey how about an update to the exception text to suggest this? This has been preventing me to go forward for weeks 馃槄

馃

When I add develop = true, mypy will no longer be able to locate the local imports (they're all PEP 561). Is there a known workaround? I'll dig (probably not related to poetry 馃槄 ) but asking just in case this can document a common side effect.

馃槷

Hey how about an update to the exception text to suggest this? This has been preventing me to go forward for weeks 馃槄

Sorry to hear that.

We will be able to do this , hopefully, once we drop pip and use python-build instead. Today, this error happens in a second level subprocess and the best we can do is guess the context and check for strings in stderr and wrap the exception. This is not necessarily reliable as you might already know.

That said I am happy to review any reasonable improvement to how we handle these kind of errors.

Was this page helpful?
0 / 5 - 0 ratings