-
Notifications
You must be signed in to change notification settings - Fork 0
Development Setup
Garot Conklin edited this page Jan 28, 2025
·
1 revision
This guide provides detailed instructions for setting up your development environment for contributing to githubauthlib.
- Python 3.6 or higher
- Git
- pip (Python package installer)
- Platform-specific requirements:
- Linux: libsecret-tools
- macOS: Xcode Command Line Tools
- Windows: Visual Studio Build Tools
Verify Python installation:
python --version # Should be 3.6 or higher
pip --version
# Fork the repository on GitHub first, then:
git clone https://github.com/YOUR_USERNAME/githubauthlib.git
cd githubauthlib
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Linux/macOS
source venv/bin/activate
# Windows
venv\Scripts\activate
# Install development dependencies
pip install -r requirements.txt
# Install the package in editable mode
pip install -e .
We use black
and isort
for code formatting:
# Format code
black githubauthlib tests
isort githubauthlib tests
Configure VS Code settings:
{
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"python.sortImports.args": ["--profile", "black"]
}
We use mypy
for static type checking:
# Run type checking
mypy githubauthlib
Configure mypy settings in setup.cfg
:
[mypy]
python_version = 3.6
warn_return_any = True
warn_unused_configs = True
disallow_untyped_defs = True
We use pytest
for testing:
# Run tests
pytest
# Run tests with coverage
pytest --cov=githubauthlib
# Run specific test file
pytest tests/test_github_auth.py
# Run tests matching pattern
pytest -k "test_token"
We use Sphinx for documentation:
# Generate documentation
cd docs
make html
Preview documentation:
# Python 3
python -m http.server -d _build/html
-
Install extensions:
- Python
- Pylance
- Python Test Explorer
- Python Docstring Generator
-
Configure settings.json:
{
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.testing.pytestEnabled": true,
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"python.analysis.typeCheckingMode": "basic"
}
-
Open project
-
Configure interpreter:
- Settings > Project > Python Interpreter
- Add > Virtual Environment > Existing
- Select
venv/bin/python
-
Configure testing:
- Settings > Tools > Python Integrated Tools
- Default test runner: pytest
# Update main branch
git checkout main
git pull origin main
# Create feature branch
git checkout -b feature/your-feature-name
# Make changes
# Run tests
pytest
# Format code
black .
isort .
# Type check
mypy githubauthlib
# Commit changes
git add .
git commit -m "feat: Add new feature"
# Push to your fork
git push origin feature/your-feature-name
- Go to GitHub
- Create Pull Request
- Fill in template
- Request review
Development-specific environment variables:
# Linux/macOS
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
export GITHUB_TOKEN="your_test_token"
# Windows PowerShell
$env:PYTHONPATH += ";$(pwd)"
$env:GITHUB_TOKEN = "your_test_token"
Install pre-commit hooks:
# Install pre-commit
pip install pre-commit
# Install hooks
pre-commit install
Configure .pre-commit-config.yaml
:
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy
Create .vscode/launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "Python: Debug Tests",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/venv/bin/pytest",
"args": [
"-v",
"tests/"
],
"console": "integratedTerminal"
}
]
}
import pdb; pdb.set_trace() # Python 3.6
breakpoint() # Python 3.7+
# All tests
pytest
# With coverage
pytest --cov=githubauthlib
# Generate coverage report
pytest --cov=githubauthlib --cov-report=html
# Generate HTML docs
cd docs
make html
# Clean and rebuild
make clean
make html
-
Update version:
githubauthlib/__init__.py
setup.py
-
Create changelog entry
-
Build distribution:
python setup.py sdist bdist_wheel
- Upload to PyPI:
twine upload dist/*
- Import errors:
# Add project root to PYTHONPATH
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
- Test discovery issues:
# Check pytest configuration
pytest --collect-only
- Documentation build errors:
# Clean build
cd docs
make clean
make html