|
1 | 1 | # coding=utf-8
|
2 | 2 | import os
|
3 |
| -from setuptools import setup, find_packages |
| 3 | +import sys |
| 4 | +from shutil import rmtree |
| 5 | +from setuptools import setup, find_packages, Command |
4 | 6 |
|
5 | 7 | # RELEASE STEPS
|
6 |
| -# $ python setup.py bdist_wheel |
7 |
| -# $ python twine upload dist/VX.Y.Z.whl |
8 |
| -# $ git tag -a VX.Y.Z -m "release version VX.Y.Z" |
9 |
| -# $ git push origin VX.Y.Z |
| 8 | +# $ python setup.py upload |
10 | 9 |
|
11 | 10 |
|
12 | 11 | __title__ = "pyecharts"
|
|
31 | 30 | with open(os.path.join(here, __title__, "_version.py")) as f:
|
32 | 31 | exec(f.read(), about)
|
33 | 32 |
|
| 33 | + |
| 34 | +__version__ = about["__version__"] |
| 35 | + |
| 36 | + |
| 37 | +class UploadCommand(Command): |
| 38 | + description = "Build and publish the package." |
| 39 | + user_options = [] |
| 40 | + |
| 41 | + @staticmethod |
| 42 | + def status(s): |
| 43 | + print("✨✨ {0}".format(s)) |
| 44 | + |
| 45 | + def initialize_options(self): |
| 46 | + pass |
| 47 | + |
| 48 | + def finalize_options(self): |
| 49 | + pass |
| 50 | + |
| 51 | + def run(self): |
| 52 | + try: |
| 53 | + self.status("Removing previous builds…") |
| 54 | + rmtree(os.path.join(here, "dist")) |
| 55 | + rmtree(os.path.join(here, "build")) |
| 56 | + rmtree(os.path.join(here, "{0}.egg-info".format(__title__))) |
| 57 | + except OSError: |
| 58 | + pass |
| 59 | + |
| 60 | + self.status("Building Source and Wheel distribution…") |
| 61 | + os.system("{0} setup.py bdist_wheel".format(sys.executable)) |
| 62 | + |
| 63 | + self.status("Uploading the package to PyPI via Twine…") |
| 64 | + os.system("twine upload dist/*") |
| 65 | + |
| 66 | + self.status("Pushing git tags…") |
| 67 | + os.system( |
| 68 | + 'git tag -a v{0} -m "release version v{0}"'.format(__version__) |
| 69 | + ) |
| 70 | + os.system("git push origin v{0}".format(__version__)) |
| 71 | + |
| 72 | + sys.exit() |
| 73 | + |
| 74 | + |
34 | 75 | setup(
|
35 | 76 | name=__title__,
|
36 |
| - version=about["__version__"], |
| 77 | + version=__version__, |
37 | 78 | description=__description__,
|
38 | 79 | url=__url__,
|
39 | 80 | author=about["__author__"],
|
|
55 | 96 | "Programming Language :: Python :: 2",
|
56 | 97 | "Programming Language :: Python :: 2.7",
|
57 | 98 | "Programming Language :: Python :: 3",
|
58 |
| - "Programming Language :: Python :: 3.4", |
59 | 99 | "Programming Language :: Python :: 3.5",
|
60 | 100 | "Programming Language :: Python :: 3.6",
|
61 | 101 | "Programming Language :: Python :: 3.7",
|
62 | 102 | "Topic :: Software Development :: Libraries",
|
63 | 103 | ],
|
| 104 | + cmdclass={"upload": UploadCommand}, |
64 | 105 | )
|
0 commit comments