From bbb281284d6b1a3d60bdcbd44ebe5d6c4258c278 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 28 Aug 2017 22:39:54 -0400 Subject: [PATCH] Update setup.py --- setup.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b1a8a5d..da7f26d 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,15 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +# Note: To use the 'upload' functionality of this file, you must: +# $ pip install twine + import codecs import os import sys from setuptools import find_packages, setup +from shutil import rmtree # Package meta-data. NAME = 'mypackage' @@ -36,8 +40,19 @@ required = [ # Support "$ setup.py publish". if sys.argv[-1] == "publish": - os.system("{0} setup.py sdist bdist_wheel upload".format(sys.executable)) - sys.exit() + try: + # Remove previous builds from the source tree. + rmtree(os.sep.join(('.', 'dist'))) + except FileNotFoundError: + pass + + # Create Source and Wheel (universal) distributions + os.system("{0} setup.py sdist bdist_wheel --universal ".format(sys.executable)) + + # Upload the package to PyPi. + os.system("twine upload dist/*") + + sys.exit() # Where the magic happens: setup(