|
| 1 | +#!/usr/bin/env python |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +from __future__ import unicode_literals |
| 4 | + |
| 5 | +# Note: To use the 'upload' functionality of this file, you must: |
| 6 | +# $ pip install twine |
| 7 | + |
| 8 | +import io |
| 9 | +import os |
| 10 | +import sys |
| 11 | +from shutil import rmtree |
| 12 | + |
| 13 | +from setuptools import find_packages, setup, Command |
| 14 | + |
| 15 | +# Package meta-data. |
| 16 | +NAME = 'transbank-sdk-python-onepay' |
| 17 | +MODULE_NAME = 'onepay' |
| 18 | +DESCRIPTION = 'Onepay SDK.' |
| 19 | +URL = 'https://github.com/TransbankDevelopers/transbank-sdk-python-onepay' |
| 20 | + |
| 21 | +AUTHOR = 'Transbank' |
| 22 | + |
| 23 | +# What packages are required for this module to be executed? |
| 24 | +REQUIRED = [ |
| 25 | +] |
| 26 | + |
| 27 | +TESTS_REQUIREMENTS = [ |
| 28 | + "nose>=1.0", |
| 29 | + "coverage", |
| 30 | + "mock", |
| 31 | + "requests_mock" |
| 32 | +] |
| 33 | + |
| 34 | +# The rest you shouldn't have to touch too much :) |
| 35 | +# ------------------------------------------------ |
| 36 | +# Except, perhaps the License and Trove Classifiers! |
| 37 | +# If you do change the License, remember to change the Trove Classifier for that! |
| 38 | + |
| 39 | +here = os.path.abspath(os.path.dirname(__file__)) |
| 40 | + |
| 41 | +# Import the README and use it as the long-description. |
| 42 | +# Note: this will only work if 'README.md' is present in your MANIFEST.in file! |
| 43 | +try: |
| 44 | + with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f: |
| 45 | + long_description = '\n' + f.read() |
| 46 | +except FileNotFoundError: |
| 47 | + long_description = DESCRIPTION |
| 48 | + |
| 49 | +# Load the package's __version__.py module as a dictionary. |
| 50 | +about = {} |
| 51 | +if not VERSION: |
| 52 | + with open(os.path.join(here, NAME, '__version__.py')) as f: |
| 53 | + exec(f.read(), about) |
| 54 | +else: |
| 55 | + about['__version__'] = VERSION |
| 56 | + |
| 57 | +class UploadCommand(Command): |
| 58 | + """Support setup.py upload.""" |
| 59 | + |
| 60 | + description = 'Build and publish the package.' |
| 61 | + user_options = [] |
| 62 | + |
| 63 | + @staticmethod |
| 64 | + def status(s): |
| 65 | + """Prints things in bold.""" |
| 66 | + print('\033[1m{0}\033[0m'.format(s)) |
| 67 | + |
| 68 | + def initialize_options(self): |
| 69 | + pass |
| 70 | + |
| 71 | + def finalize_options(self): |
| 72 | + pass |
| 73 | + |
| 74 | + def run(self): |
| 75 | + try: |
| 76 | + self.status('Removing previous builds…') |
| 77 | + rmtree(os.path.join(here, 'dist')) |
| 78 | + except OSError: |
| 79 | + pass |
| 80 | + |
| 81 | + self.status('Building Source and Wheel (universal) distribution…') |
| 82 | + os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable)) |
| 83 | + |
| 84 | + self.status('Uploading the package to PyPI via Twine…') |
| 85 | + os.system('twine upload dist/*') |
| 86 | + |
| 87 | + self.status('Pushing git tags…') |
| 88 | + os.system('git tag v{0}'.format(about['__version__'])) |
| 89 | + os.system('git push --tags') |
| 90 | + |
| 91 | + sys.exit() |
| 92 | + |
| 93 | +# Where the magic happens: |
| 94 | +setup( |
| 95 | + name=NAME, |
| 96 | + version=about['__version__'], |
| 97 | + description=DESCRIPTION, |
| 98 | + long_description=long_description, |
| 99 | + long_description_content_type='text/markdown', |
| 100 | + author=AUTHOR, |
| 101 | + author_email=EMAIL, |
| 102 | + url=URL, |
| 103 | + packages=find_packages(exclude=('tests',)), |
| 104 | + install_requires=REQUIRED, |
| 105 | + setup_requires=TESTS_REQUIREMENTS, |
| 106 | + include_package_data=True, |
| 107 | + license='BSD 3-clause "New" or "Revised License"', |
| 108 | + classifiers=[ |
| 109 | + # Trove classifiers |
| 110 | + # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers |
| 111 | + 'License :: OSI Approved :: BSD License', |
| 112 | + 'Programming Language :: Python', |
| 113 | + 'Programming Language :: Python :: 3', |
| 114 | + 'Programming Language :: Python :: 3.3', |
| 115 | + 'Programming Language :: Python :: 3.4', |
| 116 | + 'Programming Language :: Python :: 3.5', |
| 117 | + 'Programming Language :: Python :: 3.6', |
| 118 | + 'Programming Language :: Python :: 3.7', |
| 119 | + 'Programming Language :: Python :: Implementation :: CPython', |
| 120 | + ], |
| 121 | + # $ setup.py publish support. |
| 122 | + cmdclass={ |
| 123 | + 'upload': UploadCommand, |
| 124 | + }, |
| 125 | +) |
0 commit comments