diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a4a5e79 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,31 @@ +name: build + +on: [push] + +jobs: + build: + runs-on: macOS-latest + strategy: + matrix: + python-version: [3.5, 3.6, 3.7, 3.8, 3.9] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # any syntax error, break build + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest \ No newline at end of file diff --git a/example/app.py b/example/app.py index bc8f54a..c3de8fd 100644 --- a/example/app.py +++ b/example/app.py @@ -1,10 +1,14 @@ import streamlit as st from streamlit_g2 import g2 +st.set_page_config(page_title="streamlit-g2: AntV G2 for Streamlit!") + """ # Welcome to [streamlit-g2](https://github.com/hustcc/streamlit-g2)! -In the meantime, below are some examples of what you can do with just a few lines of code: +[G2](https://github.com/antvis/G2) is a visualization grammar for dashboard building, data exploration and storytelling. + +This project was created to allow us to render [G2](https://github.com/antvis/G2) charts in streamlit. In the meantime, below are some examples of what you can do with just a few lines of code: """ """ diff --git a/setup.py b/setup.py index 9188d8d..e88d90e 100644 --- a/setup.py +++ b/setup.py @@ -1,19 +1,64 @@ -import setuptools +import io +import os +import sys +from shutil import rmtree +from setuptools import Command, find_packages, setup -setuptools.setup( +here = os.path.abspath(os.path.dirname(__file__)) + +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("streamlit_g2"))) + 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/*") + + sys.exit() + +def read(*names, **kwargs): + return io.open( + os.path.join(os.path.dirname(__file__), *names), + encoding=kwargs.get("encoding", "utf8") + ).read() + +setup( name="streamlit-g2", - version="0.0.6", + version="0.1.0", author="hustcc", author_email="i@hust.cc", description="Render G2 charts in Streamlit", - long_description="Render G2 charts in Streamlit", + long_description=read('readme.md'), long_description_content_type="text/plain", + keywords=["antv", "g2", "streamlit-component", "streamlit-g2"], url="https://github.com/hustcc/streamlit-g2", - packages=setuptools.find_packages(), + packages=find_packages(), include_package_data=True, classifiers=[], python_requires=">=3.6", install_requires=[ "streamlit >= 0.63", ], + cmdclass={"upload": UploadCommand}, ) diff --git a/tests/test_meta.py b/tests/test_meta.py new file mode 100644 index 0000000..688deda --- /dev/null +++ b/tests/test_meta.py @@ -0,0 +1,4 @@ +import pytest + +def test_meta(): + assert "1" == "1" \ No newline at end of file