Pip ignores --find-links for numpy

I want to build numpy from sources and then build package of my project with aforementioned numpy
what I am doing:

## create venv
$(TARGET_PYTHON_VERSION) -m venv $(VENV_DIR)
$(VENV_PIP) install pip==$(TARGET_PIP_VERSION)
$(VENV_PIP) install setuptools==$(TARGET_SETUPTOOLS_VERSION) wheel==$(TARGET_WHEEL_VERSION)

## build numpy wheel
wget https://github.com/cython/cython/releases/download/0.29.31/Cython-0.29.31-py2.py3-none-any.whl
$(VENV_PIP) install Cython-0.29.31-py2.py3-none-any.whl
git clone --depth 1 --branch v$(NUMPY_VERSION) https://github.com/numpy/numpy.git
cd numpy && $(VENV_PIP) wheel --wheel-dir $(WHEELS_DIR) --platform manylinux_2_12_x86_64 . && cd ..

## build other in-house dependencies
mkdir -p $(WHEELS_DIR)
$(VENV_PYTHON) setup.py egg_info
cat admin_backend.egg-info/requires.txt \
    | sed -nE 's/^([a-zA-Z0-9_-]+)[>=~]?.*$$/\1/p' \
    | xargs -I'{}' echo $(LIBS_DIR)/'{}' \
    | xargs -I'{}' sh -c '[ -d "{}" ] && echo "{}" || true' \
    | xargs $(VENV_PIP) wheel --wheel-dir $(WHEELS_DIR) --no-deps

## gather all dependencies in $(PACKAGES_DIR)
mkdir -p $(PACKAGES_DIR)
$(VENV_PIP) --no-cache-dir wheel --prefer-binary --find-links $(WHEELS_DIR) --wheel-dir $(PACKAGES_DIR) $(ROOT_DIR)

## make package archive
cd $(PACKAGES_DIR) && tar czvf $(BUILD_ARCHIVE_FILE) .

during the step ## gather all dependencies in $(PACKAGES_DIR) pip installs numpy from pypi however $(WHEELS_DIR) contains numpy wheel of specified version

I have not reproduced your problem, but I suspect that pip is gathering numpy when setting up an isolated build environment.

If that’s the case, pip does not pass all install arguments down to the build time gathering of requirements.

There are two general approaches to this situation:

  1. Export your options up as environmental variables: Configuration - pip documentation v24.1.2, so that when pip is installing into the isolated build environment it reads those same environmental variables.
  2. Installing the required packages into your environment first and using the --no-isolated-build flag, pip will then not need to create an isolated build environment

Depending on your specific situation and constraints will determine which option is best for you.