From fde6ffab5c4020b9870d1a2c5848057f34974634 Mon Sep 17 00:00:00 2001 From: Craig Barratt <19445341+craigbarratt@users.noreply.github.com> Date: Wed, 4 Nov 2020 18:47:32 -0800 Subject: [PATCH] added version file; a few tweaks prior to 1.0.0 release --- README.md | 2 ++ hass_pyscript_kernel/install.py | 2 ++ hass_pyscript_kernel/shim.py | 2 +- hass_pyscript_kernel/version.py | 3 +++ setup.py | 38 +++++++++++++++++++++------------ 5 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 hass_pyscript_kernel/version.py diff --git a/README.md b/README.md index 552b477..e963bb1 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ To install the pyscript Jupyter kernel: pip install hass_pyscript_kernel jupyter pyscript install ``` +Running `jupyter pyscript install` is only required on new installs, or if your old +version of `hass_pyscript_kernel` is prior to 1.0.0. On a new install, you'll need to edit the `pyscript.conf` file. The install command above will print its path. Replace these settings: diff --git a/hass_pyscript_kernel/install.py b/hass_pyscript_kernel/install.py index faafad5..55d2864 100644 --- a/hass_pyscript_kernel/install.py +++ b/hass_pyscript_kernel/install.py @@ -9,6 +9,7 @@ from jupyter_core.paths import SYSTEM_JUPYTER_PATH from .shim import CONFIG_SETTINGS, PKG_NAME, load_config +from .version import __version__ SCRIPT_NAME = "jupyter-pyscript" @@ -86,6 +87,7 @@ def install_main(): elif args.action == "info": kernels = KernelSpecManager().find_kernel_specs() + print(f"{PKG_NAME} version {__version__} installed") if args.kernel_name not in kernels: print(f"No installed kernel named {args.kernel_name} found") else: diff --git a/hass_pyscript_kernel/shim.py b/hass_pyscript_kernel/shim.py index b0f0efa..3063a31 100644 --- a/hass_pyscript_kernel/shim.py +++ b/hass_pyscript_kernel/shim.py @@ -348,7 +348,7 @@ async def do_request( def remove_quotes(string): """Strip leading/trailing quotes from string, which VSCode strangely adds to arguments.""" - if string[0] == string[-1] and string[0] in ('"', "'"): + if len(string) > 0 and string[0] == string[-1] and string[0] in ('"', "'"): return string[1:-1] if len(string) > 1 and string[0] == "b" and string[1] == string[-1] and string[1] in ('"', "'"): return string[2:-1] diff --git a/hass_pyscript_kernel/version.py b/hass_pyscript_kernel/version.py new file mode 100644 index 0000000..96a36c5 --- /dev/null +++ b/hass_pyscript_kernel/version.py @@ -0,0 +1,3 @@ +"""Version for this package.""" + +__version__ = "1.0.0" diff --git a/setup.py b/setup.py index 13645c0..b5337d4 100644 --- a/setup.py +++ b/setup.py @@ -5,22 +5,32 @@ with open("README.md", "r") as fh: long_description = fh.read() +def get_version(path): + with open(path, "r") as fh: + for line in fh.readlines(): + if line.startswith("__version__"): + return line.split('"' if '"' in line else "'")[1] + else: + raise RuntimeError(f"Unable to find version string in {path}") + +version = get_version("hass_pyscript_kernel/version.py") + setup( - name='hass_pyscript_kernel', - version='0.30', - author='Craig Barratt', - author_email='@alumni.stanford.edu', - description='Home Assistant Pyscript Jupyter kernel shim', - url='https://github.com/craigbarratt/hass-pyscript-jupyter', - download_url='https://github.com/craigbarratt/hass-pyscript-jupyter/archive/0.30.tar.gz', - packages=['hass_pyscript_kernel'], + name="hass_pyscript_kernel", + version=version, + author="Craig Barratt", + author_email="cbarratt@users.sourceforge.net", + description="Home Assistant Pyscript Jupyter kernel shim", + url="https://github.com/craigbarratt/hass-pyscript-jupyter", + download_url=f"https://github.com/craigbarratt/hass-pyscript-jupyter/archive/{version}.tar.gz", + packages=["hass_pyscript_kernel"], long_description=long_description, long_description_content_type="text/markdown", install_requires=[ - 'aiohttp', - 'aiohttp_socks', - 'jupyter-client', - 'jupyter-core', + "aiohttp", + "aiohttp_socks", + "jupyter-client", + "jupyter-core", ], python_requires=">=3.7", zip_safe=False, @@ -33,8 +43,8 @@ ], }, entry_points={ - 'console_scripts': [ - 'jupyter-pyscript=hass_pyscript_kernel:install_main', + "console_scripts": [ + "jupyter-pyscript=hass_pyscript_kernel:install_main", ], }, )