astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.82k stars 467 forks source link

in requirements.lock `-e file:.` prevents `pip install` from resolve dependensies without pyproject.toml #1096

Closed Kanahiro closed 6 months ago

Kanahiro commented 6 months ago

Steps to Reproduce

Follow this step. https://github.com/astral-sh/rye/blob/main/docs/guide/docker.md#container-from-source

  1. build project
  2. write Dockerfile follow above instruction.
  3. docker build . -t imagename
  4. error occurs.

The error seems to be caused by line -e file:. in requirements.lock. Is it possible to disable to write this line? or other workaround?

Expected Result

Actual Result

error occurs.

 > [4/5] RUN pip install -r requirements.lock:           
0.973 Obtaining file:///. (from -r requirements.lock (line 10))                                                   
0.974 ERROR: file:///. (from -r requirements.lock (line 10)) does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.

once the line -e file:e is removed, build steps work well.

Version Info

rye 0.33.0 commit: 0.33.0 (58523f69f 2024-04-24) platform: macos (aarch64) self-python: cpython@3.12.3 symlink support: t

Stacktrace

No response

zanieb commented 6 months ago

See also discussion at https://github.com/astral-sh/uv/issues/3180

charliermarsh commented 6 months ago

Those instructions are specifically for a virtual project. Did you set virtual = true in the pyproject.toml as described?

charliermarsh commented 6 months ago

If you want to build including the current project, you have to change the Dockerfile to something like:

FROM python:slim

WORKDIR /app
COPY requirements.lock ./
COPY pyproject.toml ./
COPY README.md ./
RUN PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -r requirements.lock

COPY src .
CMD python main.py

But the steps in the docs are correct as-is. You can't include the current project (-e file:///.) as a dependency if you don't copy in the current project.

Kanahiro commented 6 months ago

Thank you for kind responses!

https://github.com/astral-sh/rye/issues/1096#issuecomment-2121062364 this works for me.