Update setup.py

This commit is contained in:
Kenneth Reitz 2017-08-28 23:01:43 -04:00 committed by GitHub
parent 4e0c5d3cb7
commit a076ebe021

View File

@ -41,16 +41,17 @@ about = {}
with open(os.path.join(here, NAME, "__version__.py")) as f: with open(os.path.join(here, NAME, "__version__.py")) as f:
exec(f.read(), about) exec(f.read(), about)
def status(s):
"""Prints things in bold."""
print('\033[1m{0}\033[0m'.format(s))
class PublishCommand(Command): class PublishCommand(Command):
"""Support setup.py publish.""" """Support setup.py publish."""
description = "Build and publish the package." description = "Build and publish the package."
user_options = [] user_options = []
@staticmethod
def status(s):
"""Prints things in bold."""
print('\033[1m{0}\033[0m'.format(s))
def initialize_options(self): def initialize_options(self):
pass pass
@ -60,15 +61,15 @@ class PublishCommand(Command):
def run(self): def run(self):
try: try:
status('Removing previous builds...') self.status('Removing previous builds...')
rmtree(os.sep.join(('.', 'dist'))) rmtree(os.sep.join(('.', 'dist')))
except FileNotFoundError: except FileNotFoundError:
pass pass
status('Building Source and Wheel (universal) distribution...') self.status('Building Source and Wheel (universal) distribution...')
os.system("{0} setup.py sdist bdist_wheel --universal ".format(sys.executable)) os.system("{0} setup.py sdist bdist_wheel --universal ".format(sys.executable))
status('Uploading the package to PyPi via Twine...') self.status('Uploading the package to PyPi via Twine...')
os.system("twine upload dist/*") os.system("twine upload dist/*")
sys.exit() sys.exit()