I am trying to use pyproject.toml
(and specifically setuptools_scm) in an isolated environment. My minimal pyproject.toml
is:
[build-system]
requires = ["setuptools-scm"]
[tool.setuptools_scm]
write_to = "mypackage/version.py"
However, when trying to install my package in an isolated environment, I get:
$ pip3 install --no-index -e .
Obtaining file:///home/…/myproject
Installing build dependencies ... error
error: subprocess-exited-with-error
× 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>=40.8.0 (from versions: none)
ERROR: No matching distribution found for setuptools>=40.8.0
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
However, setuptools and setuptools_scm are already installed (setuptools 66.1.1, setuptools_scm 7.1.0). There is no legacy setup.py
.
How can I ensure my package can be installed without network access (supposing that all dependencies are already resolved)?
By having built a wheel out of it, and installing the wheel on the desert island machine.
If your package is PEP 517 compliant, use
build
:You can also use
pip
to download the rest of the dependency wheels (so long as you're using the same architecture, etc. as the target machine) – e.g. for something that uses scikit-learn:Via the comments:
If you absolutely do need to build from source, either
--find-links
so Pip can install them into the isolated build environment, or--no-build-isolation
so Pip doesn't create a separate build environment, and uses the ambient build dependencies.