将托克斯与本地依赖性一起使用

发布于 2025-02-04 18:24:26 字数 2716 浏览 4 评论 0原文

我的项目结构是以下

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我也只是我 2025-02-11 18:24:26

tox尝试创建SDIST软件包并将其安装到环境中。这失败了,因为创建sdist发生在临时目录和虚拟环境中,在此,您的相对路径依赖关系不再指向正确的位置。

您的[testenv]应该看起来像这样:

[testenv]
skip_install = true
whitelist_externals = poetry
commands =
    poetry install -v
    poetry run pytest -vvv

设置skip_install to true会告诉tox不要构建和安装包。这是不必要的,因为您使用诗歌安装

tox tries to create a sdist package and install it into the environment. This fails, because the creation of the of sdist 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:

[testenv]
skip_install = true
whitelist_externals = poetry
commands =
    poetry install -v
    poetry run pytest -vvv

Setting skip_install to true will tell tox not to build and install the package. This is unnecessary because you use poetry install.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文