Files
copyparty/scripts/make-pypi-release.sh

107 lines
1.7 KiB
Bash
Raw Normal View History

2019-06-01 15:55:21 +00:00
#!/bin/bash
set -e
echo
# osx support
2020-05-06 01:02:28 +02:00
command -v gtar >/dev/null &&
command -v gfind >/dev/null && {
tar() { gtar "$@"; }
sed() { gsed "$@"; }
find() { gfind "$@"; }
sort() { gsort "$@"; }
}
2019-06-01 15:55:21 +00:00
which md5sum 2>/dev/null >/dev/null &&
md5sum=md5sum ||
md5sum="md5 -r"
mode="$1"
2020-01-19 16:12:59 +01:00
[ -z "$mode" ] &&
2019-06-01 15:55:21 +00:00
{
2020-01-19 16:12:59 +01:00
echo "need argument 1: (D)ry, (T)est, (U)pload"
2019-06-01 15:55:21 +00:00
echo
exit 1
}
2020-01-19 16:12:59 +01:00
[ -e copyparty/__main__.py ] || cd ..
[ -e copyparty/__main__.py ] ||
2019-06-01 15:55:21 +00:00
{
echo "run me from within the copyparty folder"
echo
exit 1
}
# one-time stuff, do this manually through copy/paste
true ||
{
cat > ~/.pypirc <<EOF
[distutils]
index-servers =
pypi
pypitest
[pypi]
2020-01-19 16:12:59 +01:00
repository: https://upload.pypi.org/legacy/
username: qwer
password: asdf
2019-06-01 15:55:21 +00:00
[pypitest]
repository: https://test.pypi.org/legacy/
2020-01-19 16:12:59 +01:00
username: qwer
password: asdf
2019-06-01 15:55:21 +00:00
EOF
# set pypi password
chmod 600 ~/.pypirc
sed -ri 's/qwer/username/;s/asdf/password/' ~/.pypirc
2019-06-02 14:16:53 +00:00
# if PY2: create build env
cd ~/dev/copyparty && virtualenv buildenv
2020-01-19 16:12:59 +01:00
(. buildenv/bin/activate && pip install twine)
2019-06-02 14:16:53 +00:00
# if PY3: create build env
cd ~/dev/copyparty && python3 -m venv buildenv
2020-01-19 16:12:59 +01:00
(. buildenv/bin/activate && pip install twine wheel)
2019-06-01 15:55:21 +00:00
}
pydir="$(
which python |
sed -r 's@[^/]*$@@'
)"
2020-01-19 16:12:59 +01:00
[ -e "$pydir/activate" ] &&
2019-06-01 15:55:21 +00:00
{
echo '`deactivate` your virtualenv'
exit 1
}
function have() {
python -c "import $1; $1; $1.__version__"
}
. buildenv/bin/activate
have setuptools
have wheel
2020-01-19 16:12:59 +01:00
have twine
2019-06-01 15:55:21 +00:00
./setup.py clean2
./setup.py sdist bdist_wheel --universal
2020-01-19 16:12:59 +01:00
[ "$mode" == t ] && twine upload -r pypitest dist/*
[ "$mode" == u ] && twine upload -r pypi dist/*
2019-06-01 15:55:21 +00:00
cat <<EOF
all done!
to clean up the source tree:
cd ~/dev/copyparty
./setup.py clean2
EOF