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

how to get uv to run my app on a read-only volume? #10687

Open
straz opened this issue Jan 16, 2025 · 3 comments
Open

how to get uv to run my app on a read-only volume? #10687

straz opened this issue Jan 16, 2025 · 3 comments
Labels
question Asking for clarification or support

Comments

@straz
Copy link

straz commented Jan 16, 2025

My Dockerfile implements a FastAPI web server, as follows:

...
RUN uv sync
CMD ["uv", "run", "--no-dev", "uvicorn", "myapp.main:app", "--host", "0.0.0.0", "--port", "8000"]

The /app volume is read-only for safety reasons. At startup, python imports site, whose documentation says

This module is automatically imported during initialization. The automatic import can be suppressed using the interpreter’s -S option.

site attempts to write to this path, and fails because the volume is read-only:
/app/.venv/lib/python3.11/site-packages/_myapp_back_end.pth

How do I get uv to be aware of running code on read-only volumes? Can uv suppress this by somehow calling python with the -S parameter?

@zanieb
Copy link
Member

zanieb commented Jan 16, 2025

You can probably use uv run --no-dev python -S -m uvicorn ...

It looks like there's an editable package or something writing the .pth? You could try not using an editable install or using a different build backend?

@zanieb zanieb added the question Asking for clarification or support label Jan 16, 2025
@straz
Copy link
Author

straz commented Jan 16, 2025

Thank you @zanieb . I'll try your suggestion uv run --no-dev python -S -m uvicorn ...

The .pth file is being written by site, and it's not editable.
The only configurable option apparently is to use python -S.

Is fair to suggest creating a FAQ question for how to run uv on a read-only volume? I've also figured out I need to suppress or redirect .cache.

@zanieb
Copy link
Member

zanieb commented Jan 16, 2025

.pth files are generally used to power editable dependencies, e.g., uv pip install --editable ./foo. Why is site to writing this file in the first place?

Is fair to suggest creating a FAQ question for how to run uv on a read-only volume? I've also figured out I need to suppress or redirect .cache.

I'm not sure yet. I think I need to understand more about what's going on. This isn't really a uv-specific problem.

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

2 participants