dev*_*tar 14 python setuptools python-packaging pyproject.toml
我有一个pyproject.toml与下面类似的 Python 项目。我用来python build生成一个用于在生产环境中安装的包。对于开发环境,我使用pip install -e .
我试图弄清楚如何确保为开发环境安装测试依赖项,而不是作为生产环境的一部分。
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[tool.setuptools]
package-dir = {"" = "src"}
packages = [
"package-a",
"package-b",
]
[tool.setuptools.package-data]
"*" = [
"path/to/*.txt"
]
[project]
name = "my-project"
version = "0.0.1"
authors = [
{ name="devnectar", email="a@b.com" },
]
description = "description goes here"
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"dep",
"another-dep",
"yet-another-dep"
]
[project.optional-dependencies]
dev = [
"tox"
]
[project.urls]
"Homepage" = "https://some_url.com"
"Bug Tracker" = "https://some_url.com"
[project.scripts]
nectarserver = "entry-point-script"
[tool.tox]
legacy_tox_ini = """
[tox]
min_version = 4.0
env_list = test_env
[testenv]
deps = pytest
commands = pytest -s
"""
Run Code Online (Sandbox Code Playgroud)
我也尝试过test,而tests不是dev试图让它发挥作用。
我遇到两个问题:
pip install -e .,tox未安装requires.txt生成的结果install最终有一个[dev]部分,这会导致pip install -r mypackage/mypackage.egg-info/requires.txt错误。这会导致我的构建链中出现其他问题,该链依赖于构建过程中生成的requirements.txt 文件来生成其中包含项目依赖项的 Docker 层。tox我应该如何捕获我的开发仅依赖于pyproject.toml?
wba*_*art 18
额外的依赖项对本地包的作用与对 PyPI 上的包的作用相同;尝试
pip install -e .[dev]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8245 次 |
| 最近记录: |