-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
22 changed files
with
433 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
133 changes: 133 additions & 0 deletions
133
ch10/python-package-template/{{cookiecutter.package_distribution_name}}/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
17 changes: 17 additions & 0 deletions
17
ch10/python-package-template/{{cookiecutter.package_distribution_name}}/.readthedocs.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: . |
13 changes: 13 additions & 0 deletions
13
ch10/python-package-template/{{cookiecutter.package_distribution_name}}/LICENSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
2 changes: 2 additions & 0 deletions
2
ch10/python-package-template/{{cookiecutter.package_distribution_name}}/MANIFEST.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
graft src | ||
recursive-exclude __pycache__ *.py[cod] |
9 changes: 9 additions & 0 deletions
9
ch10/python-package-template/{{cookiecutter.package_distribution_name}}/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | ||
``` |
88 changes: 88 additions & 0 deletions
88
ch10/python-package-template/{{cookiecutter.package_distribution_name}}/docs/conf.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
18 changes: 18 additions & 0 deletions
18
...thon-package-template/{{cookiecutter.package_distribution_name}}/docs/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
7 changes: 7 additions & 0 deletions
7
ch10/python-package-template/{{cookiecutter.package_distribution_name}}/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
Oops, something went wrong.