我有一个需要同时支持 Python 2 和 3 的包(usignals)。在我的pyproject.toml
中,我有这个:
[tool.poetry.dependencies]
python = ">=2.7, >=3.6"
和
[tool.poetry.dev-dependencies]
ipython = [
{version = "~5", python = "~2.7"},
{version = "~7.8", python = ">=3.5"}
]
当我通过 运行 tox 时tox -rve py27
,我收到此错误:
ERROR: Package u'usignals-0.4.0' requires a different Python: 2.7.5 not in '>=3.6'
请注意,如果我指定python = "*"
,那么我得到Because usignals depends on both ipython (~5) and ipython (~7.8), version solving failed.
的也无济于事。
请注意,如果我指定python = "~2.7 || >=3.6"
,我会得到与以前相同的错误。
我究竟做错了什么?
在有人问之前,这是tox.ini
文件:
[tox]
isolated_build = true
envlist = py27, py36
# Run `pyenv global 3.7.4 system` if pyenv cannot find python2.
[testenv]
whitelist_externals = poetry
commands =
poetry install -v
poetry run pytest tests/
更详细的输出:
Resolving dependencies...
1: fact: usignals is 0.4.0
1: derived: usignals
1: fact: usignals depends on click-help-colors (^0.6.0)
1: fact: usignals depends on click (^7.0)
1: fact: usignals depends on pymysql (^0.9.3)
1: fact: usignals depends on coverage (*)
1: fact: usignals depends on pytest (*)
1: fact: usignals depends on sphinx (^1.8)
1: fact: usignals depends on sphinx (^2)
1: fact: usignals depends on ipython (~5)
1: fact: usignals depends on ipython (~7.8)
1: fact: usignals depends on bumpversion (^0.5.3)
1: fact: usignals depends on docformatter (^1.3)
1: fact: usignals depends on flake8 (^3.7)
1: fact: usignals depends on mock (^3.0)
1: fact: usignals depends on sure (^1.4)
1: fact: usignals depends on tox (^3.14)
1: fact: usignals depends on yapf (^0.28.0)
1: fact: usignals depends on pytest-colordots (^1.1)
1: fact: usignals depends on pytest-runner (^5.1)
1: fact: usignals depends on pytest-xdist (^1.30)
1: selecting usignals (0.4.0)
1: derived: pytest-xdist (^1.30)
1: derived: pytest-runner (^5.1)
1: derived: pytest-colordots (^1.1)
1: derived: yapf (^0.28.0)
1: derived: tox (^3.14)
1: derived: sure (^1.4)
1: derived: mock (^3.0)
1: derived: flake8 (^3.7)
1: derived: docformatter (^1.3)
1: derived: bumpversion (^0.5.3)
1: derived: ipython (~7.8)
1: conflict: usignals depends on ipython (~5)
1: ! not ipython (~5) is satisfied by ipython (~7.8)
1: ! which is caused by "usignals depends on ipython (~7.8)"
1: ! thus: version solving failed
1: Version solving took 0.016 seconds.
1: Tried 1 solutions.
[SolverProblemError]
Because usignals depends on both ipython (~5) and ipython (~7.8), version solving failed.