Professional Python development setup project with best practices.
- Python 3.8+
- pyenv (recommended)
- Clone the repository (if applicable)
git clone <your-repository>
cd setup_python- Create virtual environment
python3 -m venv .venv- Activate virtual environment
source .venv/bin/activate- Install dependencies
# Production dependencies
pip install -r requirements.txt
# Development dependencies
pip install -r requirements-dev.txt- Setup pre-commit hooks
pre-commit installsetup_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
Run tests with:
pytestWith code coverage:
pytest --cov=src --cov-report=htmlAuto-format code:
black .Check style issues:
flake8 src testsStatic analysis with pylint:
pylint srcType checking with mypy:
mypy src- Always activate virtual environment before working
- Run tests before committing
- Use pre-commit hooks to ensure code quality
- Document your functions with docstrings
- Keep requirements.txt updated
To add new dependencies:
pip install <package>
pip freeze > requirements.txt