I had this problem trying to build psycopg from source, using downloaded dependencies on an air-gapped machine.
I did this initially :
$ python3.11 -m venv tmp-venv
$ . tmp-venv/bin/activate
$ pip list
Package Version
---------- -------
pip 22.3.1
setuptools 65.5.0
$ mkdir deps
$ pip download --destination-dir=deps wheel tomli==2.0.1 backports.zoneinfo==0.2.1 typing_extensions==4.7.1 psycopg==3.1.9 psycopg-c==3.1.9
$ pip install --no-index --find-links=deps wheel tomli
I then executed
$ pip install --no-index --find-links=deps psycopg[c]
which errored out with
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [3 lines of output]
Looking in links: deps
ERROR: Could not find a version that satisfies the requirement setuptools>=49.2.0 (from versions: none)
ERROR: No matching distribution found for setuptools>=49.2.0
[end of output]
The solution, gleaned from this GitHub issue, was to add the --no-build-isolation flag so that pip
would find the setuptools
installation.
pip install --no-index --find-links=deps --no-build-isolation psycopg[c]
Build isolation is a feature of PEP518 in which the build process does not look for build-time dependencies (such as setuptools) in the local environment. The --no-build-isolation
flag disables this feature so that the local setuptools installation is used for the build.