python-poetry / python-poetry/poetry-plugin-bundle
[Feature Request]: Add install options (--no-root, --no-directory, --extras, …) to poetry bundle venv for Docker/CI use cases
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 151
- Forks
- 30
- Avg merge
- 48m
- Merged PRs (30d)
- 5
Description
poetry install and poetry bundle venv differ in supported options. In CI/CD pipelines and Docker multi-stage builds, this gap makes poetry bundle venv less practical than it could be.
- poetry install cannot place a virtualenv at a defined path, which complicates copying environments between builder and runtime containers.
- poetry bundle venv solves this by creating a venv in a given location — perfect for Docker caching — but it lacks key install options like --no-root, --no-directory, and --extras.
Without these flags, Docker builds are forced to reinstall all dependencies whenever the source code changes, which wastes time and bandwidth. With them, we could separate the installation of dependencies from the installation of the root package, leveraging Docker layer caching.
ARG VENV=/opt/venv
# ───────────────────────────────────────────────
# 1. Builder stage
# ───────────────────────────────────────────────
FROM python:3.13-slim-bookworm AS builder
RUN python -m pip install --upgrade pip setuptools pipx && \
pipx install poetry==2.2.0 && \
pipx inject poetry poetry-dynamic-versioning[plugin] && \
pipx inject poetry poetry-plugin-bundle
# Make sure pipx binaries are in PATH
ENV PATH="/root/.local/bin:$PATH"
# Set workdir
WORKDIR /build
# Build venv
ARG VENV
# --- Copy project definition and meta files only
# COPY pyproject.toml poetry.lock README.md ./
# --- Pre-build venv with dependencies only (cached unless deps change)
# RUN poetry bundle venv "${VENV}" --no-root
# --- Copy full source code afterwards
COPY . .
# --- Bundle again to install the project itself
RUN poetry bundle venv "${VENV}"
# ───────────────────────────────────────────────
# 2. Runtime stage
# ───────────────────────────────────────────────
FROM python:3.13-slim-bookworm AS runner
# Copy pre-built venv from builder
ARG VENV
COPY --from=builder "${VENV}" "${VENV}"
ENV PATH="${VENV}/bin:$PATH"
# Set working directory for mounted data
WORKDIR /data
# Default entrypoint
ENTRYPOINT [ "bsbs2" ]
CMD ["--help"]
This two-step pattern (dependencies first, root package later) is standard practice in Docker builds because dependencies change much less frequently than project code. With the missing flags, poetry bundle venv would fully support this pattern.
Missing but useful options
From comparing the help messages of poetry install and poetry bundle venv, these are the missing but useful options in poetry bundle venv
--no-root Do not install the root package (the current project).
--no-directory Do not install any directory path dependencies; useful to install dependencies without source code, e.g. for caching of Docker layers)
--dry-run Output the operations but do not execute anything (implicitly enables --verbose).
-E, --extras=EXTRAS Extra sets of dependencies to install. (multiple values allowed)
--all-extras Install all extra dependencies.
--all-groups Install dependencies from all groups.
--only-root Exclude all dependencies.
Related Work
There is already a PR #78 proposing to add these options. I am not deep enough in poetry and poetry bundle code to review it, but want to support this PR with this feature requestion and justification. This feature request is intended to back that work with a real-world CI/CD use case and highlight its importance for speeding up builds and reducing network usage.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing PR #78 and comparing the help output and option behavior of poetry install with poetry bundle venv. Verify the requested flags against the Docker multi-stage example; done means the listed options support the dependency-first and root-package installation workflow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100