仅安装 pep 518 构建系统要求(构建 sdist)
Install pep 518 build system requirements only (to build sdist)
PEP 518 介绍了 pyproject.toml
文件,以及描述构建所需工具的部分:
[build-system]
requires = ["setuptools", "wheel", "numpy>=1.13"]
在这里,我告诉构建系统(隐含的 setuptools)我需要安装这三个要求,然后才能 运行 构建。 (是的,我确实需要 numpy 作为 build 过程的一部分。)
当我运行 pip wheel
时,它知道在这个文件中寻找这个部分,安装要求,然后造轮子。但是 pip 无法创建 sdist
发行版(及其维护者 seem reluctant 添加一个),所以我需要 运行 python setup.py sdist
。这就是问题所在:setup.py 不知道它需要 numpy,因此构建失败。
有没有标准的方法来安装要求,然后构建 sdist?特别是pip已经走向build isolation,那么这个用isolation可以吗?如果做不到这一点,我可以创建自己的隔离环境;那么,在某些环境中安装需求的最佳方式是什么?
一种方法是使用 pypa 项目 pep517(尽管该模块被标记为“实验性”)
这是我尝试过的具有特殊依赖性的示例 dist:
# setup.py
from setuptools import setup
import astpretty
setup(name='wat', version='1')
# pyproject.toml
[build-system]
requires = ["setuptools", "wheel", "astpretty"]
build-backend = "setuptools.build_meta"
$ python -m pep517.build --source .
WARNING: You are using pip version 20.2.1; however, version 20.2.2 is available.
You should consider upgrading via the '/tmp/x/venv/bin/python -m pip install --upgrade pip' command.
running egg_info
creating wat.egg-info
writing wat.egg-info/PKG-INFO
writing dependency_links to wat.egg-info/dependency_links.txt
writing top-level names to wat.egg-info/top_level.txt
writing manifest file 'wat.egg-info/SOURCES.txt'
reading manifest file 'wat.egg-info/SOURCES.txt'
writing manifest file 'wat.egg-info/SOURCES.txt'
running sdist
running egg_info
writing wat.egg-info/PKG-INFO
writing dependency_links to wat.egg-info/dependency_links.txt
writing top-level names to wat.egg-info/top_level.txt
reading manifest file 'wat.egg-info/SOURCES.txt'
writing manifest file 'wat.egg-info/SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md
running check
warning: check: missing required meta-data: url
warning: check: missing meta-data: either (author and author_email) or (maintainer and maintainer_email) must be supplied
creating wat-1
creating wat-1/wat.egg-info
copying files to wat-1...
copying pyproject.toml -> wat-1
copying setup.py -> wat-1
copying wat.egg-info/PKG-INFO -> wat-1/wat.egg-info
copying wat.egg-info/SOURCES.txt -> wat-1/wat.egg-info
copying wat.egg-info/dependency_links.txt -> wat-1/wat.egg-info
copying wat.egg-info/top_level.txt -> wat-1/wat.egg-info
Writing wat-1/setup.cfg
Creating tar archive
removing 'wat-1' (and everything under it)
$ ls dist/
wat-1.tar.gz
你想要build。它是 Python Package Authority (PyPA) 下的项目,专为构建 PEP 517 软件包而创建。
它将构建一个 wheel 和一个 sdist。但是,您也可以告诉它只构建一个 sdist。
PEP 518 介绍了 pyproject.toml
文件,以及描述构建所需工具的部分:
[build-system]
requires = ["setuptools", "wheel", "numpy>=1.13"]
在这里,我告诉构建系统(隐含的 setuptools)我需要安装这三个要求,然后才能 运行 构建。 (是的,我确实需要 numpy 作为 build 过程的一部分。)
当我运行 pip wheel
时,它知道在这个文件中寻找这个部分,安装要求,然后造轮子。但是 pip 无法创建 sdist
发行版(及其维护者 seem reluctant 添加一个),所以我需要 运行 python setup.py sdist
。这就是问题所在:setup.py 不知道它需要 numpy,因此构建失败。
有没有标准的方法来安装要求,然后构建 sdist?特别是pip已经走向build isolation,那么这个用isolation可以吗?如果做不到这一点,我可以创建自己的隔离环境;那么,在某些环境中安装需求的最佳方式是什么?
一种方法是使用 pypa 项目 pep517(尽管该模块被标记为“实验性”)
这是我尝试过的具有特殊依赖性的示例 dist:
# setup.py
from setuptools import setup
import astpretty
setup(name='wat', version='1')
# pyproject.toml
[build-system]
requires = ["setuptools", "wheel", "astpretty"]
build-backend = "setuptools.build_meta"
$ python -m pep517.build --source .
WARNING: You are using pip version 20.2.1; however, version 20.2.2 is available.
You should consider upgrading via the '/tmp/x/venv/bin/python -m pip install --upgrade pip' command.
running egg_info
creating wat.egg-info
writing wat.egg-info/PKG-INFO
writing dependency_links to wat.egg-info/dependency_links.txt
writing top-level names to wat.egg-info/top_level.txt
writing manifest file 'wat.egg-info/SOURCES.txt'
reading manifest file 'wat.egg-info/SOURCES.txt'
writing manifest file 'wat.egg-info/SOURCES.txt'
running sdist
running egg_info
writing wat.egg-info/PKG-INFO
writing dependency_links to wat.egg-info/dependency_links.txt
writing top-level names to wat.egg-info/top_level.txt
reading manifest file 'wat.egg-info/SOURCES.txt'
writing manifest file 'wat.egg-info/SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md
running check
warning: check: missing required meta-data: url
warning: check: missing meta-data: either (author and author_email) or (maintainer and maintainer_email) must be supplied
creating wat-1
creating wat-1/wat.egg-info
copying files to wat-1...
copying pyproject.toml -> wat-1
copying setup.py -> wat-1
copying wat.egg-info/PKG-INFO -> wat-1/wat.egg-info
copying wat.egg-info/SOURCES.txt -> wat-1/wat.egg-info
copying wat.egg-info/dependency_links.txt -> wat-1/wat.egg-info
copying wat.egg-info/top_level.txt -> wat-1/wat.egg-info
Writing wat-1/setup.cfg
Creating tar archive
removing 'wat-1' (and everything under it)
$ ls dist/
wat-1.tar.gz
你想要build。它是 Python Package Authority (PyPA) 下的项目,专为构建 PEP 517 软件包而创建。
它将构建一个 wheel 和一个 sdist。但是,您也可以告诉它只构建一个 sdist。