This is a sample to implement a multi-project structure in python by using poetry to manage dependencies and packaging of python code. Also includes make files to handle building and deployment of applications using docker images.
monorepo-demo
├── libs
│ ├── lib-one
│ │ ├── Makefile
│ │ └── pyproject.toml
│ └── logger
│ ├── Makefile
│ └── pyproject.toml
├── stack
│ ├── project-one
│ │ ├── Dockerfile
│ │ ├── Makefile
│ │ └── pyproject.toml
│ └── project-two
│ ├── Dockerfile
│ ├── Makefile
│ └── pyproject.toml
├── tools
│ ├── DockerImages.mk
│ └── PythonPackages.mk
└── README.md
Projects are either Libs (./libs) or applications (./stack).
Application specific code goes here. Each application has its own dependencies.
Shared code goes here. Each lib has its own dependencies.
- Install python3
apt install python3.9 -y - Install poetry instructions
Build
cd ../<libs||stack>/<project>
make buildClean
cd ../<libs||stack>/<project>
make cleanRebuild
cd ../<libs||stack>/<project>
make clean && make buildcd ../<libs||stack>/<project>
poetry installcd ../<libs||stack>
poetry new <project>cd ../<libs||stack>/<project>
poetry add <package>To a Library
cd ../libs/<project>
poetry add ../<lib project> -DTo an Application
cd ../stack/<project>
poetry add ./../../libs/<lib project> -D