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

Install library in editable mode in dev, but from a private repo in prod #12309

Open
andrej-peterka opened this issue Mar 19, 2025 · 0 comments
Labels
question Asking for clarification or support

Comments

@andrej-peterka
Copy link

Question

Hi,

I'm developing a couple of scripts (tool_01, tool_02) that depend on a common library (lib_common).
Everything is developed by me and I have a private repo to where I publish the library.

Final step is building my tool_01 as a docker image and publishing it to a docker registry.

This is my folder structure:

lib_common
|-- README.md
|-- pyproject.toml
|-- src
|   `-- lib_common
|       |-- __init__.py
|       |-- py.typed
|       `-- my_code
|           |-- __init__.py
`-- uv.lock

tool_01
|-- Dockerfile
|-- README.md
|-- pyproject.toml
|-- src
|   |-- docker-entrypoint.py
|   `-- tool.py
`-- uv.lock

The lib_common and tool_01 folders are in the same folder, one next to the other.

tool_01 includes lib_common as a dependency:

[project]
name = "tool-01"
version = "0.1.0"
classifiers = [
    "Private :: Do Not Upload"
]
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
    "requests~=2.32.3",
    "lib-common==0.1.0",
]

[tool.uv.sources]
lib-common = [
    { index = "private-repo" }
]

[[tool.uv.index]]
name = "private-repo"
url = "https://.../simple/"
explicit = true

And this works, no issues.

The question I have is how can I develop lib-common and have the changes be reflected in the tool_01 project without building, publishing and re-instaling the lib-common?

I know that installing lib-common in editable mode is the solution, but how can I incorporate that into the pyproject.toml and the lock file?

I tried adding this to the tool_01 pyproject.toml:

[dependency-groups]
dev = [
    "lib-common",
]

[tool.uv.sources]
lib-common = [
    { path = "../lib_common", editable = true, group = "dev" },
    { index = "private-repo" }
]

But then my docker build of the tool_01 fails with error:

0.481 Using CPython 3.13.2 interpreter at: /usr/local/bin/python3
0.482 Creating virtual environment at: .venv
0.525 error: Failed to determine installation plan
0.525   Caused by: Distribution not found at: file:///lib_common

which makes sense, since that folder is not present in my docker build - I want it to use the package from my private repo there.

Dockerfile:

ARG BUILD_PLATFORM=linux/amd64
FROM --platform=${BUILD_PLATFORM} ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder

ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_PYTHON_DOWNLOADS=0

WORKDIR /src

RUN --mount=type=bind,source=uv.lock,target=uv.lock \
    --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
    uv sync --frozen --no-install-project --no-dev

ADD src/ /src/

FROM --platform=${BUILD_PLATFORM} python:3.13-slim AS final

# Copy the application from the builder
COPY --from=builder /src /src

# Place executables in the environment at the front of the path
ENV PATH="/src/.venv/bin:$PATH"

I saw some related issues, but after reading through them, I'm not sure what the solution to my question is...

#9654
#11104
#11363
#11675

Platform

macOS, docker, linux

Version

uv 0.6.7

@andrej-peterka andrej-peterka added the question Asking for clarification or support label Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

1 participant