Skip to content

Commit

Permalink
Pull in latest run script changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pronovic committed Oct 25, 2022
1 parent c130808 commit 370ec08
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 118 deletions.
23 changes: 14 additions & 9 deletions .run/commands/checktabs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@ command_checktabs() {

cd "$REPO_DIR" # we need to be in the root of the repo for 'git ls-files' to do what we need

git -C . rev-parse 2>/dev/null # check whether it's a Git repository
if [ $? == 0 ]; then
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
if git rev-parse --git-dir > /dev/null 2>&1; then
files="$(git ls-files | grep -v -x -F --file=".tabignore")"
if [ ! -z "$files" ]; then
result=$(grep -l "$(printf '\t')" $files)
if [ $? == 0 ]; then
echo "❌ Some files contain tab characters:"
echo ""
echo "$result"
echo ""
exit 1
fi
fi
echo "✅ No tab characters found"
else
echo "⛔ Not a Git repository, no checks run"
fi

echo "✅ No tab characters found"
echo "done"

cd - >/dev/null
}

14 changes: 14 additions & 0 deletions .run/commands/openfile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# vim: set ft=bash ts=3 sw=3 expandtab:
# Open a file in the platform-appropriate way

# Use 'start' on Windows, and 'open' on MacOS and Debian (post-bullseye)

