Skip to content

Commit

Permalink
Setup enhance (pyecharts#716)
Browse files Browse the repository at this point in the history
* Enhance: setup.py for human

* Update: remove python3.4

* Update: micro change

* Update: update pink version

* Patch: 修复 fix-online 补丁
  • Loading branch information
chenjiandongx authored Aug 31, 2018
1 parent d1ec848 commit 5103cf7
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 14 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ python:
- "3.7-dev"
- "3.6"
- "3.5"
- "3.4"
- "2.7"
before_install:
- pip install -r test/requirements.txt
Expand Down
7 changes: 3 additions & 4 deletions pyecharts/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from pyecharts.js_extensions import EXTENSION_MANAGER


ONLINE_ASSETS = "https://pyecharts.github.io/assets/"
ONLINE_ASSETS_JS = ONLINE_ASSETS + "js/"
ONLINE_ASSETS_JS = "https://pyecharts.github.io/assets/js/"


class PyEchartsConfig(object):
Expand Down Expand Up @@ -75,9 +74,9 @@ def read_file_contents_from_local(js_names):

def generate_js_link(self, js_names):
# self.jshost 为 None 时应该使用远程 js
# "https://pyecharts.github.io/assets/"
# "https://pyecharts.github.io/assets/js"
if not self.jshost:
self.jshost = ONLINE_ASSETS
self.jshost = ONLINE_ASSETS_JS
links = []
for name in js_names:
for extension in EXTENSION_MANAGER.get_all_extensions():
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Windows: format_code.bat

black==18.6b4
pink>0.2.0
pink>0.4.0
55 changes: 48 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# coding=utf-8
import os
from setuptools import setup, find_packages
import sys
from shutil import rmtree
from setuptools import setup, find_packages, Command

# RELEASE STEPS
# $ python setup.py bdist_wheel
# $ python twine upload dist/VX.Y.Z.whl
# $ git tag -a VX.Y.Z -m "release version VX.Y.Z"
# $ git push origin VX.Y.Z
# $ python setup.py upload


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


__version__ = about["__version__"]


class UploadCommand(Command):
description = "Build and publish the package."
user_options = []

@staticmethod
def status(s):
print("✨✨ {0}".format(s))

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
try:
self.status("Removing previous builds…")
rmtree(os.path.join(here, "dist"))
rmtree(os.path.join(here, "build"))
rmtree(os.path.join(here, "{0}.egg-info".format(__title__)))
except OSError:
pass

self.status("Building Source and Wheel distribution…")
os.system("{0} setup.py bdist_wheel".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 -a v{0} -m "release version v{0}"'.format(__version__)
)
os.system("git push origin v{0}".format(__version__))

sys.exit()


setup(
name=__title__,
version=about["__version__"],
version=__version__,
description=__description__,
url=__url__,
author=about["__author__"],
Expand All @@ -55,10 +96,10 @@
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: Software Development :: Libraries",
],
cmdclass={"upload": UploadCommand},
)
2 changes: 1 addition & 1 deletion test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_online_html():
bar.render()
html_content = get_default_rendering_file_content()
assert (
'src="https://pyecharts.github.io/assets/echarts.min.js'
'src="https://pyecharts.github.io/assets/js/echarts.min.js'
in html_content
)
CURRENT_CONFIG.jshost = None
Expand Down

0 comments on commit 5103cf7

Please sign in to comment.