Install required tools:
Create a virtual environment:
python -m venv env
source env/bin/activate
pip install pytest sphinx
Create the package structure:
mypackage/
__init__.py
core.py
Write basic module code:
Write tests:
tests/
test_
test_core.py
Run tests:
pytest
Setup Sphinx:
sphinx-quickstart
Document your code:
docs/
Build the documentation:
make html
Initialize Git repository:
git init
.gitignore
env/
*.pyc
__pycache__/
Commit and push your changes:
git add .
git commit -m "Initial commit"
git remote add origin [your-repository-url]
git push -u origin main
Create GitHub Actions workflow:
.github/workflows/
python-package.yml
Set up actions for documentation and deployment:
Tag a release:
git tag v1.0.0
git push --tags
Publish on Test PyPI:
pyproject.toml
python -m twine upload --repository testpypi dist/*
See https://github.com/pcafrica/python_package_example/.