|
| 1 | +# coding=utf-8 |
| 2 | +import io |
| 3 | +import os |
| 4 | +import sys |
| 5 | +from shutil import rmtree |
| 6 | + |
| 7 | +from setuptools import find_packages, setup, Command |
| 8 | + |
| 9 | +NAME = "openapigenerator" |
| 10 | +DESCRIPTION = "CLI for openapi generator" |
| 11 | +URL = "https://github.com/OpenAPITools/openapi-generator" |
| 12 | +EMAIL = "team@openapitools.org" |
| 13 | +AUTHOR = "OpenAPI Generator community" |
| 14 | +VERSION = open("version").read() |
| 15 | +EXTRAS = {} |
| 16 | + |
| 17 | +here = os.path.abspath(os.path.dirname(__file__)) |
| 18 | + |
| 19 | +try: |
| 20 | + with io.open(os.path.join(here, "README.md"), encoding="utf-8") as f: |
| 21 | + long_description = "\n" + f.read() |
| 22 | +except FileNotFoundError: |
| 23 | + long_description = DESCRIPTION |
| 24 | + |
| 25 | + |
| 26 | +class UploadCommand(Command): |
| 27 | + description = "Build and publish the package." |
| 28 | + user_options = [] |
| 29 | + |
| 30 | + @staticmethod |
| 31 | + def status(s): |
| 32 | + print("\033[1m{0}\033[0m".format(s)) |
| 33 | + |
| 34 | + def initialize_options(self): |
| 35 | + pass |
| 36 | + |
| 37 | + def finalize_options(self): |
| 38 | + pass |
| 39 | + |
| 40 | + def run(self): |
| 41 | + try: |
| 42 | + self.status("Removing previous builds…") |
| 43 | + rmtree(os.path.join(here, "dist")) |
| 44 | + except OSError: |
| 45 | + pass |
| 46 | + |
| 47 | + self.status("Building Source and Wheel (universal) distribution…") |
| 48 | + os.system("{0} setup.py sdist bdist_wheel --universal".format(sys.executable)) |
| 49 | + |
| 50 | + self.status("Uploading the package to PyPI via Twine…") |
| 51 | + os.system("twine upload dist/*") |
| 52 | + |
| 53 | + sys.exit() |
| 54 | + |
| 55 | + |
| 56 | +setup( |
| 57 | + name=NAME, |
| 58 | + version=VERSION, |
| 59 | + description=DESCRIPTION, |
| 60 | + long_description=long_description, |
| 61 | + long_description_content_type="text/markdown", |
| 62 | + author=AUTHOR, |
| 63 | + author_email=EMAIL, |
| 64 | + url=URL, |
| 65 | + packages=["openapi_generator_cli"], |
| 66 | + extras_require=EXTRAS, |
| 67 | + package_data={"openapi_generator_cli": ["*.jar"]}, |
| 68 | + include_package_data=True, |
| 69 | + license="APACHE 2.0", |
| 70 | + classifiers=[ |
| 71 | + "License :: OSI Approved :: Apache Software License", |
| 72 | + "Programming Language :: Python", |
| 73 | + "Programming Language :: Python :: Implementation :: CPython", |
| 74 | + "Programming Language :: Python :: Implementation :: PyPy", |
| 75 | + ], |
| 76 | + cmdclass={"upload": UploadCommand}, |
| 77 | + entry_points={"console_scripts": ["openapi-generator=openapi_generator_cli:run"]}, |
| 78 | +) |
0 commit comments