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 in a Docker container doesn't copy the project #7126

Closed
hynek opened this issue Sep 6, 2024 · 7 comments
Closed

uv sync in a Docker container doesn't copy the project #7126

hynek opened this issue Sep 6, 2024 · 7 comments

Comments

@hynek
Copy link
Contributor

hynek commented Sep 6, 2024

Sorry for the opaque title, but since you mentioned on Discord you couldn't reproduce, so I'm just describing what I'm seeing.

I've created a minimal repro for you at https://github.com/hynek/uv-reproducer – you can start the build by running just if you've installed it.

Due to the /app/bin/python -Ic 'import tc' at the end, the build fails.

The ls on the line before looks like this:

#17 0.188 drwxr-xr-x 1 root root  192 Sep  6 13:18 .
#17 0.188 drwxr-xr-x 1 root root   26 Sep  6 13:17 ..
#17 0.188 drwxr-xr-x 1 root root   54 Sep  6 13:17 __pycache__
#17 0.188 -rw-r--r-- 1 root root    8 Sep  6 13:18 _tc.pth
#17 0.188 -rw-r--r-- 1 root root   18 Sep  6 13:17 _virtualenv.pth
#17 0.188 -rw-r--r-- 1 root root 4342 Sep  6 13:17 _virtualenv.py
#17 0.188 drwxr-xr-x 1 root root  560 Sep  6 13:17 attr
#17 0.188 drwxr-xr-x 1 root root  202 Sep  6 13:17 attrs
#17 0.188 drwxr-xr-x 1 root root   90 Sep  6 13:17 attrs-24.2.0.dist-info
#17 0.188 drwxr-xr-x 1 root root  104 Sep  6 13:18 tc-0.1.0.dist-info

So the deps sync works, but from the app pkg there's just dist-info.


If I replace:

cd /src
uv sync --frozen --no-dev

by

uv pip install \
     --python=$UV_PROJECT_ENVIRONMENT \
     --no-deps \
     /src

it works.

@zanieb
Copy link
Member

zanieb commented Sep 6, 2024

My first guess is that this is because you're doing something weird with your pyproject.toml? What is the output for the final sync?

@hynek
Copy link
Contributor Author

hynek commented Sep 6, 2024

this is the default pyproject that uv created + build-system. It's all in the repo: https://github.com/hynek/uv-reproducer/blob/main/pyproject.toml

#15 [build 7/7] RUN --mount=type=cache,target=/root/.cache <<EOT (cd /src...)
#15 0.101 + cd /src
#15 0.101 + uv sync --frozen --no-dev
#15 0.813 Prepared 1 package in 605ms
#15 0.815 Installed 1 package in 1ms
#15 0.977 Bytecode compiled 20 files in 162ms
#15 0.978  + tc==0.1.0 (from file:///src)
#15 DONE 1.0s

@zanieb
Copy link
Member

zanieb commented Sep 6, 2024

By weird, I meant that you were copying it into a _lock directory but I guess that's actually undone at COPY . /src. I now suspect that hatchling is at fault, it has some peculiar behaviors around package source detection and will happily build an empty distribution. I can look into it later using the reproduction (thanks!) but have some other priorities at this moment.

@hynek
Copy link
Contributor Author

hynek commented Sep 6, 2024

FWIW, switching [build-system] to

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

or

[build-system]
requires = ["flit_core"]
build-backend = "flit_core.buildapi"

doesn't help either.

Interestingly, the former adds a /app/lib/python3.12/site-packages/__editable__.tc-0.1.0.pth containing:

/src/src

and flit creates a /app/lib/python3.12/site-packages/tc.pth containing the same, I think except without a trailing \n.

I've also just noticed that the ls output in my first post was truncated (Docker…) so I've updated it: Hatchling creates a _tc.pth too and it also contains /src/src.

These all look like editable installs to me.


To be clear: adding /app/bin/python -Ic 'import tc' behind uv sync --frozen --no-dev does work.

HTH when this becomes a priority. The workaround is easy enough.

@zanieb
Copy link
Member

zanieb commented Sep 6, 2024

🤦 I didn't scroll down and see that there's a second layer. It looks like you're not copying the source code into the final image layer? That's why it doesn't work, since we're doing an editable install. The uv pip command you share that works doesn't use an editable install.

We're interested in adding non-editable install support (#5792) but I don't think this is intended to work as written today.

@hynek
Copy link
Contributor Author

hynek commented Sep 6, 2024

heh yeah that’s what I’ve been trying to say in discord already but my English is still limited 🙈

given there’s #5792 and it was all just a miscommunication, I guess we can close this?

@zanieb
Copy link
Member

zanieb commented Sep 6, 2024

Yeah haha let's track there. Sorry.

@zanieb zanieb closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants