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

Enable --only-deps with FLIT_ALLOW_INVALID #631

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

dciborow
Copy link
Contributor

@dciborow dciborow commented Mar 12, 2023

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

@dciborow
Copy link
Contributor Author

dciborow commented Mar 12, 2023

@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)

@takluyver
Copy link
Member

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. 🤔

@pradyunsg do you have any inspiration here? 🙂

@pradyunsg
Copy link
Member

There's plans to add --only-deps to pip.

pypa/pip#11440

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

Successfully merging this pull request may close these issues.

3 participants