jazzband / pip-tools

A set of tools to keep your pinned Python dependencies fresh.
https://pip-tools.rtfd.io
BSD 3-Clause "New" or "Revised" License
7.69k stars 610 forks source link

Simple piptools compile failing #1946

Open kevinlinxc opened 1 year ago

kevinlinxc commented 1 year ago

This is a reproducible build that will fail. It is not pip-tools fault, but I still want to know how to get around it.

Make a Dockerfile with this:

FROM python:3.8.10-alpine

COPY . .

RUN python -m pip install pip-tools

RUN python -m piptools compile --verbose --generate-hashes --output-file=requirements.txt requirements.in

Have a requirements.in file in the same directory with

matplotlib==3.7.2

This creates an error because a wheel can't be built because certain things are missing. This might be solvable in Docker by using apt/apt-get to install things, but my actual application is on Windows, where fixing these issues are tricky. On this reproduction, numpy has the problem, on Windows, Contourpy has the problem. Is there any insight for how to fix this kind of issue? It's preventing me from using pip-compile.

atugushev commented 1 year ago

Unfortunately, when there is no wheel for a package, there's not much to do other than satisfy build requirements. The same issue will occur with other package managers too (pipenv/poetry/etc).

kevinlinxc commented 1 year ago

In other scenarios, I would do a separate pip install with --only-binary to deal with some problematic packages, but with pip-compile I have no low-level control over what is happening. Is there a way to specify that binaries are preferred but only for a few packages?

atugushev commented 1 year ago

You can use --pip-args option: pip-compile --pip-args "--only-binary :all:"

kevinlinxc commented 1 year ago

Thanks, that looks useful. Another problem though: Cython 3.0 release broke a few packages, so they need to be installed separately with --no-build-isolation like so: https://github.com/yaml/pyyaml/issues/724#issuecomment-1638636728

Is there any way to pip compile in stages to allow for this?

atugushev commented 1 year ago

Does pip-compile --no-build-isolation work for you?

kevinlinxc commented 1 year ago

I don't want all packages to have no build isolation, just the few that rely on unpinned Cython. I will test this out tomorrow though.