digitalocean / digitalocean/sample-functions-python-helloworld
library code for multiple python functions?
- 主要語言
- Python
- 星號
- 33
- 分支
- 65
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Suppose we have multiple functions that would share common, library code -- I'm sure this is a very common situation.
I currently ended up writing a minimal python project inside "lib" (the python package is also, inaptly, named `lib` -- apologies). I've ended up with a structure similar to the following:
```
.
├── .env
├── .gitignore
├── lib
│ └── lib
│ ├── pyproject.toml
│ └── src
│ └── lib
│ ├── __init__.py
│ ├── db.py
│ └── rest.py
├── packages
│ └── servers
│ ├── get_servers
│ │ ├── __deployer__.zip
│ │ ├── __main__.py
│ │ ├── build.sh
│ │ └── virtualenv
│ └── put_server
│ ├── __deployer__.zip
│ ├── __main__.py
│ ├── build.sh
│ └── virtualenv
└── project.yml
```
and each function's build.sh roughly doing
```
virtualenv --without-pip virtualenv
pip install ../../../lib/lib --target virtualenv/lib/python3.9/site-packages
```
Is there a better way? Could you add an example (or alter an existing example) with how to best achieve this?
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
先檢視 project.yml 以及各函式對應的 packages/servers/get_servers/build.sh 和 put_server/build.sh 檔案,然後將它們與 lib/lib/pyproject.toml 及其 src/lib 模組進行比較。判定專案應示範哪種共用程式庫作法,並透過一個涵蓋兩個函式的範例將其記錄下來;完成的標準是新手能依照該範例建置重複使用共用程式碼的函式。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- build-system
- Issue 類型
- 文件
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100