Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

# Note: To use the 'upload' functionality of this file, you must:
# $ pipenv install twine --dev
"""
setup.py for human
"""

import io
import os
Expand Down Expand Up @@ -33,26 +36,26 @@
# The rest you shouldn't have to touch too much :)
# ------------------------------------------------
# Except, perhaps the License and Trove Classifiers!
# If you do change the License, remember to change the Trove Classifier for that!
# If you change the License, remember to change the Trove Classifier for that!

here = os.path.abspath(os.path.dirname(__file__))
HERE = os.path.abspath(os.path.dirname(__file__))

# Import the README and use it as the long-description.
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
try:
with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = '\n' + f.read()
with io.open(os.path.join(HERE, 'README.md'), encoding='utf-8') as f:
LONG_DESCRIPTION = '\n' + f.read()
except FileNotFoundError:
long_description = DESCRIPTION
LONG_DESCRIPTION = DESCRIPTION

# Load the package's __version__.py module as a dictionary.
about = {}
ABOUT = {}
if not VERSION:
project_slug = NAME.lower().replace("-", "_").replace(" ", "_")
with open(os.path.join(here, project_slug, '__version__.py')) as f:
exec(f.read(), about)
PROJECT_SLUG = NAME.lower().replace("-", "_").replace(" ", "_")
with open(os.path.join(HERE, PROJECT_SLUG, '__version__.py')) as f:
exec(f.read(), ABOUT) # pylint: disable=W0122
else:
about['__version__'] = VERSION
ABOUT['__version__'] = VERSION


class UploadCommand(Command):
Expand All @@ -62,31 +65,34 @@ class UploadCommand(Command):
user_options = []

@staticmethod
def status(s):
def status(stat):
"""Prints things in bold."""
print('\033[1m{0}\033[0m'.format(s))
print('\033[1m{0}\033[0m'.format(stat))

def initialize_options(self):
pass
"""Initialize Options"""

def finalize_options(self):
pass
"""Finalize Options"""

def run(self):
"""Cleanup, build, upload, and git tag"""
try:
self.status('Removing previous builds…')
rmtree(os.path.join(here, 'dist'))
rmtree(os.path.join(HERE, 'dist'))
except OSError:
pass

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)
)

self.status('Uploading the package to PyPI via Twine…')
os.system('twine upload dist/*')

self.status('Pushing git tags…')
os.system('git tag v{0}'.format(about['__version__']))
os.system('git tag v{0}'.format(ABOUT['__version__']))
os.system('git push --tags')

sys.exit()
Expand All @@ -95,15 +101,17 @@ def run(self):
# Where the magic happens:
setup(
name=NAME,
version=about['__version__'],
version=ABOUT['__version__'],
description=DESCRIPTION,
long_description=long_description,
long_description=LONG_DESCRIPTION,
long_description_content_type='text/markdown',
author=AUTHOR,
author_email=EMAIL,
python_requires=REQUIRES_PYTHON,
url=URL,
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
packages=find_packages(
exclude=["tests", "*.tests", "*.tests.*", "tests.*"]
),
# If your package is a single module, use this instead of 'packages':
# py_modules=['mypackage'],

Expand Down