Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poetry install fails when directories for dependencies outside of specified dependency group do not exist #6515

Closed
3 tasks done
tobgu opened this issue Sep 14, 2022 · 7 comments
Labels
kind/question User questions (candidates for conversion to discussion) status/duplicate Duplicate issues

Comments

@tobgu
Copy link

tobgu commented Sep 14, 2022

  • 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 12.5.1

  • Poetry version: 1.2.0

Issue

I want to use dependency groups to group my dependencies into local (libraries located in the same file system as the project using them) and remote (eg. packages found on PyPI).

The main reason for doing this would be to allow me to install external packages early during docker builds and then, at a later stage copy in the local dependencies and install those. This would avoid having to re-install every external package when local packages are updated since the the docker image layer with the external packages could be reused between builds.

This does not work the way I was hoping though. Given the minimal pyproject.toml below:

[tool.poetry]
name = "foo"
version = "0.1.0"
description = ""
authors = ["Tobias Gustafsson <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"

[tool.poetry.group.local.dependencies]
bar = {path = "../../libs/bar", develop = true}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

I get the following behaviour:

$ poetry install --only main
Directory ../../libs/bar does not exist

It is true that the directory does not exist (at this stage), but I would not have expected poetry to care about it since bar is not part of the dependency group that was to be installed. Is there a good reason for this?

@tobgu tobgu added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Sep 14, 2022
@dimbleby
Copy link
Contributor

please read the docs eg per https://python-poetry.org/docs/managing-dependencies#dependency-groups

All dependencies ... will be resolved regardless of whether they are required for installation or not

@tobgu
Copy link
Author

tobgu commented Sep 14, 2022

Thanks for your quick response!

That's unfortunate for the use case I had in mind. What would the motivation be for always resolving all dependencies? Are there any other patterns that one could follow with poetry to achieve the above? I can think of a few hacky ones but if there is a nice way of doing it I'd much prefer that of course!

@dimbleby
Copy link
Contributor

I could imagine a feature that behaved as you suggest: it's just not a feature that poetry actually has.

Do whatever hacky thing you have in mind!

@neersighted neersighted added kind/question User questions (candidates for conversion to discussion) and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Sep 14, 2022
@neersighted
Copy link
Member

Poetry will always create a lock file for all platforms/install scenarios. It is possible to poetry install with a lock file if the validation was relaxed, but without a lock file Poetry would still throw the same error as it wouldn't be able to gather metadata from a missing path. Whether or not changing this to be less consistent is a good idea is debatable I think.

Regardless, I'm going to close this as I think we already have a feature request I can't find -- if you can't turn it up either feel free to open one.

@tobgu
Copy link
Author

tobgu commented Sep 15, 2022

Thanks for your prompt responses! I'll try to find a decent workaround to achieve my goals.

@neersighted
Copy link
Member

Duplicates #668 as well

@neersighted neersighted added the status/duplicate Duplicate issues label Sep 17, 2022
Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/question User questions (candidates for conversion to discussion) status/duplicate Duplicate issues
Projects
None yet
Development

No branches or pull requests

3 participants