如何在构建过程中正确附加诗歌依赖性?

发布于 2025-02-08 15:21:32 字数 1388 浏览 2 评论 0原文

我有以下诗歌设置:

- libs
  - notreal
    - pyproject.toml
    - notreal
      - __init__.py
      - main.py
- services
  - one
    - pyproject.toml
    - one
      - __init__.py
      - main.py

在一个/main.py中,我正在做以下操作:

from notreal.main import main as notrealfunc

def main():
    notrealfunc()


if __name__ == '__main__':
    main()

pyproject.toml

[tool.poetry]
name = "one"
version = "0.1.0"
description = ""
authors = ["Bob Ross <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.9"
notreal = {path = "./notreal-0.1.0-py3-none-any.whl"}

[tool.poetry.dev-dependencies]
pytest = "^5.2"
notreal = {path = "../../libs/notreal"}

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

在我运行诗歌运行python service_one/main.py时,它的工作原理预期的。

问题来自当我使用诗歌构建构建项目时,然后尝试从setup.py文件运行安装步骤。它无法正确安装轮子文件。

当服务构建CMD创建A /DIST目录时,我会从库的构建输出到服务的 /区域将车轮文件复制。

输出的读者是这样的:

 Invalid URL: notreal-0.1.0-py3-none-any.whl

我已经对此进行了一些研究,似乎可以通过将依赖关系更改为DEV依赖关系并使用诗歌运行来解决。不过,我不想要这个,因为我打算在没有诗歌的情况下发货。

这样就把我带到了我的问题。我该如何正确执行此操作?我基本上是在尝试让单声道回购与诗歌合作。可以在没有安装诗歌的情况下包装和使用仓库的建造。

I have a poetry setup like the following:

- libs
  - notreal
    - pyproject.toml
    - notreal
      - __init__.py
      - main.py
- services
  - one
    - pyproject.toml
    - one
      - __init__.py
      - main.py

Within one/main.py, I am doing the following:

from notreal.main import main as notrealfunc

def main():
    notrealfunc()


if __name__ == '__main__':
    main()

where the pyproject.toml is

[tool.poetry]
name = "one"
version = "0.1.0"
description = ""
authors = ["Bob Ross <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.9"
notreal = {path = "./notreal-0.1.0-py3-none-any.whl"}

[tool.poetry.dev-dependencies]
pytest = "^5.2"
notreal = {path = "../../libs/notreal"}

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

When I run poetry run python service_one/main.py, it works as expected.

The issue comes from when I build the project with poetry build, then try to run the installation step from the setup.py file. It does not correctly install the wheel file.

When the service build cmd creates a /dist directory, I do copy over the wheel file from the build output of the library to the /dist of the service.

The output reads as such:

 Invalid URL: notreal-0.1.0-py3-none-any.whl

I have done some research on this, where it appears that this can be resolved by changing the dependency to a dev dependency and running the package with poetry run. I do not want this though, as I plan to ship the application without poetry.

So that brings me to my question. How can I do this correctly? I am basically trying to get a mono repo working with poetry. Where the build of the repo can be packaged and used without poetry installed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

聽兲甴掵 2025-02-15 15:21:32

做到这一点的一种方法是首先将您的notreal软件包发布到PYPI注册表,然后在软件包一个中更新版本。

notreal = {path = "../../libs/notreal"}

当您发布时,提供这样的路径将无法正常工作。

One way to do this would be to first publish your notreal package to pypi registry then update the version in package one.

notreal = {path = "../../libs/notreal"}

giving path like this wont work when u publish it is only meant for local use.

梦冥 2025-02-15 15:21:32

跳过诗歌生成的设置的用法,然后直接安装本地轮毂文件。之后,它应该使用python -m One.main运行

Skip the usage of setup.py generated by poetry, and install the local wheel files directly. After that, it should run with python -m one.main

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