flit
flit copied to clipboard
Enable --only-deps with FLIT_ALLOW_INVALID
Currently, trying to run "flit install --only-deps" includes checks that require both the README and the module folder be present, even though they are not actually needed. When trying to use --only-deps in my docker file, I have to also copy the README and have to create a fake directory.
FROM mcr.microsoft.com/devcontainers/python:3
RUN python -m pip install --upgrade pip \
&& python -m pip install 'flit>=3.8.0'
ENV FLIT_ROOT_INSTALL=1
COPY pyproject.toml README.rst ./
RUN mkdir -p flit \
&& python -m flit install --only-deps --deps develop \
&& rm -r pyproject.toml README.rst flit
flit already includes a flag to try and install if there are invalid settings, FLIT_ALLOW_INVALID. I have extended the use of that flag to enable running --only-deps without the checks. The updated Dockerfile becomes.
FROM mcr.microsoft.com/devcontainers/python:3
RUN python -m pip install --upgrade pip \
&& python -m pip install 'flit>=3.8.1'
ENV FLIT_ROOT_INSTALL=1
ENV FLIT_ALLOW_INVALID=1
COPY pyproject.toml .
RUN python -m flit install --only-deps --deps develop \
&& rm -r pyproject.toml
@takluyver , have made some updates so that I can use FLIT_ALLOW_INVALID to run flit install --only-deps with just a pyproject.toml. (particularly for building Docker containers)
Hi @dciborow, sorry it's taken me a while to look at this.
I see what you're after, but this feels like the wrong approach to me. Flit is meant to work with a package, and crucial files being missing is not the same thing as metadata that Flit thinks is invalid. The FLIT_ALLOW_INVALID environment variable is basically meant as an 'escape hatch' for bugs in Flit's validation, which is why the docs say:
If you need to use it and you believe your metadata is valid, please open an issue.
Maybe --only-deps should use a separate code path which doesn't look at these things in the first place. Maybe it should even be a separate tool, not tied to Flit - it could be just a few lines, reading requirements in the standard format from pyproject.toml and passing them to pip. Perhaps it should even be part of pip itself - like it can read a requirements.txt file, perhaps it should also allow a list of requirements from TOML. :thinking:
@pradyunsg do you have any inspiration here? :slightly_smiling_face:
There's plans to add --only-deps to pip.
https://github.com/pypa/pip/issues/11440