command_openfile() {
if [ $# != 1 ]; then
echo "openfile <file>"
exit 1
fi

$(which start || which open) "$1" 2>/dev/null
}

3 changes: 1 addition & 2 deletions .run/commands/precommit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

command_precommit() {
echo -n "Installing pre-commit hooks..."
git -C . rev-parse 2>/dev/null
if [ $? == 0 ]; then
if git rev-parse --git-dir > /dev/null 2>&1; then
poetry_run pre-commit install
else
echo "not a Git repository"
Expand Down
3 changes: 1 addition & 2 deletions .run/commands/pytest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ command_pytest() {
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
run_command openfile .htmlcov/index.html
fi
else
poetry_run pytest --testdox --force-testdox $color tests
Expand Down
19 changes: 4 additions & 15 deletions .run/commands/requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
# 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
# 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.
# but it's fragile and we may eventually run into problems with it.

command_requirements() {
echo -n "Generating docs/requirements.txt..."

local replacement

run_command poetryplugin poetry-plugin-export

poetry export --format=requirements.txt --without-hashes --with dev --output=docs/requirements.txt
Expand All @@ -26,16 +23,8 @@ command_requirements() {
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 sedreplace 's|python_version >= "3\.[0-9][0-9]*"|python_version >= "3.7"|g' docs/requirements.txt
run_command sedreplace 's|python_full_version >= "3\.[0-9][0-9]*(\.[0-9][0-9]*)"|python_version >= "3.7"|g' docs/requirements.txt
run_command dos2unix docs/requirements.txt

echo "done"
Expand Down
26 changes: 26 additions & 0 deletions .run/commands/sedreplace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# vim: set ft=bash ts=3 sw=3 expandtab:
# Call sed in a platform-portable way to replace a string in-place

# Annoyingly, GNU sed and BSD sed are not compatible on the syntax for -i.

command_sedreplace() {
local replace_expr file

if [ $# != 2 ]; then
echo "sedreplace <replace-expr> <file>"
exit 1
fi

replace_expr="$1"
file="$2"

sed --version 2>&1 | grep -iq "GNU sed"
if [ $? == 0 ]; then
# GNU sed accepts a bare -i and assumes no backup file
sed -i -E "$replace_expr" "$file"
else
# BSD sed requires you to set an empty backup file extension
sed -i "" -E "$replace_expr" "$file"
fi
}

3 changes: 1 addition & 2 deletions .run/commands/sphinx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ command_sphinx() {

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
run_command openfile _build/html/index.html
fi

cd - >/dev/null
Expand Down
26 changes: 8 additions & 18 deletions .run/commands/tagrelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ command_tagrelease() {
local VERSION EARLIEST_YEAR LATEST_YEAR DEFAULT_BRANCH CURRENT_BRANCH COPYRIGHT DATE TAG FILES MESSAGE

if [ $# != 1 ]; then
echo "<version> required"
echo "tagrelease <version>"
exit 1
fi

Expand All @@ -14,15 +14,16 @@ command_tagrelease() {
LATEST_YEAR=$(git log -1 --pretty="%ci" | sed 's/-.*$//g')
DEFAULT_BRANCH=$(git config --get init.defaultBranch) # works on git > 2.28.0 from 2020
CURRENT_BRANCH=$(git branch -a | grep '^\*' | sed 's/^\* //')
DATE=$(date +'%d %b %Y')
TAG="v$VERSION" # follow PEP 440 naming convention
FILES="NOTICE pyproject.toml Changelog"
MESSAGE="Release v$VERSION to PyPI"

if [ "$EARLIEST_YEAR" == "$LATEST_YEAR" ]; then
COPYRIGHT="${EARLIEST_YEAR}"
else
COPYRIGHT="${EARLIEST_YEAR}-${LATEST_YEAR}"
fi
DATE=$(date +'%d %b %Y')
TAG="v$VERSION" # follow PEP 440 naming convention
FILES="NOTICE pyproject.toml Changelog"
MESSAGE="Release v$VERSION to PyPI"

if [ "$CURRENT_BRANCH" != "$DEFAULT_BRANCH" ]; then
echo "*** You are not on $DEFAULT_BRANCH; you cannot release from this branch"
Expand All @@ -48,19 +49,8 @@ command_tagrelease() {
fi

run_command dos2unix pyproject.toml

# annoyingly, BSD sed and GNU sed are not compatible on the syntax for -i
# I failed miserably in all attempts to put the sed command (with empty string) into a variable
sed --version 2>&1 | grep -iq "GNU sed"
if [ $? = 0 ]; then
# GNU sed accepts a bare -i and assumes no backup file
sed -i "s/^Version $VERSION\s\s*unreleased/Version $VERSION $DATE/g" Changelog
sed -i -E "s/(^ *Copyright \(c\) *)([0-9,-]+)( *Kenneth.*$)/\1$COPYRIGHT\3/" NOTICE
else
# BSD sed requires you to set an empty backup file extension
sed -i "" "s/^Version $VERSION\s\s*unreleased/Version $VERSION $DATE/g" Changelog
sed -i "" -E "s/(^ *Copyright \(c\) *)([0-9,-]+)( *Kenneth.*$)/\1$COPYRIGHT\3/" NOTICE
fi
run_command sedreplace "s/^Version $VERSION\s\s*unreleased/Version $VERSION $DATE/g" Changelog
run_command sedreplace "s/(^ *Copyright \(c\) *)([0-9,-]+)( *.*$)/\1$COPYRIGHT\3/" NOTICE

git diff $FILES

Expand Down
140 changes: 70 additions & 70 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
alabaster==0.7.12 ; python_full_version >= "3.7.2" and python_version < "4"
astroid==2.12.12 ; python_full_version >= "3.7.2" and python_version < "4"
attrs==21.4.0 ; python_full_version >= "3.7.2" and python_version < "4"
babel==2.10.3 ; python_full_version >= "3.7.2" and python_version < "4"
black==22.10.0 ; python_full_version >= "3.7.2" and python_version < "4"
cattrs==22.2.0 ; python_full_version >= "3.7.2" and python_version < "4"
certifi==2022.9.24 ; python_full_version >= "3.7.2" and python_version < "4"
cfgv==3.3.1 ; python_full_version >= "3.7.2" and python_version < "4"
charset-normalizer==2.1.1 ; python_full_version >= "3.7.2" and python_version < "4"
click==8.1.3 ; python_full_version >= "3.7.2" and python_version < "4"
colorama==0.4.5 ; python_full_version >= "3.7.2" and python_version < "4"
coverage==6.5.0 ; python_full_version >= "3.7.2" and python_version < "4"
coveralls==3.3.1 ; python_full_version >= "3.7.2" and python_version < "4"
dill==0.3.5.1 ; python_full_version >= "3.7.2" and python_version < "4"
distlib==0.3.6 ; python_full_version >= "3.7.2" and python_version < "4"
docopt==0.6.2 ; python_full_version >= "3.7.2" and python_version < "4"
docutils==0.17.1 ; python_full_version >= "3.7.2" and python_version < "4"
exceptiongroup==1.0.0rc9 ; python_full_version >= "3.7.2" and python_version < "3.11"
filelock==3.8.0 ; python_full_version >= "3.7.2" and python_version < "4"
identify==2.5.6 ; python_full_version >= "3.7.2" and python_version < "4"
idna==3.4 ; python_full_version >= "3.7.2" and python_version < "4"
imagesize==1.4.1 ; python_full_version >= "3.7.2" and python_version < "4"
importlib-metadata==5.0.0 ; python_full_version >= "3.7.2" and python_version < "3.10"
iniconfig==1.1.1 ; python_full_version >= "3.7.2" and python_version < "4"
isort==5.10.1 ; python_full_version >= "3.7.2" and python_version < "4.0"
jinja2==3.1.2 ; python_full_version >= "3.7.2" and python_version < "4"
lazy-object-proxy==1.7.1 ; python_full_version >= "3.7.2" and python_version < "4"
markupsafe==2.1.1 ; python_full_version >= "3.7.2" and python_version < "4"
mccabe==0.7.0 ; python_full_version >= "3.7.2" and python_version < "4"
mypy-extensions==0.4.3 ; python_full_version >= "3.7.2" and python_version < "4"
mypy==0.950 ; python_full_version >= "3.7.2" and python_version < "4"
nodeenv==1.7.0 ; python_full_version >= "3.7.2" and python_version < "4"
packaging==21.3 ; python_full_version >= "3.7.2" and python_version < "4"
pathspec==0.10.1 ; python_full_version >= "3.7.2" and python_version < "4"
pendulum==2.1.2 ; python_full_version >= "3.7.2" and python_version < "4"
platformdirs==2.5.2 ; python_full_version >= "3.7.2" and python_version < "4"
pluggy==1.0.0 ; python_full_version >= "3.7.2" and python_version < "4"
pre-commit==2.20.0 ; python_full_version >= "3.7.2" and python_version < "4"
py==1.11.0 ; python_full_version >= "3.7.2" and python_version < "4"
pygments==2.13.0 ; python_full_version >= "3.7.2" and python_version < "4"
pylint==2.15.5 ; python_full_version >= "3.7.2" and python_version < "4"
pyparsing==3.0.9 ; python_full_version >= "3.7.2" and python_version < "4"
pytest-testdox==3.0.1 ; python_full_version >= "3.7.2" and python_version < "4"
pytest==7.1.3 ; python_full_version >= "3.7.2" and python_version < "4"
python-dateutil==2.8.2 ; python_full_version >= "3.7.2" and python_version < "4"
pytz==2022.5 ; python_full_version >= "3.7.2" and python_version < "4"
pytzdata==2020.1 ; python_full_version >= "3.7.2" and python_version < "4"
pyyaml==6.0 ; python_full_version >= "3.7.2" and python_version < "4"
requests==2.28.1 ; python_full_version >= "3.7.2" and python_version < "4"
setuptools==65.5.0 ; python_full_version >= "3.7.2" and python_version < "4"
six==1.16.0 ; python_full_version >= "3.7.2" and python_version < "4"
snowballstemmer==2.2.0 ; python_full_version >= "3.7.2" and python_version < "4"
sphinx-autoapi==1.9.0 ; python_full_version >= "3.7.2" and python_version < "4"
sphinx==4.5.0 ; python_full_version >= "3.7.2" and python_version < "4"
sphinxcontrib-applehelp==1.0.2 ; python_full_version >= "3.7.2" and python_version < "4"
sphinxcontrib-devhelp==1.0.2 ; python_full_version >= "3.7.2" and python_version < "4"
sphinxcontrib-htmlhelp==2.0.0 ; python_full_version >= "3.7.2" and python_version < "4"
sphinxcontrib-jsmath==1.0.1 ; python_full_version >= "3.7.2" and python_version < "4"
sphinxcontrib-qthelp==1.0.3 ; python_full_version >= "3.7.2" and python_version < "4"
sphinxcontrib-serializinghtml==1.1.5 ; python_full_version >= "3.7.2" and python_version < "4"
toml==0.10.2 ; python_full_version >= "3.7.2" and python_version < "4"
tomli==2.0.1 ; python_full_version >= "3.7.2" and python_version < "4"
tomlkit==0.11.5 ; python_full_version >= "3.7.2" and python_version < "4.0"
typed-ast==1.5.4 ; python_full_version >= "3.7.2" and python_version < "3.8"
typing-extensions==4.4.0 ; python_full_version >= "3.7.2" and python_version < "4"
unidecode==1.3.6 ; python_full_version >= "3.7.2" and python_version < "4"
urllib3==1.26.12 ; python_full_version >= "3.7.2" and python_version < "4"
virtualenv==20.16.5 ; python_full_version >= "3.7.2" and python_version < "4"
wrapt==1.14.1 ; python_full_version >= "3.7.2" and python_version < "4"
zipp==3.9.0 ; python_full_version >= "3.7.2" and python_version < "3.10"
alabaster==0.7.12 ; python_version >= "3.7" and python_version < "4"
astroid==2.12.12 ; python_version >= "3.7" and python_version < "4"
attrs==21.4.0 ; python_version >= "3.7" and python_version < "4"
babel==2.10.3 ; python_version >= "3.7" and python_version < "4"
black==22.10.0 ; python_version >= "3.7" and python_version < "4"
cattrs==22.2.0 ; python_version >= "3.7" and python_version < "4"
certifi==2022.9.24 ; python_version >= "3.7" and python_version < "4"
cfgv==3.3.1 ; python_version >= "3.7" and python_version < "4"
charset-normalizer==2.1.1 ; python_version >= "3.7" and python_version < "4"
click==8.1.3 ; python_version >= "3.7" and python_version < "4"
colorama==0.4.5 ; python_version >= "3.7" and python_version < "4"
coverage==6.5.0 ; python_version >= "3.7" and python_version < "4"
coveralls==3.3.1 ; python_version >= "3.7" and python_version < "4"
dill==0.3.5.1 ; python_version >= "3.7" and python_version < "4"
distlib==0.3.6 ; python_version >= "3.7" and python_version < "4"
docopt==0.6.2 ; python_version >= "3.7" and python_version < "4"
docutils==0.17.1 ; python_version >= "3.7" and python_version < "4"
exceptiongroup==1.0.0rc9 ; python_version >= "3.7" and python_version < "3.11"
filelock==3.8.0 ; python_version >= "3.7" and python_version < "4"
identify==2.5.6 ; python_version >= "3.7" and python_version < "4"
idna==3.4 ; python_version >= "3.7" and python_version < "4"
imagesize==1.4.1 ; python_version >= "3.7" and python_version < "4"
importlib-metadata==5.0.0 ; python_version >= "3.7" and python_version < "3.10"
iniconfig==1.1.1 ; python_version >= "3.7" and python_version < "4"
isort==5.10.1 ; python_version >= "3.7" and python_version < "4.0"
jinja2==3.1.2 ; python_version >= "3.7" and python_version < "4"
lazy-object-proxy==1.7.1 ; python_version >= "3.7" and python_version < "4"
markupsafe==2.1.1 ; python_version >= "3.7" and python_version < "4"
mccabe==0.7.0 ; python_version >= "3.7" and python_version < "4"
mypy-extensions==0.4.3 ; python_version >= "3.7" and python_version < "4"
mypy==0.950 ; python_version >= "3.7" and python_version < "4"
nodeenv==1.7.0 ; python_version >= "3.7" and python_version < "4"
packaging==21.3 ; python_version >= "3.7" and python_version < "4"
pathspec==0.10.1 ; python_version >= "3.7" and python_version < "4"
pendulum==2.1.2 ; python_version >= "3.7" and python_version < "4"
platformdirs==2.5.2 ; python_version >= "3.7" and python_version < "4"
pluggy==1.0.0 ; python_version >= "3.7" and python_version < "4"
pre-commit==2.20.0 ; python_version >= "3.7" and python_version < "4"
py==1.11.0 ; python_version >= "3.7" and python_version < "4"
pygments==2.13.0 ; python_version >= "3.7" and python_version < "4"
pylint==2.15.5 ; python_version >= "3.7" and python_version < "4"
pyparsing==3.0.9 ; python_version >= "3.7" and python_version < "4"
pytest-testdox==3.0.1 ; python_version >= "3.7" and python_version < "4"
pytest==7.1.3 ; python_version >= "3.7" and python_version < "4"
python-dateutil==2.8.2 ; python_version >= "3.7" and python_version < "4"
pytz==2022.5 ; python_version >= "3.7" and python_version < "4"
pytzdata==2020.1 ; python_version >= "3.7" and python_version < "4"
pyyaml==6.0 ; python_version >= "3.7" and python_version < "4"
requests==2.28.1 ; python_version >= "3.7" and python_version < "4"
setuptools==65.5.0 ; python_version >= "3.7" and python_version < "4"
six==1.16.0 ; python_version >= "3.7" and python_version < "4"
snowballstemmer==2.2.0 ; python_version >= "3.7" and python_version < "4"
sphinx-autoapi==1.9.0 ; python_version >= "3.7" and python_version < "4"
sphinx==4.5.0 ; python_version >= "3.7" and python_version < "4"
sphinxcontrib-applehelp==1.0.2 ; python_version >= "3.7" and python_version < "4"
sphinxcontrib-devhelp==1.0.2 ; python_version >= "3.7" and python_version < "4"
sphinxcontrib-htmlhelp==2.0.0 ; python_version >= "3.7" and python_version < "4"
sphinxcontrib-jsmath==1.0.1 ; python_version >= "3.7" and python_version < "4"
sphinxcontrib-qthelp==1.0.3 ; python_version >= "3.7" and python_version < "4"
sphinxcontrib-serializinghtml==1.1.5 ; python_version >= "3.7" and python_version < "4"
toml==0.10.2 ; python_version >= "3.7" and python_version < "4"
tomli==2.0.1 ; python_version >= "3.7" and python_version < "4"
tomlkit==0.11.5 ; python_version >= "3.7" and python_version < "4.0"
typed-ast==1.5.4 ; python_version >= "3.7" and python_version < "3.8"
typing-extensions==4.4.0 ; python_version >= "3.7" and python_version < "4"
unidecode==1.3.6 ; python_version >= "3.7" and python_version < "4"
urllib3==1.26.12 ; python_version >= "3.7" and python_version < "4"
virtualenv==20.16.5 ; python_version >= "3.7" and python_version < "4"
wrapt==1.14.1 ; python_version >= "3.7" and python_version < "4"
zipp==3.9.0 ; python_version >= "3.7" and python_version < "3.10"

0 comments on commit 370ec08

Please sign in to comment.