Created
September 7, 2016 07:43
-
-
Save metatoaster/a6a722db834ab056c28633063e3c03c1 to your computer and use it in GitHub Desktop.
Sick of forgetting to clean dir before running bdist_wheel/sdist
This file contains hidden or 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
| #!/bin/sh | |
| PYSRC=/usr/bin/python3.4 | |
| TMPROOT=/tmp | |
| P=$(readlink -f "$1") | |
| REPO=${P}/.git | |
| if [ ! -d $REPO ]; then | |
| echo "Need a repo" | |
| exit | |
| fi | |
| NAME=$(basename "$P") | |
| if [ -n $NAME ]; then | |
| echo "Building project $NAME"; | |
| else | |
| exit | |
| fi | |
| TMPDIR=${TMPROOT}/${NAME} | |
| if [ -e $TMPDIR ]; then | |
| echo "Temporary target exists; please remove ${TMPDIR} to continue." | |
| exit | |
| fi | |
| PROJROOT="${TMPDIR}/${NAME}" | |
| ENVBASE="${TMPDIR}/env" | |
| BUILDENV="${ENVBASE}/build" | |
| TESTENV="${ENVBASE}/test" | |
| mkdir -p $PROJROOT | |
| chdir $TMPDIR | |
| virtualenv -p $PYSRC $BUILDENV | |
| virtualenv -p $PYSRC $TESTENV | |
| BUILDER="${BUILDENV}/bin/python" | |
| TESTER="${TESTENV}/bin/python" | |
| chdir $PROJROOT | |
| git --git-dir=$REPO archive --format=tar HEAD | tar xf - | |
| export PATH="${TESTENV}/bin:$PATH" | |
| $BUILDER -m pip install wheel | |
| $BUILDER setup.py develop | |
| $BUILDER setup.py sdist | |
| $TESTER -m pip install --find-links ./dist $NAME | |
| $TESTER -m unittest ${NAME}.tests.make_suite | |
| rm -rf $TESTENV | |
| virtualenv -p $PYSRC $TESTENV | |
| $BUILDER setup.py bdist_wheel | |
| $TESTER -m pip install --find-links ./dist $NAME | |
| $TESTER -m unittest ${NAME}.tests.make_suite | |
| find ./dist/* | |
| if [ "$2" = "upload" ]; then | |
| read -p "Upload? " yn | |
| case $yn in | |
| Y ) | |
| $BUILDER setup.py register | |
| $BUILDER setup.py sdist bdist_wheel upload | |
| break | |
| ;; | |
| y ) | |
| $BUILDER setup.py register -r https://testpypi.python.org/pypi; | |
| $BUILDER setup.py sdist bdist_wheel upload -r https://testpypi.python.org/pypi; | |
| break | |
| ;; | |
| esac | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment