digitalocean / digitalocean/sample-functions-python-helloworld

library code for multiple python functions?

Offen
#3 6 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
33
Forks
65
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.