Skip to content

Commit 109a9f7

Browse files
First pass of refactoring using recent setuptools, typing and mypy.
1 parent 34e9f01 commit 109a9f7

22 files changed

+649
-434
lines changed

build-testpypi.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

build.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
. ./set-ex.sh
3+
4+
banner2 "Cleaning up"
5+
./clean.sh
6+
7+
banner2 "Linting"
8+
./lint.sh
9+
10+
banner2 "Testing"
11+
./test.sh
12+
13+
banner2 "Making doc"
14+
./make-doc.sh

clean.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
clean() {
6+
$1 rm -rf build/ dist/ src/*.egg-info/ $(find -name __pycache__)
7+
}
8+
9+
clean || clean sudo

examples/example.svg

Lines changed: 2 additions & 0 deletions
Loading

install-locally.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
. ./set-ex.sh
3+
4+
WHAT=umlsequence2
5+
6+
./build.sh
7+
8+
yes | pip3 uninstall $WHAT 2>/dev/null || true
9+
yes | sudo pip3 uninstall $WHAT
10+
11+
python3 setup.py build
12+
13+
sudo python3 setup.py install

lint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
MYPY_OPTS=""
5+
MYPY_OPTS+=" --warn-redundant-casts"
6+
MYPY_OPTS+=" --warn-return-any"
7+
#MYPY_OPTS+=" --warn-unreachable"
8+
MYPY_OPTS+=" --strict-equality"
9+
MYPY_OPTS+=" --strict --namespace-packages"
10+
11+
#SRCS=$(find src tests -name "*.py")
12+
SRCS=$(find src -name "*.py")
13+
mypy --ignore-missing-imports --pretty $MYPY_OPTS --no-strict-optional $SRCS

make-doc.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
. ./set-ex.sh
3+
4+
WHAT=umlsequence2
5+
6+
#OPTS=--debug
7+
OPTS=
8+
9+
for dir in doc examples; do (
10+
cd $dir
11+
12+
rm -f *.svg
13+
14+
if ls *.md; then
15+
for doc in *.md; do
16+
../$WHAT $OPTS $doc --markdown
17+
done
18+
fi
19+
20+
if ls *.umlsequence; then
21+
for doc in *.umlsequence; do
22+
../$WHAT $OPTS $doc
23+
done
24+
fi
25+
)
26+
done
27+
28+
./$WHAT README.md --markdown

build-pypi.sh renamed to publish-to-pypi.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@
1010
# https://pypi.org/manage/account/token/
1111
#
1212
# Version info: please update the file
13-
# setup.cfg
13+
# setup.py
1414
#
1515

16-
set -ex
16+
. ./set-ex.sh
1717

18-
rm -rf dist/ src/*.egg-info/
19-
python3 -m build
18+
./build.sh
19+
20+
21+
banner2 "Publishing to Pypi"
22+
23+
if [ ! -f .token ]; then
24+
echo "ERROR: please have a file named '.token' containing your pypi token"
25+
exit 1
26+
fi
27+
28+
python3 setup.py sdist
2029
python3 -m twine upload --username __token__ dist/* \
2130
--password $(cat .token) --verbose

pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
[build-system]
2-
requires = [
3-
"setuptools>=42",
4-
"wheel"
5-
]
2+
# These are the assumed default build requirements from pip:
3+
# https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
4+
requires = ["setuptools>=43.0.0", "wheel"]
65
build-backend = "setuptools.build_meta"
7-

set-ex.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Make 'set -ex' no trace 'echo' (https://superuser.com/a/1141026)
2+
set +x -e
3+
4+
shopt -s expand_aliases 2>/dev/null || true # for bash
5+
6+
_here_=$(pwd)
7+
8+
alias echo='{ save_flags="$-"; set +x; } 2>/dev/null; _echo_';
9+
_echo_() { \echo "$*"; case "$save_flags" in *x*) set -x;; esac }
10+
11+
alias banner='{ save_flags="$-"; set +x; } 2>/dev/null; _banner_';
12+
_banner_() { __banner__ "$*"; case "$save_flags" in *x*) set -x;; esac }
13+
14+
alias banner2='{ save_flags="$-"; set +x; } 2>/dev/null; _banner2_';
15+
_banner2_() { __banner2__ "$*"; case "$save_flags" in *x*) set -x;; esac }
16+
17+
alias step='{ save_flags="$-"; set +x; } 2>/dev/null; _step_';
18+
_step_() { __step__ "$*"; case "$save_flags" in *x*) set -x;; esac }
19+
20+
__banner__() {
21+
\echo
22+
\echo "######################################################################"
23+
\echo "$*"
24+
\echo "######################################################################"
25+
\echo
26+
}
27+
28+
__banner2__() {
29+
\echo
30+
\echo "----------------------------------------------------------------------"
31+
\echo "$*"
32+
\echo "----------------------------------------------------------------------"
33+
\echo
34+
}
35+
36+
__step__() {
37+
\echo
38+
\echo "==== $* ===="
39+
\echo
40+
}
41+
42+
set -ex
43+

0 commit comments

Comments
 (0)