Skip to content

Commit

Permalink
Chapter 10: Scaling practices (#12)
Browse files Browse the repository at this point in the history
* Create codeql-analysis.yml

* Add Dependabot config

* Remove comments

* Update Dependabot config comments

* Update schedule

* Add code coverage threshold

* Add pre-commit configuration

* Add pre-commit hooks for black and flake8

* Chapter 10 project template

* Address errata
  • Loading branch information
daneah authored May 12, 2022
1 parent 2a6f5ef commit 2b90666
Show file tree
Hide file tree
Showing 22 changed files with 433 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ch03/first-python-package/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2021 <copyright holders>
Copyright © 2021 Dane Hillard

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion ch04/first-python-package/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2021 <copyright holders>
Copyright © 2021 Dane Hillard

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion ch05/first-python-package/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2021 <copyright holders>
Copyright © 2021 Dane Hillard

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion ch06/first-python-package/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2021 <copyright holders>
Copyright © 2021 Dane Hillard

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion ch07/first-python-package/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2021 <copyright holders>
Copyright © 2021 Dane Hillard

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion ch08/first-python-package/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2021 <copyright holders>
Copyright © 2021 Dane Hillard

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion ch09/first-python-package/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2021 <copyright holders>
Copyright © 2021 Dane Hillard

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
11 changes: 11 additions & 0 deletions ch10/python-package-template/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"package_distribution_name": "my-python-package",
"package_import_name": [
"{{ cookiecutter.package_distribution_name.lower().replace('-', '') }}",
"{{ cookiecutter.package_distribution_name.lower().replace('-', '_') }}"
],
"package_description": "The {{ cookiecutter.package_distribution_name }} package does amazing things.",
"package_license": ["MIT License", "BSD License", "ISC License (ISCL)", "GNU General Public License v3 (GPLv3)", "Apache Software License"],
"author_name": "First Last",
"author_email": "first@last.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# 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/
docs/reference/

# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2

sphinx:
configuration: docs/conf.py

formats:
- htmlzip

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

python:
install:
- method: pip
path: .
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
**REPLACE THIS CONTENT WITH THE LICENSE LOCATED AT THE FOLLOWING URL**:

{% if cookiecutter.package_license == 'MIT License' %}
https://opensource.org/licenses/MIT
{% elif cookiecutter.package_license == 'BSD License' %}
https://opensource.org/licenses/0BSD
{% elif cookiecutter.package_license == 'ISC License (ISCL)' %}
https://opensource.org/licenses/ISC
{% elif cookiecutter.package_license == 'GNU General Public License v3 (GLPv3)' %}
https://opensource.org/licenses/GPL-3.0
{% elif cookiecutter.package_license == 'Apache Software License' %}
https://opensource.org/licenses/Apache-2.0
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
graft src
recursive-exclude __pycache__ *.py[cod]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# {{ cookiecutter.package_distribution_name }}

This package does amazing things.

## Installation

```shell
$ python -m pip install {{ cookiecutter.package_distribution_name }}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
from importlib import metadata
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = '{{ cookiecutter.package_distribution_name }}'
copyright = '2022, Dane Hillard'
author = 'Dane Hillard'
PACKAGE_VERSION = metadata.version("{{ cookiecutter.package_distribution_name }}")
version = PACKAGE_VERSION
release = PACKAGE_VERSION


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autodoc.typehints',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']


# -- Setup for sphinx-apidoc -------------------------------------------------

# Read the Docs doesn't support running arbitrary commands like tox.
# sphinx-apidoc needs to be called manually if Sphinx is running there.
# https://github.com/readthedocs/readthedocs.org/issues/1139

if os.environ.get("READTHEDOCS") == "True":
from pathlib import Path

PROJECT_ROOT = Path(__file__).parent.parent
PACKAGE_ROOT = PROJECT_ROOT / "src" / "{{ cookiecutter.package_import_name }}"

def run_apidoc(_):
from sphinx.ext import apidoc
apidoc.main([
"--force",
"--implicit-namespaces",
"--module-first",
"--separate",
"-o",
str(PROJECT_ROOT / "docs" / "reference"),
str(PACKAGE_ROOT),
str(PACKAGE_ROOT / "*.c"),
str(PACKAGE_ROOT / "*.so"),
])

def setup(app):
app.connect('builder-inited', run_apidoc)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Welcome to {{ cookiecutter.package_distribution_name }}'s documentation!
==========================================================

{{ cookiecutter.package_description }}

.. toctree::
:maxdepth: 2
:caption: Contents:

reference/modules


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 120
target-version = ['py39', 'py310']
Loading

0 comments on commit 2b90666

Please sign in to comment.