python-poetry / python-poetry/poetry

Nested development depdency overrides optional flag of main package

Open
#3,188 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

Performing the following steps leads to a lock file where an optional main package gets marked as optional = false. This is unexpected and also seems to impeded correctly identifying package for removal during poetry install --no-dev.

Reproducer
podman run --rm -i --entrypoint bash python:3.8 <<EOF
set -xe
python -m pip install -q poetry
poetry new foobar
pushd foobar
sed -i /pytest/d pyproject.toml
poetry add --optional grpcio
poetry add --dev grpcio-tools
cat poetry.lock
poetry install --no-dev
EOF
Console Output Snippets
Lock File

Note the optional flag for grpcio package.

[[package]]
name = "grpcio"
version = "1.32.0"
description = "HTTP/2-based RPC framework"
category = "main"
optional = false
python-versions = "*"

[package.dependencies]
six = ">=1.5.2"

[package.extras]
protobuf = ["grpcio-tools (>=1.32.0)"]

[[package]]
name = "grpcio-tools"
version = "1.32.0"
description = "Protobuf code generator for gRPC"
category = "dev"
optional = false
python-versions = "*"

[package.dependencies]
grpcio = ">=1.32.0"
protobuf = ">=3.5.0.post1,<4.0dev"

[[package]]
name = "protobuf"
version = "3.13.0"
description = "Protocol Buffers"
category = "dev"
optional = false
python-versions = "*"

[package.dependencies]
six = ">=1.9"

[[package]]
name = "six"
version = "1.15.0"
description = "Python 2 and 3 compatibility utilities"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"

[metadata]
lock-version = "1.1"
python-versions = "^3.8"
content-hash = "2a7da8afdc04c79ebc47003e6a50e1da2e57dd605b79e754dece9fd74042c14e"

[metadata.files]
...
Output for install --no-dev
Installing dependencies from lock file

Package operations: 0 installs, 0 updates, 2 removals

  • Removing grpcio-tools (1.32.0)
  • Removing protobuf (3.13.0)

Installing the current project: foobar (0.1.0)

You'll note that `grpcio was not removed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Podman reproducer and compare pyproject.toml with poetry.lock after adding optional grpcio and dev grpcio-tools. Inspect the dependency-locking and install paths involved in marking grpcio optional and selecting removals for poetry install --no-dev. Done means the lock file preserves grpcio's optional status and the command removes it when appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.