python - Install Python package from monorepo
问题描述
We have a private git monorepo which hosts a number of Python packages. Poetry was the dependency management tool initially chosen for the project. Anyway, due to this Poetry issue, it would not be accepted solution that involves creating new setup.py
files.
A simplified version of the structure:
git-monorepo
├── pkg-1
│ ├── pkg
│ │ └── mod1.py
│ └── pyproject.toml
├── pkg-2
│ ├── pkg
│ │ └── mod2.py
│ └── pyproject.toml
└── lib
├── pkg
│ └── lib.py
└── pyproject.toml
The library distribution package lib
is indepentent from any other package. However, pkg-1
depends on lib
and pkg-2
depends on both pkg-1
and lib
.
So, the question is:
How would be the proper way to use pip
to install a package from this monorepo?
Let us consider as an example that we try to install pkg-1
, where pkg-1/pyproject.toml
includes the following lines:
...
[tool.poetry.dependencies]
lib = {path = "../lib/"}
...
The result from running pip
, as explained in the VCS support documentation:
$ pip install -e git+https://gitlab.com/my-account/git-monorepo#"egg=pkg-1&subdirectory=pkg-1"
Traceback (most recent call last):
File "/home/hblanco/.local/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3101, in __init__
super(Requirement, self).__init__(requirement_string)
File "/home/hblanco/.local/lib/python3.8/site-packages/pip/_vendor/packaging/requirements.py", line 115, in __init__
raise InvalidRequirement("Invalid URL: {0}".format(req.url))
pip._vendor.packaging.requirements.InvalidRequirement: Invalid URL: ../lib
解决方案
推荐阅读
- sql - 如何在 SSIS 中将多列映射到单列
- python - 用于从 python 中的字符串中提取所有复杂日期格式的正则表达式
- c++ - 为什么找不到这些符号?
- latex - 如何使用某种引用或诸如 \input "formula1" 之类的东西在乳胶中插入公式
- elixir - 如何使用 Stripe-Elixir 捕获和存储用户的电子邮件
- arrays - 使用转置函数会导致错误
- machine-learning - Watson 深度学习:实验构建器、命令行界面和 Python 客户端 - 成熟度和功能
- ios - 将 fastlane 与使用通知扩展的应用程序一起使用
- ios - Xcode 9 将 P3 PDF 资源渲染为 SRGB
- php - PHP函数中的不知情参数