digitalocean / digitalocean/sample-functions-python-helloworld

library code for multiple python functions?

未关闭
#3 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
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?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。