Skip to content

Commit

Permalink
Update PyPI packager
Browse files Browse the repository at this point in the history
  • Loading branch information
mbourqui committed May 25, 2020
1 parent 6d579e3 commit 3e1380f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions pypi_packager.sh
Expand Up @@ -20,19 +20,19 @@
# converts a README.md to README.rst for nice rendering on PyPI.
#author :https://github.com/mbourqui
#licence :GNU GPL-3.0
#date :20200523
#version :1.2.3
#date :20200525
#usage :bash pypi_packager.sh
#requires :pandoc
#==============================================================================

PROGRAM_NAME=$(basename "$0")
VERSION=1.2.3
VERSION=1.3.0
PROJECT_NAME=$(basename $(pwd))
PACKAGE_NAME=${PROJECT_NAME//-/_} # Replace all - with _
WHEEL_PKG_NAME=${PROJECT_NAME//-/_} # Replace all - with _
PACKAGE_NAME=${PROJECT_NAME#"django-"}

copyright() {
echo "$PROGRAM_NAME Copyright (C) 2017-2020 Marc Bourqui"
echo "$PROGRAM_NAME Copyright (C) 2017-2020 Marc Bourqui $PACKAGE_NAME"
}

usage() {
Expand All @@ -45,18 +45,19 @@ conditions, see <http://www.gnu.org/licenses/> for details.
Script to build source distribution and wheel for a python package. Also
converts a README.md to README.rst thanks to pandoc for nice rendering on PyPI.
Usage: $PROGRAM_NAME [-h,--help,-v,--version] [-s,--submit|-t,--test]
Usage: $PROGRAM_NAME [-h,--help,-v,--version] [-t,--test|-s,--submit [--no-tag]]
Options:
-s, --submit upload the package to PyPI.
-t, --test upload the package to TestPyPI.
--no-tag do not tag the git commit, only effective on --submit
-h, --help display this help and exit
-v, --version output version information and exit"
}

# Parse arguments
TEMP=$(getopt -n $PROGRAM_NAME -o sthv --long submit,test,help,version -- "$@")
TEMP=$(getopt -n $PROGRAM_NAME -o sthv --long no-tag,submit,test,help,version -- "$@")

if [ $? != 0 ] ; then usage >&2 ; exit 1 ; fi

Expand All @@ -69,6 +70,9 @@ while true; do
-t|--test)
TEST=1; shift; continue
;;
--no-tag)
NOTAG=1; shift; continue
;;
-h|--help)
usage
exit
Expand Down Expand Up @@ -102,7 +106,7 @@ echo "Thank you for using this utility"
# Clear previous compilations to prevent potential issues and limit disk space
# usage
rm -f README.rst
rm -rf dist/ build/ ${PACKAGE_NAME}.egg-info/
rm -rf dist/ build/ ${WHEEL_PKG_NAME}.egg-info/

# Generate doc as restructured text for nice PyPI rendering
pandoc --from=markdown --to=rst --output=README.rst README.md
Expand All @@ -114,6 +118,10 @@ python setup.py sdist
python setup.py sdist bdist_wheel

if [ -n "$SUBMIT" ]; then
if [ -z "$NOTAG" ]; then
# Automatic tagging, because you know, I tend to forget that step
git tag --annotate "$(python -c "import $PACKAGE_NAME; print($PACKAGE_NAME.__version__)")"
fi
# Pre-registration to PyPI is no longer required or supported, upload
# directly
twine upload dist/*
Expand Down

0 comments on commit 3e1380f

Please sign in to comment.