如何在同一個 monorepo 中的 Python 項目之間共享開發依賴項? (how to share dev-dependencies between Python projects within the same monorepo?)


問題描述

如何在同一個 monorepo 中的 Python 項目之間共享開發依賴項? (how to share dev‑dependencies between Python projects within the same monorepo?)

我有兩個這樣的monorepos:

.
├── monorepo1/
│   ├── apps/
│   │   ├── app1/
│   │   └── app2/
│   └── libs/
│       ├── lib1/
│       └── lib2/
└── monorepo2/
    ├── apps/
    │   ├── app3/
    │   └── app4/
    └── libs/
        ├── lib3/
        └── lib4/

每個monorepo包含appslibs,其中包含python包。

我想為同一個 monorepo 共享 dev‑dependencies,但我沒有找到辦法。我正在使用 Poetry 來管理 Python 包依賴項。

  • 使用 poetry add ‑D 只會安裝 dev‑dependencies 在那個 Python 包(ege app1)中。
  • 將包安裝為 全局包 將影響其他 monorepos。

我怎樣才能在monorepo1中一次性安裝開發依賴?

此外,我正在使用 VSCode,並為每個 python 項目設置 settings.json 以使用其自己的 python 環境。例如:

// monorepo1/apps/app1/.vscode/settings.json
{
  "python.pythonPath": ".venv/bin/python",
}

我怎樣才能找到monorepo的dev‑dependencies(例如pytest / pylint / black / ipykernel...) 而不為同一個 monorepo 中的每個 python 項目安裝這些開發依賴項?


參考解法

方法 1:

You cannot do this. poetry's philosophy is to separate each project. But there are some thoughts about how to support subpackages. See https://github.com/python‑poetry/poetry/issues/2270

(by Xaree Leefinswimmer)

參考文件

  1. how to share dev‑dependencies between Python projects within the same monorepo? (CC BY‑SA 2.5/3.0/4.0)

#Python #monorepo #python-poetry






相關問題

如何從控制台中導入的文件中訪問變量的內容? (How do I access the contents of a variable from a file imported in a console?)

在 python 3.5 的輸入列表中添加美元符號、逗號和大括號 (Adding dollar signs, commas and curly brackets to input list in python 3.5)

為 KeyError 打印出奇怪的錯誤消息 (Strange error message printed out for KeyError)

django 1.9 中的 from django.views.generic.simple import direct_to_template 相當於什麼 (What is the equivalent of from django.views.generic.simple import direct_to_template in django 1.9)

查詢嵌入列表中的數組 (Querying for array in embedded list)

如何在 Python 中搜索子字符串是否在二進製文件中? (How to search if a substring is into a binary file in Python?)

為什麼要避免 while 循環? (Why avoid while loops?)

使用python的json模塊解析json請求 (Parse a json request using json module of python)

為什麼使用 py2app 模塊創建 mac 文件時出現錯誤? (Why i am getting Error when creating mac file using py2app module?)

當 python 線程在網絡調用(HTTPS)中並且發生上下文切換時會發生什麼? (What happens when the python thread is in network call(HTTPS) and the context switch happens?)

如何繪製一條帶斜率和一個點的線?Python (How to plot a line with slope and one point given? Python)

Pickle 找不到我不使用的模塊? (Pickle can't find module that I am not using?)







留言討論