Used projen and poetry in a submodule in a few roles and found it really usefull for standardising repo setup so Ive set one up to use myself.
A reusable submodule template for bootstrapping Python Poetry projects using Projen
Results in a repo that looks like this https://github.com/JimHBeam/testrepo
Assuming poetry is installed already.
-
Install Projen globally
npm install -g projen
-
Create and initialize your project
mkdir my-project && cd my-project git init
-
Add this repo as a Git submodule
git submodule add --name projen-submodule -b main ../projen-submodule projen-submodule
-
Run the setup script
./projen-submodule/projen-init.sh
this will add projen as a deve dep and setup ".projenrc.projdata.json" file in the root
-
Create your project config
Edit your
.projenrc.projdata.jsonfile in the root directory:{ "name": "pencil_pusher", "version": "1.0.0", "description": "Pushes pencils.", "deps": [ "boto3@^1.18", ], "dev_deps": [ "bandit@*" ] }🔍 Note on advanced dependencies:
Complex dependencies must be JSON-escaped:
"apache-airflow@{ extras = [\"celery\", \"postgres\", \"redis\", \"rabbitmq\"], version = \"*\" }" -
Run it
poetry install poetry run python3 .projenrc.py
my-project/
├── .github/
│ ├── ISSUE_TEMPLATE/new-issue-template.md
│ └── workflows/
│ ├── on-push.yml
│ ├── dependabot-build-transfer.yml
│ └── dependabot-auto-merge.yml
├── src/
│ └── main.py
├── tests/
│ └── test_example.py
├── .projenrc.py (symlink from submodule)
├── .projenrc.projdata.json (your config)
├── Makefile
├── pyproject.toml
├── poetry.lock
├── .gitignore
├── .flake8
├── mypy.ini
🔧 Files marked with * in the original repo are managed by Projen and regenerated automatically when .projenrc.py runs.
- 🧰 Built-in dev tools:
black,flake8,mypy,bandit - ✅ GitHub Actions CI for testing and releases
- 🛠️ Handy Make targets:
make installmake testmake buildmake publishmake fixstylemake lint