Skip to content

Commit

Permalink
Chapter 8: Authoring and maintaining documentation (#7)
Browse files Browse the repository at this point in the history
* Start chapter 8 changes

* Start GitHub Actions workflow for chapter 8

* Start Sphinx docs

* Add Python .gitignore files to previous chapters

* Start autodoc

* Remove unneeded port

* Update sphinx-apidoc usage

* Add some minor documentation

* Try dynamic sphinx-apidoc approach for RTD

* Fix pathing

* Add typehints extension

* Add Read the Docs configuration file

* Copy Read the Docs configuration to repo root

* Fix formats value

* Fix formats value

* Fix Python version syntax

* Try updated build.os

* Update install path in root config

* Update root config

* Add return type hint for main

* Move files to officially supported name

* Fix types

* Check untyped defs

* Trigger new build

* Add package version
  • Loading branch information
daneah authored Feb 10, 2022
1 parent 3d72885 commit c428184
Show file tree
Hide file tree
Showing 28 changed files with 1,324 additions and 4 deletions.
152 changes: 152 additions & 0 deletions .github/workflows/ch08-packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Packaging (chapter 8)

on:
- push

jobs:
format:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install tox
run: python -m pip install tox

- name: Run black
run: tox -e format
working-directory: ch08/first-python-package # You don't need this in your package

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install tox
run: python -m pip install tox

- name: Run flake8
run: tox -e lint
working-directory: ch08/first-python-package # You don't need this in your package

typecheck:
name: Type check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install tox
run: python -m pip install tox

- name: Run mypy
run: python -m tox -e typecheck
working-directory: ch08/first-python-package # You don't need this in your package

test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
python:
- version: "3.10"
toxenv: "py310"
- version: "3.9"
toxenv: "py39"
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python.version }}

- name: Install tox
run: python -m pip install tox

- name: Run pytest
run: tox -e ${{ matrix.python.toxenv }}
working-directory: ch08/first-python-package # You don't need this in your package

build_source_dist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install build
run: python -m pip install build

- name: Run build
run: python -m build --sdist
working-directory: ch08/first-python-package # You don't need this in your package

- uses: actions/upload-artifact@v2
with:
path: ch08/first-python-package/dist/*.tar.gz

build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macOS-10.15]

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.3.1

- name: Build wheels
run: python -m cibuildwheel --output-dir wheels
working-directory: ch08/first-python-package # You don't need this in your package

- uses: actions/upload-artifact@v2
with:
path: ./ch08/first-python-package/wheels/*.whl # Update to match root of package

""" Avoid double-publishing from other workflows
publish:
name: Publish package
if: startsWith(github.event.ref, 'refs/tags/v')
needs:
- format
- lint
- typecheck
- test
- build_source_dist
- build_wheels
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: ./ch08/first-python-package/dist # Update to match root of package
- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: ./ch08/first-python-package/dist/ # You don't need this in your package
"""
17 changes: 17 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2

sphinx:
configuration: ch08/first-python-package/docs/conf.py

formats:
- htmlzip

build:
os: ubuntu-20.04
tools:
python: "3.10"

python:
install:
- method: pip
path: ch08/first-python-package
132 changes: 132 additions & 0 deletions ch03/first-python-package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Compiled extensions
*.c
Loading

0 comments on commit c428184

Please sign in to comment.