pythonpip

pip install --no-index can't find setuptools


I have a computer that for security reasons has no public network access. The system starts with all necessary public Python dependencies installed, I just need to add the latest version of my own python package and run. I'm trying to install my package from the .tar.gz file by pip3 --no-index; --no-index is needed because otherwise pip tries to go out to a remote repository and fails. When I run "pip3 --no-deps --no-index mypackage-1.0.0.tar.gz", given an error like:

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [2 lines of output]
      ERROR: Could not find a version that satisfies the requirement setuptools>=57 (from versions: none)
      ERROR: No matching distribution found for setuptools>=57
      [end of output]

But setuptools is there! When I run python, then "import setuptools," there it is. Version 59.6.0.

I think maybe I need to add a --find-links option to tell it where to find setuptools, but that also seems to want a .whl file, and I don't have a .whl file - just the setuptools install in /usr/lib/python3/dist-packages. I tried adding a bunch of different --find-links local paths, none helped.

Any idea how to fix this? Is the right --find-links option what I need, or do I need to download the .whl file for setup tools, or...?


Solution

  • For building packages pip uses build Isolation. I.e. it installs build dependencies into a separate virtual environment, build a package and remove the isolating venv. You don't have a wheel for setuptools to install into that transient environment so build fails.

    On a connected host download setuptools and wheel using pip download setuptools wheel, copy downloaded wheels to the offline host and run

    pip install --find-links /path/to/wheels/ --no-index mypackage
    

    Or install everything avoiding transient isolating environment:

    pip install --no-index --no-build-isolation mypackage