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

uv sync --no-source breaking from 0.4 #7572

Closed
lambda-science opened this issue Sep 20, 2024 · 7 comments · Fixed by #7599
Closed

uv sync --no-source breaking from 0.4 #7572

lambda-science opened this issue Sep 20, 2024 · 7 comments · Fixed by #7599
Assignees
Labels
bug Something isn't working

Comments

@lambda-science
Copy link

lambda-science commented Sep 20, 2024

Hello,

My basic TOML:

[project]
name = "pythia-streamlit"
version = "0.4.0"
dependencies = [
    "numpy",
    "pythia-client>=0.6.3",
]
requires-python = ">=3.12"

[tool.uv.sources]
pythia-client = { workspace = true }

[tool.uv.workspace]
members = [
    "../pythia-client"
]

In UV 0.3.5 this worked for me:

COPY --from=ghcr.io/astral-sh/uv:0.3.5 /uv /bin/uv
ENV UV_COMPILE_BYTECODE=1
ENV UV_NO_CACHE=1
ENV PATH="/code/.venv/bin:$PATH"
# Install dependencies
WORKDIR /code
COPY pyproject.toml /code/
RUN uv sync --no-install-project --no-sources

docker build .
Output: [+] Building FINISHED

In UV 0.4.13 it doesn't work anymore:

COPY --from=ghcr.io/astral-sh/uv:0.4.13 /uv /bin/uv
ENV UV_COMPILE_BYTECODE=1
ENV UV_NO_CACHE=1
ENV PATH="/code/.venv/bin:$PATH"
# Install dependencies
WORKDIR /code
COPY pyproject.toml /code/
RUN uv sync --no-install-project --no-sources

Output:

 => ERROR [stage-0 6/8] RUN uv sync --no-install-project --no-sources                                                                                                                                                                              0.7s 
------
 > [stage-0 6/8] RUN uv sync --no-install-project --no-sources:
0.613 Using Python 3.12.6 interpreter at: /usr/local/bin/python3
0.613 Creating virtual environment at: .venv
0.620 error: Failed to build: `pythia-streamlit @ file:///code`
0.620   Caused by: Failed to parse entry for: `pythia-client`
0.620   Caused by: Package is not included as workspace package in `tool.uv.workspace`
------
Dockerfile:18
--------------------
  16 |     WORKDIR /code
  17 |     COPY pyproject.toml /code/
  18 | >>> RUN uv sync --no-install-project --no-sources
  19 |
  20 |     COPY src/pythia_streamlit /code/pythia_streamlit
--------------------
ERROR: failed to solve: process "/bin/sh -c uv sync --no-install-project --no-sources" did not complete successfully: exit code: 2

My setup is a workspace with 3 parts: two app (pythia-streamlit, pythia-api) and a python package (pythia-client). The Dockerfile snippet is coming from production image where I want to install pythia-client from Pypi. In local developement environnement I remove the --no-sources to install from local folder (from parent directory).

The update from 0.4 broke by CI/CD pipeline, because the image would not build anymore due to the error above.
Any idea why ?

@charliermarsh charliermarsh self-assigned this Sep 20, 2024
@charliermarsh
Copy link
Member

Hmm... I guess we should allow this when running with --no-sources? \cc @zanieb @konstin

@charliermarsh charliermarsh added the needs-decision Undecided if this should be done label Sep 20, 2024
@konstin
Copy link
Member

konstin commented Sep 20, 2024

This is a complicated one, because --no-sources should take the package from pypi (behaving as if it were a published package), so in this case, we should re-lock with the pypi version of the dep?

@zanieb
Copy link
Member

zanieb commented Sep 20, 2024

Yeah this seems like a bug? We should not be trying to use the source entry from the lockfile when --no-sources is provided right? Roughly agree with what @konstin is saying.

At the very least, the error message is horrible. What's the suggestion if we were to keep the existing behavior and just improve the error? To run uv lock --no-sources first?

@charliermarsh
Copy link
Member

I think there's a bug because we shouldn't even be trying to resolve the sources here (which is where the failure happens).

@charliermarsh charliermarsh added bug Something isn't working and removed needs-decision Undecided if this should be done labels Sep 20, 2024
@gita-unlearn
Copy link

@charliermarsh
Im on uv 0.4.15 and I am having the same problem

0.445 error: Failed to build: `gita-current_package` @ file:///opt/dagster/dagster_home/gita-current_package`
0.446   Caused by: Failed to parse entry for: `gita-package1`
0.446   Caused by: Package is not included as workspace package in `tool.uv.workspace`
------

 2 warnings found (use docker --debug to expand):
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 4)
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 31)
Dockerfile.backend:40
--------------------
  38 |     RUN uv sync --no-sources --python 3.11 --extra-index-url https://${PRIVATE_PYPI}
  39 |     
  40 | >>> RUN uv run pip install --no-cache-dir dagster-cloud

Weirdly the uv sync works, it is when it goes to the next RUN command that it fails

@charliermarsh
Copy link
Member

You'd have to pass --no-sources to each command (uv run --no-sources). We do not store sync "state" across commands.

@gita-unlearn
Copy link

ah okay, thank you for the quick reply <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@charliermarsh @zanieb @konstin @lambda-science @gita-unlearn and others