library code for multiple python functions?

Open
#3 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
build-system

Research direction

Start by reviewing project.yml and the per-function packages/servers/get_servers/build.sh and put_server/build.sh files, then compare them with lib/lib/pyproject.toml and its src/lib modules. Determine which shared-library approach the project should demonstrate and document it with an example covering both functions; done means a newcomer can follow the example to build functions that reuse the common code.

Written by the indexing model from the issue text.

Description

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?

Dominant language
Python
Stars
33
Forks
65
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.