Python:如何制作诗歌包括一个不在副path上的软件包/模块?
在一个回购中,我有两个python项目都取决于共享的公用事业包。我的目标是在软件分发软件包(即.tzr.gz
文件)中打包两个项目中的每个项目),
我目前正在使用setuptools
和完成此操作。 setup.py
文件,并且很难。我宁愿使用诗歌分别管理和包装每个项目中的每个项目。
请考虑我问题的“最小再现”:
repo
project1/
__init__.py
main_module.py
pyproject.toml
project2/
__init__.py
main_module.py
pyproject.toml
util/
__init__.py
util_module.py
我试图通过修改其project1
来使诗歌包括util
软件包,通过修改其project.toml 这样:
[tool.poetry]
name = "project1"
version = "0.1.0"
description = ""
authors = [""]
packages = [
{ include = "../util/*.py" }
]
[tool.poetry.dependencies]
python = "^3.9"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
当我运行诗歌构建
时,我会得到此错误:
Building project1 (0.1.0)
- Building sdist
ValueError
'C:\\repo\\util\\__init__.py' is not in the subpath of 'C:\\repo\\project1' OR one path is relative and the other is absolute.
at ~\.pyenv\pyenv-win\versions\3.9.6\lib\pathlib.py:929 in relative_to
925│ n = len(to_abs_parts)
926│ cf = self._flavour.casefold_parts
927│ if (root or drv) if n == 0 else cf(abs_parts[:n]) != cf(to_abs_parts):
928│ formatted = self._format_parsed_parts(to_drv, to_root, to_parts)
→ 929│ raise ValueError("{!r} is not in the subpath of {!r}"
930│ " OR one path is relative and the other is absolute."
931│ .format(str(self), str(formatted)))
932│ return self._from_parsed_parts('', root if n == 1 else '',
933│ abs_parts[n:])
不 诗歌
支持我的用例?如果没有,我想念什么?
另外,请建议另一种分别包装我的两个项目的方法,但两个软件包都必须包括共享util
软件包。
I have, in a single repo, two Python projects that both depend on a shared utility package. My goal is to package each of the two projects in a software distribution package (i.e. a .tzr.gz
file)
I am currently getting this done using setuptools
and setup.py
files and having a hard time of it. I would much rather use Poetry to manage and package each of the two projects separately.
Please consider this "minimal repro" of my problem:
repo
project1/
__init__.py
main_module.py
pyproject.toml
project2/
__init__.py
main_module.py
pyproject.toml
util/
__init__.py
util_module.py
I tried to get Poetry to include the util
package when building project1
by modifying its project.toml
this way:
[tool.poetry]
name = "project1"
version = "0.1.0"
description = ""
authors = [""]
packages = [
{ include = "../util/*.py" }
]
[tool.poetry.dependencies]
python = "^3.9"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
When I run poetry build
I get this error:
Building project1 (0.1.0)
- Building sdist
ValueError
'C:\\repo\\util\\__init__.py' is not in the subpath of 'C:\\repo\\project1' OR one path is relative and the other is absolute.
at ~\.pyenv\pyenv-win\versions\3.9.6\lib\pathlib.py:929 in relative_to
925│ n = len(to_abs_parts)
926│ cf = self._flavour.casefold_parts
927│ if (root or drv) if n == 0 else cf(abs_parts[:n]) != cf(to_abs_parts):
928│ formatted = self._format_parsed_parts(to_drv, to_root, to_parts)
→ 929│ raise ValueError("{!r} is not in the subpath of {!r}"
930│ " OR one path is relative and the other is absolute."
931│ .format(str(self), str(formatted)))
932│ return self._from_parsed_parts('', root if n == 1 else '',
933│ abs_parts[n:])
Doesn't poetry
support my use-case? If not, what am I missing?
Alternatively, please suggest another approach to package my two projects separately, but both packages must include the shared util
package.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这似乎是诗歌的问题。检查一下 https://github.com/python-poetry/poetry/poetry/poetry/poetry/poetry/5621 <5621 <5621 <5621 < /a>。
This seems to be a issue with poetry. Check this out https://github.com/python-poetry/poetry/issues/5621.
UTIT本身应作为另一个Python软件包(请注意额外的pyproject.toml)
,然后按照任何其他软件包的平常添加它:
它应将其添加到
pyproject.toml
:Util itself should be built as another python package (note the extra pyproject.toml)
Then add it as you normally would with any other package:
Which should add it to
pyproject.toml
: