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.

"poetry build" with relative path dependency in pyproject.toml raises ValueError

See original GitHub issue
  • OS version and name: Windows 10 Pro, version 1803, build 17134.112
  • Poetry version: 0.11.0-alpha.4
  • Link of a Gist with the contents of your pyproject.toml file: pyproject.toml

Issue

Note: I:\Projects\bar-project exists, while poetry add bar-project --path ../bar-project and poetry install bar-project definitely work.

PS I:\Projects\foo-project> poetry build -vvv
Using virtualenv: I:\Projects\foo-project\.venv
Building foo-project (0.1.0)
 - Building sdist
 - Adding: rootnamespace\myapp\__init__.py
 - Adding: rootnamespace\myapp\__main__.py
 - Adding: rootnamespace\myapp\cli\__init__.py
 - Adding: rootnamespace\myapp\dependencies\__init__.py
 - Adding: rootnamespace\myapp\dependencies\c2p.py
 - Adding: rootnamespace\myapp\dependencies\constants.py
 - Adding: rootnamespace\myapp\dependencies\p2c.py
 - Adding: pyproject.toml
 - Built foo-project-0.1.0.tar.gz

[ValueError]
Directory ..\bar-project does not exist

Exception trace:
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\_vendor\cleo\application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\console\application.py in do_run() at line 87
   return super(Application, self).do_run(i, o)
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\_vendor\cleo\application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\console\commands\command.py in run() at line 72
   return super(BaseCommand, self).run(i, o)
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\_vendor\cleo\commands\base_command.py in run() at line 146
   status_code = self.execute(input_, output_)
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\_vendor\cleo\commands\command.py in execute() at line 107
   return self.handle()
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\console\commands\build.py in handle() at line 27
   builder.build(fmt)
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\masonry\builder.py in build() at line 21
   return builder.build()
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\masonry\builders\complete.py in build() at line 25
   poetry.poetry.Poetry.create(tmpdir),
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\poetry.py in create() at line 127
   package.add_dependency(name, constraint)
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\packages\package.py in add_dependency() at line 269
   develop=constraint.get("develop", False),
 C:\Users\Win10\AppData\Roaming\Python\Python36\site-packages\poetry\packages\directory_dependency.py in __init__() at line 48
   raise ValueError("Directory {} does not exist".format(self._path))

build [-f|--format FORMAT]

Changing the dependency path to an absolute path in pyproject.toml as below makes poetry build work without any errors.

...
[tool.poetry.dependencies]
python = "^3.6"
bar-project = {path = "I:/Projects/bar-project"}
toml = "^0.9.4"
pyyaml = "^4.1"
...
PS I:\Projects\foo-project> poetry build -vvv
Using virtualenv: I:\Projects\foo-project\.venv
Building playerdotme-pydevtools (0.1.0)
 - Building sdist
 - Adding: rootnamespace\myapp\__init__.py
 - Adding: rootnamespace\myapp\__main__.py
 - Adding: rootnamespace\myapp\cli\__init__.py
 - Adding: rootnamespace\myapp\dependencies\__init__.py
 - Adding: rootnamespace\myapp\dependencies\c2p.py
 - Adding: rootnamespace\myapp\dependencies\constants.py
 - Adding: rootnamespace\myapp\dependencies\p2c.py
 - Adding: pyproject.toml
 - Built foo-project-0.1.0.tar.gz

 - Building wheel
 - Adding: C:\Users\Win10\AppData\Local\Temp\tmp1nt0r_e4\foo-project-0.1.0\rootnamespace\myapp\__init__.py
 - Adding: C:\Users\Win10\AppData\Local\Temp\tmp1nt0r_e4\foo-project-0.1.0\rootnamespace\myapp\__main__.py
 - Adding: C:\Users\Win10\AppData\Local\Temp\tmp1nt0r_e4\foo-project-0.1.0\rootnamespace\myapp\cli\__init__.py
 - Adding: C:\Users\Win10\AppData\Local\Temp\tmp1nt0r_e4\foo-project-0.1.0\rootnamespace\myapp\dependencies\__init__.py
 - Adding: C:\Users\Win10\AppData\Local\Temp\tmp1nt0r_e4\foo-project-0.1.0\rootnamespace\myapp\dependencies\c2p.py
 - Adding: C:\Users\Win10\AppData\Local\Temp\tmp1nt0r_e4\foo-project-0.1.0\rootnamespace\myapp\dependencies\constants.py
 - Adding: C:\Users\Win10\AppData\Local\Temp\tmp1nt0r_e4\foo-project-0.1.0\rootnamespace\myapp\dependencies\p2c.py
 - Built foo_project-0.1.0-py3-none-any.whl

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

16reactions
kevinastonecommented, Mar 2, 2020

I ran into this today. I’d expect poetry build to allow building packages that have relative path dependencies since it has no effect on the end sdist/wheel. I’m trying to setup a monorepo with a collection of interdependent packages that I’d like to develop together, but publish independently.

This error is caused by unpacking the sdist into a temp directory which no longer has the relative path. This tmpdir is causing all relative paths to be rooted against the tempdir instead of the project root: https://github.com/kevinastone/poetry/blob/754dbf80dc022b89974288cff10b40ab2f1c2697/poetry/masonry/builders/complete.py#L53-L55

11reactions
adamalcommented, May 27, 2020

Should this issue be reopened? It was closed automatically due to inactivity but has recently seen new interest.

The way I was expecting poetry build to work when including a local dependency, say ../shared, would be to include /shared and its dependencies in the output.

A use case for this is to have local packages that are not necessarily published but could be included in several related projects.

Either way, it would be good to have this behaviour documented in more detail at https://python-poetry.org/docs/versions/#path-dependencies

Read more comments on GitHub >

github_iconTop Results From Across the Web

pip install with relative paths in poetry - Stack Overflow
I am pretty sure pip can not handle dependencies with relative paths. Absolute paths might be okay. The way I see it, pip...
Read more >
History | Poetry - Python dependency management and ...
ParseConstraintError is now raised on version and constraint parsing errors, and includes information on the package that caused the error (#514). Fix an...
Read more >
Imports from a poetry path dependency does not resolve
One project imports the other using a relative path dependency in the pyproject.toml file, like so: mylib = {path = "../mylib", develop =...
Read more >
Can Rasa support up to 1.20.0?
[tool.poetry.dependencies] python = ">=3.7,<3.9" rasa = {path ... 738│ if not self.is_absolute(): → 739│ raise ValueError("relative path ...
Read more >
Changelog — prospector documentation
Stopped the ProfileValidator tool raising errors about pep8 and pep257 ... The effort to allow pylint configuration in pyproject.toml to be used as...
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