仅安装pep 518构建系统要求(构建sdist)

2024-05-28 22:43:45 发布

您现在位置:Python中文网/ 问答频道 /正文

PEP 518介绍了pyproject.toml文件,以及描述构建所需工具的部分:

[build-system]
requires = ["setuptools", "wheel", "numpy>=1.13"]

在这里,我告诉构建系统(隐式setuptools),在运行构建之前,我需要安装这三个需求。(是的,我确实需要numpy作为构建过程的一部分。)

当我运行pip wheel时,它知道在这个文件中查找这个部分,安装需求,然后构建控制盘。但是pip无法创建sdist发行版(及其维护程序seem reluctant来添加一个发行版),所以我需要运行python setup.py sdist。这就是问题所在:setup.py不知道它需要numpy,构建失败

是否有一种标准的方法来安装需求,然后构建sdist?特别是,pip已经朝着构建隔离的方向发展,所以这可以通过隔离来实现吗?如果做不到这一点,我可以创造我自己的环境来进行一些隔离;那么,在某些环境中安装需求的最佳方法是什么


Tags: pip文件工具方法pybuildnumpy环境
2条回答

一种方法是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软件包管理局(PyPA)下的项目,专门为构建PEP517软件包而创建

它将构建一个轮子和一个sdist。但是,您可以告诉它也只构建sdist

相关问题 更多 >

    热门问题