Skip to content

Commit 5103cf7

Browse files
Setup enhance (pyecharts#716)
* Enhance: setup.py for human * Update: remove python3.4 * Update: micro change * Update: update pink version * Patch: 修复 fix-online 补丁
1 parent d1ec848 commit 5103cf7

File tree

5 files changed

+53
-14
lines changed

5 files changed

+53
-14
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ python:
1010
- "3.7-dev"
1111
- "3.6"
1212
- "3.5"
13-
- "3.4"
1413
- "2.7"
1514
before_install:
1615
- pip install -r test/requirements.txt

pyecharts/conf.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from pyecharts.js_extensions import EXTENSION_MANAGER
99

1010

11-
ONLINE_ASSETS = "https://pyecharts.github.io/assets/"
12-
ONLINE_ASSETS_JS = ONLINE_ASSETS + "js/"
11+
ONLINE_ASSETS_JS = "https://pyecharts.github.io/assets/js/"
1312

1413

1514
class PyEchartsConfig(object):
@@ -75,9 +74,9 @@ def read_file_contents_from_local(js_names):
7574

7675
def generate_js_link(self, js_names):
7776
# self.jshost 为 None 时应该使用远程 js
78-
# "https://pyecharts.github.io/assets/"
77+
# "https://pyecharts.github.io/assets/js"
7978
if not self.jshost:
80-
self.jshost = ONLINE_ASSETS
79+
self.jshost = ONLINE_ASSETS_JS
8180
links = []
8281
for name in js_names:
8382
for extension in EXTENSION_MANAGER.get_all_extensions():

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# Windows: format_code.bat
44

55
black==18.6b4
6-
pink>0.2.0
6+
pink>0.4.0

setup.py

+48-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# coding=utf-8
22
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
46

57
# 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
109

1110

1211
__title__ = "pyecharts"
@@ -31,9 +30,51 @@
3130
with open(os.path.join(here, __title__, "_version.py")) as f:
3231
exec(f.read(), about)
3332

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+
3475
setup(
3576
name=__title__,
36-
version=about["__version__"],
77+
version=__version__,
3778
description=__description__,
3879
url=__url__,
3980
author=about["__author__"],
@@ -55,10 +96,10 @@
5596
"Programming Language :: Python :: 2",
5697
"Programming Language :: Python :: 2.7",
5798
"Programming Language :: Python :: 3",
58-
"Programming Language :: Python :: 3.4",
5999
"Programming Language :: Python :: 3.5",
60100
"Programming Language :: Python :: 3.6",
61101
"Programming Language :: Python :: 3.7",
62102
"Topic :: Software Development :: Libraries",
63103
],
104+
cmdclass={"upload": UploadCommand},
64105
)

test/test_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def test_online_html():
204204
bar.render()
205205
html_content = get_default_rendering_file_content()
206206
assert (
207-
'src="https://pyecharts.github.io/assets/echarts.min.js'
207+
'src="https://pyecharts.github.io/assets/js/echarts.min.js'
208208
in html_content
209209
)
210210
CURRENT_CONFIG.jshost = None

0 commit comments

Comments
 (0)