-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
798 additions
and
742 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Run the black code formatter | ||
|
||
command_black() { | ||
echo "Running black formatter..." | ||
poetry_run black "$@" . | ||
echo "done" | ||
} | ||
|
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,21 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Check for tab characters in the source tree | ||
|
||
command_checktabs() { | ||
echo "Checking for tab characters..." | ||
|
||
cd "$REPO_DIR" # we need to be in the root of the repo for 'git ls-files' to do what we need | ||
|
||
result=$(grep -l "$(printf '\t')" $(git ls-files | grep -v -x -F --file=".tabignore")) | ||
if [ $? == 0 ]; then | ||
echo "❌ Some files contain tab characters" | ||
echo "${result}" | ||
exit 1 | ||
fi | ||
|
||
echo "✅ No tab characters found" | ||
echo "done" | ||
|
||
cd - >/dev/null | ||
} | ||
|
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,10 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Disable the Python keyring | ||
|
||
# This prevents Poetry v1.2.0 from using the Python keyring, which sometimes fails or hangs on Linux. | ||
# See: https://github.com/python-poetry/poetry/issues/2692#issuecomment-1235683370 | ||
|
||
command_disablekeyring() { | ||
export PYTHON_KEYRING_BACKEND="keyring.backends.null.Keyring" | ||
} | ||
|
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,9 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Enable the Python keyring | ||
|
||
# We need to unset this for cases where the keyring is required, like publishing | ||
|
||
command_enablekeyring() { | ||
unset PYTHON_KEYRING_BACKEND | ||
} | ||
|
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 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Run the isort import formatter | ||
|
||
command_isort() { | ||
echo "Running isort formatter..." | ||
poetry_run isort --color "$@" . | ||
echo "done" | ||
} | ||
|
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 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Make sure that the latest code is installed | ||
|
||
command_latestcode() { | ||
poetry install --only-root >/dev/null | ||
if [ $? != 0 ]; then | ||
echo "*** Failed to install the latest code" | ||
exit 1 | ||
fi | ||
} | ||
|
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 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Run the MyPy code checker | ||
|
||
# We generate relative paths in the output to make integration with Pycharm work better | ||
|
||
command_mypy() { | ||
echo "Running mypy checks..." | ||
poetry_run mypy --hide-absolute-path "$@" | ||
echo "done" | ||
} | ||
|
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 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Install pre-commit hooks | ||
|
||
command_precommit() { | ||
echo -n "Installing pre-commit hooks..." | ||
poetry_run pre-commit install >/dev/null | ||
echo "done" | ||
} | ||
|
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,28 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Publish the current tagged code to PyPI and push to GitHub | ||
|
||
# Before doing this, you must retrieve and configure a local API token | ||
# For instance: poetry config pypi-token.pypi token --local | ||
# See: https://python-poetry.org/docs/repositories/#configuring-credentials | ||
|
||
command_publishpypi() { | ||
run_command enablekeyring # or we can't get the token from the keyring | ||
|
||
poetry build | ||
if [ $? != 0 ]; then | ||
echo "*** Build step failed." | ||
exit 1 | ||
fi | ||
|
||
poetry publish | ||
if [ $? != 0 ]; then | ||
echo "*** Publish step failed." | ||
exit 1 | ||
fi | ||
|
||
git push --follow-tags | ||
if [ $? != 0 ]; then | ||
exit 1 | ||
fi | ||
} | ||
|
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 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Run the Pylint code checker | ||
|
||
# We generate relative paths in the output to make integration with Pycharm work better | ||
|
||
command_pylint() { | ||
echo "Running pylint checks..." | ||
TEMPLATE="{path}:{line}:{column} - {C} - ({symbol}) - {msg}" | ||
poetry_run pylint --msg-template="$TEMPLATE" -j 0 "$@" $(ls -d src/*) tests | ||
echo "done" | ||
} |
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,40 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Run the pytest unit tests, optionally with coverage | ||
|
||
command_pytest() { | ||
coverage="no" | ||
html="no" | ||
|
||
while getopts ":ch" option; do | ||
case $option in | ||
c) | ||
coverage="yes" | ||
;; | ||
h) | ||
html="yes" | ||
;; | ||
?) | ||
echo "invalid option -$OPTARG" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
color="" | ||
if [ "$GITHUB_ACTIONS" == "true" ] && [ "$RUNNER_OS" == "Windows" ]; then | ||
color="--color no" # color messes up the terminal on Windows in GHA | ||
fi | ||
|
||
if [ $coverage == "yes" ]; then | ||
poetry_run coverage run -m pytest --testdox --force-testdox $color tests | ||
poetry_run coverage report | ||
if [ $html == "yes" ]; then | ||
# Use 'start' on Windows, and 'open' on MacOS and Debian (post-bullseye) | ||
poetry_run coverage html -d .htmlcov | ||
$(which start || which open) .htmlcov/index.html 2>/dev/null | ||
fi | ||
else | ||
poetry_run pytest --testdox --force-testdox $color tests | ||
fi | ||
} | ||
|
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,46 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Generate a requirements.txt file in the docs directory, for use by readthedocs.io | ||
|
||
# Unfortunately, we can't just rely on Poetry here. Poetry wants to generate a | ||
# file that includes our project's lowest compatible version of Python, but | ||
# readthedocs.io can only build with older versions (v3.7 as of this writing, | ||
# even though it's years out of date). So, we need to modify the generated | ||
# result to make readthedocs.io happy. | ||
# | ||
# The "solution" is to replace whatever lowest python version Poetry generated | ||
# with "3.7", and hope for the best. That seems to have been working so far, | ||
# but we may eventually run into a dependency that simply doesn't exist for | ||
# Python 3.7. | ||
|
||
command_requirements() { | ||
echo -n "Generating docs/requirements.txt..." | ||
|
||
poetry self add --quiet poetry-plugin-export | ||
if [ $? != 0 ]; then | ||
echo "" | ||
echo "*** Failed to install Poetry plugin: poetry-plugin-export" | ||
exit 1 | ||
fi | ||
|
||
poetry export --format=requirements.txt --without-hashes --with dev --output=docs/requirements.txt | ||
if [ $? != 0 ]; then | ||
echo "" | ||
echo "*** Failed to export docs/requirements.txt" | ||
exit 1 | ||
fi | ||
|
||
REPLACEMENT='s|python_version >= "3\.[0-9][0-9]*"|python_version >= "3.7"|g' | ||
sed --version 2>&1 | grep -iq "GNU sed" | ||
if [ $? = 0 ]; then | ||
# GNU sed accepts a bare -i and assumes no backup file | ||
sed -i "$REPLACEMENT" docs/requirements.txt | ||
else | ||
# BSD sed requires you to set an empty backup file extension | ||
sed -i "" "$REPLACEMENT" docs/requirements.txt | ||
fi | ||
|
||
run_command dos2unix docs/requirements.txt | ||
|
||
echo "done" | ||
} | ||
|
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,29 @@ | ||
# vim: set ft=bash ts=3 sw=3 expandtab: | ||
# Build the Sphinx documentation for readthedocs.io | ||
|
||
command_sphinx() { | ||
open="no" | ||
|
||
while getopts ":o" option; do | ||
case $option in | ||
o) | ||
open="yes" | ||
;; | ||
?) | ||
echo "invalid option -$OPTARG" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
cd docs | ||
|
||
poetry_run sphinx-build -N -E -a -b html -d _build/doctrees . _build/html 2>&1 | grep -v -F --file=.sphinxignore | ||
if [ $open == "yes" ]; then | ||
# Use 'start' on Windows, and 'open' on MacOS and Debian (post-bullseye) | ||
$(which start || which open) _build/html/index.html 2>/dev/null | ||
fi | ||
|
||
cd - >/dev/null | ||
} | ||
|
Oops, something went wrong.