PyInit is a CLI tool that automates the creation of a structured Python project, configuring a virtual environment (venv) or Poetry, and optionally adding a Dockerfile.
✅ Generates a structured Python project
✅ Supports both venv and Poetry
✅ Works with pipx for global installation
pipx install git+https://github.com/AlessandroBertozzi/pyinit.gitThi️s allows using pyinit globally without polluting the system.
pyinit my_project- Creates a structured project folder
- Generates a virtual environment
- Installs
pytestandblack
pyinit my_project --poetry- Initializes Poetry and adds dependencies
- Uses
pipx run poetryif Poetry isn't globally installed
pyinit my_project --docker- Generates a ready-to-use
Dockerfile
pyinit my_project --poetry --docker- Creates a fully configured project with Poetry and Docker
After running pyinit, your project will be structured as follows:
my_project/
│── venv/ # Virtual environment (if not using Poetry)
│── src/ # Source code
│ ├── __init__.py
│ ├── main.py # Main script
│── tests/ # Unit tests
│ ├── __init__.py
│── docs/ # Documentation
│── .gitignore
│── .env
│── requirements.txt # Dependencies
│── Makefile # Utility commands
│── setup.py # Package configuration
│── Dockerfile # (optional)
│── README.md
PyInit includes a pre-configured .gitignore file for Python projects:
# 🔥 Python .gitignore - Generated by PyInit
# Virtual Environments
venv/
.venv/
env/
pip-log.txt
pip-delete-this-directory.txt
# Bytecode files
__pycache__/
*.py[cod]
# Logs & Debugging
*.log
*.out
*.err
# IDE Configurations
.vscode/
.idea/
*.sublime-project
*.sublime-workspace
# macOS
.DS_Store
# Jupyter Notebook Checkpoints
.ipynb_checkpoints/
# MyPy Type Checking
.mypy_cache/
# PyTest Cache
.pytest_cache/
# Coverage Reports
htmlcov/
.coverage
.tox/
# Build Artifacts
build/
dist/
*.egg-info/
If you don't want to use pyinit, you can manually replicate the steps:
- Create a project folder and a virtual environment
mkdir my_project && cd my_project python3 -m venv venv source venv/bin/activate pip install --upgrade pip setuptools wheel pytest black
- Set up the folder structure
mkdir src tests docs touch src/__init__.py src/main.py tests/__init__.py .gitignore .env requirements.txt README.md
- (Optional) Initialize Poetry
poetry init -n poetry add pytest black
No, pyinit works even without rich, but logs will be less readable.
If you want colored logs, install it with:
pipx inject pyinit richIf installed with pipx:
pipx upgrade pyinitIf installed with pip:
pip install --upgrade pyinitpipx uninstall pyinit # If installed with pipx
pip uninstall pyinit # If installed with pipDistributed under the MIT License.
Created by Alessandro Bertozzi, inspired by the need to streamline Python project setup. 🚀