pyproject.toml 在隔离环境中

问题描述 投票:0回答:1

我正在尝试在隔离环境中使用

pyproject.toml
(特别是 setuptools_scm)。我的最小
pyproject.toml
是:

[build-system]
requires = ["setuptools-scm"]

[tool.setuptools_scm]
write_to = "mypackage/version.py"

但是,当尝试在隔离环境中安装我的包时,我得到:

$ 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.

但是,已经安装了setuptools和setuptools_scm(setuptools 66.1.1,setuptools_scm 7.1.0)。没有遗产

setup.py
.

如何确保我的包可以在没有网络访问的情况下安装(假设所有依赖项都已经解决)?

python setuptools pyproject.toml setuptools-scm
1个回答
0
投票

如何确保我的包可以在没有网络访问的情况下安装(假设所有依赖项都已经解决)?

通过用它建造一个,并将轮子安装在荒岛机器上。

如果您的包裹符合 PEP 517 标准,请使用

build

(buildbox) $ pip install build
(buildbox) $ python -m build .
# whisk dist/*.whl to your isolated machine
(isolated) $ pip install ./*.whl

您还可以使用

pip
下载其余的依赖轮(只要您使用与目标机器相同的体系结构等)——例如对于使用 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

通过评论:

如果你绝对需要从源代码构建,要么

  • 将开发依赖项作为轮子运送并使用
    --find-links
    以便 Pip 可以将它们安装到隔离的构建环境中,或者
  • set
    --no-build-isolation
    所以 Pip 不会创建单独的构建环境,而是使用环境构建依赖项。
© www.soinside.com 2019 - 2024. All rights reserved.