将托克斯与本地依赖性一起使用
我的项目结构是以下
py/
├─ projects/
│ ├─ project1/
│ │ ├─ ...
│ │ ├─ pyproject.toml
│ │ ├─ tox.ini
├─ libs/
│ ├─ lib1/
│ │ ├─ ...
│ │ ├─ pyproject.toml
py/project/project1/pyproject.toml 是类似
[tool.poetry.dependencies]
...
lib1 = {path = "../../libs/lib1" }
py/project/project 1/tox.ini 这样的东西
[tox]
isolated_build = True
envlist = py3
minversion = 3.24.4
requires = setuptools >= 60.1.0
[testenv]
whitelist_externals = poetry
commands =
poetry install -v
poetry run pytest -vvv
。在开发和运行期间,但我无法进行测试工作。运行命令诗歌运行tox
时,我得到以下错误
.package recreate: ...
.package installdeps: poetry-core>=1.0.0
py3 recreate: ...
py3 inst: ...
ERROR: invocation failed (exit code 1), logfile: ....
============================================================================================================== log start ===============================================================================================================
Processing ./.tox/.tmp/package/1/project1-1.0.0.tar.gz
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
Traceback (most recent call last):
...
self.create_dependency(name, constraint, root_dir=package.root_dir)
File "/tmp/pip-build-env-nmn7y8qz/overlay/lib/python3.10/site-packages/poetry/core/factory.py", line 244, in create_dependency
dependency = DirectoryDependency(
File "/tmp/pip-build-env-nmn7y8qz/overlay/lib/python3.10/site-packages/poetry/core/packages/directory_dependency.py", line 41, in __init__
raise ValueError("Directory {} does not exist".format(self._path))
ValueError: Directory ../../libs/lib1 does not exist
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
WARNING: You are using pip version 22.0.4; however, version 22.1.2 is available.
You should consider upgrading via the ...
是否有人知道如何强制托克斯安装本地依赖关系?非常感谢!
my project structure is the following
py/
├─ projects/
│ ├─ project1/
│ │ ├─ ...
│ │ ├─ pyproject.toml
│ │ ├─ tox.ini
├─ libs/
│ ├─ lib1/
│ │ ├─ ...
│ │ ├─ pyproject.toml
py/projects/project1/pyproject.toml is something like this
[tool.poetry.dependencies]
...
lib1 = {path = "../../libs/lib1" }
py/projects/project1/tox.ini is something like this
[tox]
isolated_build = True
envlist = py3
minversion = 3.24.4
requires = setuptools >= 60.1.0
[testenv]
whitelist_externals = poetry
commands =
poetry install -v
poetry run pytest -vvv
Everything is working fine during development and run, but I cannot make the testing work. When running the command poetry run tox
I got the following error
.package recreate: ...
.package installdeps: poetry-core>=1.0.0
py3 recreate: ...
py3 inst: ...
ERROR: invocation failed (exit code 1), logfile: ....
============================================================================================================== log start ===============================================================================================================
Processing ./.tox/.tmp/package/1/project1-1.0.0.tar.gz
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
Traceback (most recent call last):
...
self.create_dependency(name, constraint, root_dir=package.root_dir)
File "/tmp/pip-build-env-nmn7y8qz/overlay/lib/python3.10/site-packages/poetry/core/factory.py", line 244, in create_dependency
dependency = DirectoryDependency(
File "/tmp/pip-build-env-nmn7y8qz/overlay/lib/python3.10/site-packages/poetry/core/packages/directory_dependency.py", line 41, in __init__
raise ValueError("Directory {} does not exist".format(self._path))
ValueError: Directory ../../libs/lib1 does not exist
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
WARNING: You are using pip version 22.0.4; however, version 22.1.2 is available.
You should consider upgrading via the ...
Does anyone know how to force tox to install local dependencies? Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
tox
尝试创建SDIST
软件包并将其安装到环境中。这失败了,因为创建sdist
发生在临时目录和虚拟环境中,在此,您的相对路径依赖关系不再指向正确的位置。您的
[testenv]
应该看起来像这样:设置
skip_install
totrue
会告诉tox
不要构建和安装包。这是不必要的,因为您使用诗歌安装
。tox
tries to create asdist
package and install it into the environment. This fails, because the creation of the ofsdist
takes place in a temporary directory and virtual environment, where your relative path dependency does not point to the correct location anymore.Your
[testenv]
should look like this instead:Setting
skip_install
totrue
will telltox
not to build and install the package. This is unnecessary because you usepoetry install
.