Skip to content

Latest commit

Β 

History

History
110 lines (86 loc) Β· 2.07 KB

File metadata and controls

110 lines (86 loc) Β· 2.07 KB

Setup Python - Professional Development Project

Professional Python development setup project with best practices.

πŸš€ Environment Setup

Prerequisites

  • Python 3.8+
  • pyenv (recommended)

Installation

  1. Clone the repository (if applicable)
git clone <your-repository>
cd setup_python
  1. Create virtual environment
python3 -m venv .venv
  1. Activate virtual environment
source .venv/bin/activate
  1. Install dependencies
# Production dependencies
pip install -r requirements.txt

# Development dependencies
pip install -r requirements-dev.txt
  1. Setup pre-commit hooks
pre-commit install

πŸ—οΈ Project Structure

setup_python/
β”œβ”€β”€ .venv/                  # Virtual environment (not committed)
β”œβ”€β”€ src/                    # Source code
β”‚   └── __init__.py
β”œβ”€β”€ tests/                  # Unit tests
β”‚   └── __init__.py
β”œβ”€β”€ run.py                  # Main script
β”œβ”€β”€ requirements.txt        # Production dependencies
β”œβ”€β”€ requirements-dev.txt    # Development dependencies
β”œβ”€β”€ pyproject.toml         # Project configuration
β”œβ”€β”€ .flake8                # Flake8 configuration
β”œβ”€β”€ .pre-commit-config.yaml # Pre-commit hooks
β”œβ”€β”€ .gitignore             # Git ignored files
└── README.md              # This file

πŸ§ͺ Testing

Run tests with:

pytest

With code coverage:

pytest --cov=src --cov-report=html

🎨 Formatting and Linting

Auto-format code:

black .

Check style issues:

flake8 src tests

Static analysis with pylint:

pylint src

Type checking with mypy:

mypy src

πŸ”§ Best Practices

  1. Always activate virtual environment before working
  2. Run tests before committing
  3. Use pre-commit hooks to ensure code quality
  4. Document your functions with docstrings
  5. Keep requirements.txt updated

πŸ“ Development

To add new dependencies:

pip install <package>
pip freeze > requirements.txt