构建以下
pyproject.toml
时:
[build-system]
requires = [ "poetry-core",]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "sigfig"
version = "1.3.6"
description = "Python library for rounding numbers (with expected results)"
authors = [ "Michael Busuttil <[email protected]>", "Travis Valdez <[email protected]>",]
maintainers = [ "Michael Busuttil <[email protected]>",]
readme = "README.rst"
license = "MIT License"
keywords = [ "round", "rounding", "significant figures", "significant digits", "sigfigs", "sigdigs", "decimals", "uncertainty", "uncertainties", "numeric", "numerical", "number", "numbers", "data", "format", "style", "publication",]
classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Financial and Insurance Industry", "Intended Audience :: Healthcare Industry", "Intended Audience :: Other Audience", "Intended Audience :: Manufacturing", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Operating System :: OS Independent", "Topic :: Education", "Topic :: Education :: Computer Aided Instruction (CAI)", "Topic :: Office/Business :: Financial", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Scientific/Engineering :: Mathematics", "Topic :: Scientific/Engineering :: Physics", "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities",]
[tool.poetry.urls]
Homepage = "https://sigfig.readthedocs.io/"
Documentation = "https://sigfig.readthedocs.io/"
Repository = "https://github.com/drakegroup/sigfig.git"
Issues = "https://github.com/drakegroup/sigfig/issues"
[tool.poetry.dependencies]
python = "^3.11"
sortedcontainers = "^2.4.0"
[tool.poetry.group.dev.dependencies]
semver = "^3.0.2"
pyyaml = "^6.0.1"
requests = "^2.31.0"
toml = "^0.10.2"
numpy = "^1.26.2"
coverage = "^7.3.2"
click = "^8.1.7"
coverage-badge = "^1.1.2"
sphinx = "^8.1.3"
sphinx-rtd-theme = "^3.0.1"
twine = "^5.1.1"
build = "^1.2.2.post1"
与
poetry run python -m build
包信息元数据表明所需的 Python 版本是
>=3.11
,正如您所期望的那样。
$ tar xfO dist/sigfig-1.3.6.tar.gz sigfig-1.3.6/PKG-INFO | grep Requires-Python
Requires-Python: >=3.11,<4.0
但是,当 pip 允许时,
sigfig
包仍然适用于那些使用低至 3.6 版本的 Python 的用户。 Python 3.11 只是一个开发依赖项,而不是一个使用/核心依赖项。
为了在 PKG-INFO 元数据中传达这一点,我尝试将
requires-python = ">= 3.6"
放入 [tool.poetry]
部分
[tool.poetry]
requires-python = ">= 3.6"
构建时失败。
$ poetry run python -m build
The Poetry configuration is invalid:
- Additional properties are not allowed ('requires-python' was unexpected)
我还尝试在
[tool.poetry.dependencies]
和 [tool.poetry.group.dev.dependencies]
部分指定不同的 Python 版本
[tool.poetry.dependencies]
python = "^3.6"
[tool.poetry.group.dev.dependencies]
python = "^3.11"
但是诗歌无法正常发挥作用
$ poetry lock
Updating dependencies
Resolving dependencies... (0.6s)
The current project's Python requirement (>=3.6,<4.0) is not compatible with some of the required packages Python requirement:
- build requires Python >=3.8, so it will not be satisfied for Python >=3.6,<3.8
有人知道如何告诉 pip 任何 Python >=3.6 的用户都可以使用这个包吗?
达到预期结果的一种有点hacky的方法如下:
python = "^3.6"
的
[tool.poetry.dependencies]
部分设置
pyproject.toml
[tool.poetry.dependencies]
python = "^3.6"
$ poetry run python -m build
$ poetry run twine upload dist/*
python
的
[tool.poetry.dependencies]
部分中的
pyproject.toml
[tool.poetry.dependencies]
python = "^3.11"