Skip to content

loresico/template-python-poetry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Python Poetry Template (Always Portable) ๐Ÿš€

Python 3.13 Poetry Portable

A professional Python project template that always uses portable Python - never relies on system installations.

โœจ Philosophy

  • ๐ŸŽฏ Always Portable - Consistent Python environment everywhere
  • ๐Ÿ“ฆ Self-Contained - No dependency on system Python
  • ๐Ÿ”„ Reproducible - Same exact Python version every time
  • ๐Ÿš€ Distributable - Package includes everything needed

๐Ÿš€ Quick Start

# 1. Clone or use this template
git clone https://github.com/yourusername/your-project
cd your-project

# 2. Run setup (downloads Python 3.13.9 first time, ~2 minutes)
./setup.sh

# 3. Activate and run
source .venv/bin/activate
python src/main.py

That's it! No system Python needed.

๐Ÿ“ Project Structure (After Setup)

your-project/
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ ci.yml            # CI/CD pipeline
โ”œโ”€โ”€ .python/                  # Portable Python 3.13.9 (~80MB, gitignored)
โ”œโ”€โ”€ .venv/                    # Virtual environment (gitignored)
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ main.py
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ test_main.py
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ CONTRIBUTING.md           # Contribution guidelines
โ”œโ”€โ”€ pyproject.toml            # Project configuration
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ QUICK_REFERENCE.md
โ”œโ”€โ”€ setup.sh         # Setup script
โ”œโ”€โ”€ poetry.lock
โ””โ”€โ”€ verify-python-version.sh  # Version checker

๐ŸŽฏ Common Commands

# Setup (first time downloads Python, subsequent runs reuse it)
./setup.sh

# If something breaks, clean rebuild
./setup.sh --force-clean

# Add a dependency
# 1. Edit pyproject.toml
# 2. Then:
poetry lock
poetry sync

๐Ÿ”ง How It Works

First Time

  1. Downloads pre-built Python 3.13.9 from python-build-standalone
  2. Installs to .python/ directory
  3. Creates virtual environment in .venv/
  4. Installs dependencies with poetry

Subsequent Runs

  1. Finds existing .python/ installation
  2. Reuses it (no download needed!)
  3. Creates fresh .venv/
  4. Installs dependencies

With --force-clean

  1. Deletes .python/, .venv/, poetry.lock
  2. Downloads Python 3.13.9 again
  3. Fresh installation

๐Ÿ’ก Why Portable Python?

System Python Portable Python
โŒ Different versions on different machines โœ… Exact same version everywhere
โŒ Might not be installed โœ… Always available
โŒ User might update it โœ… Controlled version
โŒ Dependency conflicts โœ… Self-contained
โŒ "Works on my machine" โœ… Works everywhere

๐Ÿ“Š Disk Space

  • .python/ : ~80 MB (one-time)
  • .venv/ : ~50 MB (varies by dependencies)
  • Total: ~150 MB uncompressed
  • Package: ~50 MB compressed

Small price for complete portability!

๐Ÿ› ๏ธ Development Workflow

# Day 1: Setup
./setup.sh
source .venv/bin/activate

# Daily development
python src/main.py
pytest

# Add dependencies
# Edit pyproject.toml, then:
poetry lock && poetry sync

# If weird issues
./setup.sh --force-clean

๐Ÿ“ฎ Distribution Workflow

# 1. Ensure clean build
./setup.sh --force-clean

# 2. Test your app
source .venv/bin/activate
python src/main.py

๐ŸŽจ Customization

Change Python Version

Edit setup.sh:

PYTHON_VERSION="3.14.*"  # Or any version

Available versions: https://github.com/indygreg/python-build-standalone/releases

๐Ÿ› Troubleshooting

# Virtual environment issues
rm -rf .venv/ && ./setup.sh

# Complete fresh start
./setup.sh --force-clean

# Check what you have
.python/bin/python3 --version
source .venv/bin/activate && python --version

๐Ÿ“š Documentation

โš ๏ธ Platform Compatibility

Portable Python is OS and architecture specific:

  • โœ… macOS x86_64 โ†’ macOS x86_64
  • โœ… macOS arm64 (M1/M2/M3) โ†’ macOS arm64
  • โœ… Linux x86_64 โ†’ Linux x86_64
  • โœ… Linux aarch64 โ†’ Linux aarch64
  • โŒ macOS โ†’ Linux (use Docker)
  • โŒ x86_64 โ†’ arm64 (use Docker)
  • โŒ Windows (use WSL or Docker)

๐Ÿค Contributing

Commit Message Convention

This project follows Conventional Commits for clear and structured commit history.

Format:

<type>(<scope>): <description>

[optional body]

[optional footer]

Types:

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation changes
  • style: Code style changes (formatting, no logic change)
  • refactor: Code refactoring (no feature change or bug fix)
  • perf: Performance improvements
  • test: Adding or updating tests
  • chore: Maintenance tasks (dependencies, config)
  • ci: CI/CD changes

Examples:

feat(setup): add Python 3.14 support
fix(package): correct tar.gz extraction path
docs(readme): update installation instructions
chore(deps): upgrade poetry to latest version
refactor(setup): improve error handling

Scope (optional): Component affected (setup, package, docs, etc.)

Pull Request Process

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with conventional commits
  4. Run tests and linting (pytest && black --check .)
  5. Update documentation if needed
  6. Commit your changes (git commit -m 'feat: add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request with:
    • Clear description of changes
    • Link to related issues
    • Screenshots/examples if applicable

Code Standards

  • Python Code: Follow PEP 8, use Black formatter
  • Bash Scripts: Use ShellCheck for validation
  • Documentation: Clear, concise, with examples
  • Tests: Add tests for new features

Before Submitting

# Format code
black src/ tests/

# Run linting
flake8 src/ tests/

# Run tests
pytest tests/

# Verify script works
./setup.sh --force-clean

Set Up Commit Message Template (Optional)

# Use the included commit message template
git config commit.template .gitmessage

# Now when you commit, you'll see helpful hints
git commit

See CONTRIBUTING.md for detailed guidelines.

๐Ÿ“„ License

MIT License - See LICENSE file

๐Ÿ™ Acknowledgments

๐Ÿ“ง Support


โญ If you find this template helpful, please star it!

Ready to use? Click "Use this template" above or clone and start building!