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)?
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
:
(buildbox) $ pip install build
(buildbox) $ python -m build .
# whisk dist/*.whl to your isolated machine
(isolated) $ pip install ./*.whl
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:
$ pip download ./*.whl
Saved /scikit_learn-1.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Saved /joblib-1.2.0-py3-none-any.whl
Saved /numpy-1.24.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Saved /scipy-1.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Saved /threadpoolctl-3.1.0-py3-none-any.whl
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.