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

Subsequent poetry install fails with transitive path dependencies via git subdir dependency #10194

Open
WBSemple opened this issue Feb 17, 2025 · 2 comments
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@WBSemple
Copy link

Description

Poetry fails to correctly install when it has a transitive path dependency via a git subdirectory dependency.

Same as this closed issue #8765; the example is taken from there and modified to run poetry install twice.

It seems poetry is resolving the path of the transitive namespace-lib relative to the root directory of the poetry-managed virtualenv, whereas it should be resolving the path relative to the subdirectory of the git dependency.

It appears to succeed on first install, but breaks on any subsequent attempts with the message Directory /usr/lib for namespace-lib does not seem to be a Python package (or more often Path <path> for <package> does not exist in cases when the incorrectly resolved path doesn't correspond to an existing dir).

Workarounds

Remove the current env and start fresh for every install/sync

Poetry Installation Method

pip

Operating System

macos 14.1.2 + debian 12 (6.12.9-200.fc41.aarch64)

Poetry Version

2.1.1

Poetry Configuration

cache-dir = "/root/.cache/pypoetry"
data-dir = "/root/.local/share/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
python.installation-dir = "{data-dir}/python"  # /root/.local/share/pypoetry/python
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /root/.cache/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

No response

Example pyproject.toml

[project]
name = "example"
requires-python = "~3.10"

[tool.poetry]
requires-poetry = "^2.0"
package-mode = false

[tool.poetry.dependencies]
namespace-cli = {git = "https://github.com/adriangb/python-monorepo.git",  subdirectory = "poetry/workspaces/cli", rev = "9bb66f4"}

Poetry Runtime Logs

Reproduce with:

podman run --rm -i --entrypoint bash python:3.10 <<EOF
set -xe
python -m pip install --disable-pip-version-check --root-user-action ignore -q poetry

cat > pyproject.toml <<TOML
[project]
name = "example"
requires-python = "~3.10"

[tool.poetry]
requires-poetry = "^2.0"
package-mode = false

[tool.poetry.dependencies]
namespace-cli = {git = "https://github.com/adriangb/python-monorepo.git",  subdirectory = "poetry/workspaces/cli", rev = "9bb66f4"}
TOML

poetry install
poetry install
EOF

Output:

+ python -m pip install --disable-pip-version-check --root-user-action ignore -q poetry
+ cat
+ poetry install
Creating virtualenv example-il7asoJj-py3.10 in /root/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...

Package operations: 12 installs, 0 updates, 0 removals

  - Installing dnspython (2.7.0)
  - Installing idna (3.10)
  - Installing typing-extensions (4.12.2)
  - Installing annotated-types (0.7.0)
  - Installing email-validator (2.2.0)
  - Installing pydantic-core (2.27.2)
  - Installing commonmark (0.9.1)
  - Installing pydantic (2.10.6)
  - Installing pygments (2.19.1)
  - Installing namespace-lib (0.0.0 /root/.cache/pypoetry/virtualenvs/example-il7asoJj-py3.10/src/python-monorepo/poetry/workspaces/lib)
  - Installing rich (12.6.0)
  - Installing namespace-cli (0.0.0 9bb66f4)

Writing lock file
+ poetry install
Installing dependencies from lock file
Directory /usr/lib for namespace-lib does not seem to be a Python package

Directory /usr/lib for namespace-lib does not seem to be a Python package
@WBSemple WBSemple added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Feb 17, 2025
@WBSemple WBSemple changed the title subsequent poetry install fails with transitive path dependencies via git subdir Subsequent poetry install fails with transitive path dependencies via git subdir Feb 17, 2025
@WBSemple WBSemple changed the title Subsequent poetry install fails with transitive path dependencies via git subdir Subsequent poetry install fails with transitive path dependencies via git subdir dependency Feb 17, 2025
@dimbleby
Copy link
Contributor

as I said in the other one - I don't think this should be expected to work

@WBSemple
Copy link
Author

WBSemple commented Feb 17, 2025

as I said in the other one - I don't think this should be expected to work

If so, it would be nice to make this explicit through validation/error messaging.

It would also provide a helpful workaround if poetry supported overriding such transitive path dependencies. Currently, if the library is required explicitly as follows, it causes a dependency resolution error pointing to a version clash between the top-level and the transitive namespace-lib.

[tool.poetry.dependencies]
namespace-cli = {git = "https://github.com/adriangb/python-monorepo.git",  subdirectory = "poetry/workspaces/cli", rev = "9bb66f4"}
namespace-lib = {git = "https://github.com/adriangb/python-monorepo.git",  subdirectory = "poetry/workspaces/lib", rev = "9bb66f4"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants