diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7497f3e..3b57ae9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,6 +67,12 @@ jobs: shell: bash -l {0} run: python -c 'import here_map_widget' + - name: Build the package (Only on Linux for saving time) + if: matrix.os == 'ubuntu-latest' + shell: bash -l {0} + run: | + python setup.py sdist bdist_wheel + - name: Build docs (Only on Linux for saving time) if: matrix.os == 'ubuntu-latest' shell: bash -l {0} diff --git a/README.md b/README.md index 3b82ddb..ded283b 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,44 @@ # HERE Map Widget for Jupyter +![Tests](https://github.com/heremaps/here-map-widget-for-jupyter/workflows/Tests/badge.svg) +[![PyPI - Status](https://img.shields.io/pypi/status/here-map-widget-for-jupyter)](https://pypi.org/project/here-map-widget-for-jupyter/) +[![PyPI - Python Version](https://img.shields.io/pypi/v/here-map-widget-for-jupyter.svg?logo=pypi)](https://pypi.org/project/here-map-widget-for-jupyter/) +[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/here-map-widget-for-jupyter)](https://pypi.org/project/here-map-widget-for-jupyter/) +[![PyPI - License](https://img.shields.io/pypi/l/here-map-widget-for-jupyter)](https://pypi.org/project/here-map-widget-for-jupyter/) +[![Downloads](https://pepy.tech/badge/here-map-widget-for-jupyter)](https://pepy.tech/project/here-map-widget-for-jupyter) +[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/heremaps/here-map-widget-for-jupyter/master?urlpath=lab/tree/examples) + Use [HERE Maps API for JavaScript](https://developer.here.com/develop/javascript-api) in your [Jupyter Notebook](https://jupyter.org/). ## Usage **Selecting a basemap:** -![Select base map](images/basemaps.gif) +![Select base map](https://github.com/heremaps/here-map-widget-for-jupyter/raw/master/images/basemaps.gif) **Loading a GeoJSON data on a map:** -![Use GeoJSON on map](images/geojson.gif) +![Use GeoJSON on map](https://github.com/heremaps/here-map-widget-for-jupyter/raw/master/images/geojson.gif) **Making use of HERE Maps API for JavaScript primitives such as Marker to draw a SVG icon on the map:** -![Add marker to map](images/marker.gif) +![Add marker to map](https://github.com/heremaps/here-map-widget-for-jupyter/raw/master/images/marker.gif) **Using the search control to search GeoJSON layer data:** -![Add search control to map](images/search-control.gif) +![Add search control to map](https://github.com/heremaps/here-map-widget-for-jupyter/raw/master/images/search-control.gif) **Displaying [GeoPandas](https://geopandas.org/) data on map:** -![Add Geopandas data to map](images/geo-pandas.gif) +![Add Geopandas data to map](https://github.com/heremaps/here-map-widget-for-jupyter/raw/master/images/geo-pandas.gif) **Displaying [XYZ Hub](https://github.com/heremaps/xyz-hub) or [HERE Data Hub](https://developer.here.com/products/data-hub) space data on a map:** -![Add XYZ data to map](images/xyz.gif) +![Add XYZ data to map](https://github.com/heremaps/here-map-widget-for-jupyter/raw/master/images/xyz.gif) **Use [ipywidgets](https://ipywidgets.readthedocs.io/) controls to build an interactive GUI:** -![Add ipywidgets controls](images/widget-control.gif) +![Add ipywidgets controls](https://github.com/heremaps/here-map-widget-for-jupyter/raw/master/images/widget-control.gif) ## Prerequisites diff --git a/binder/environment.yml b/binder/environment.yml new file mode 100644 index 0000000..f6db27e --- /dev/null +++ b/binder/environment.yml @@ -0,0 +1,12 @@ +name: here_map_widget +channels: + - conda-forge +dependencies: + - pip + - xyzspaces + - jupyterlab==2.2.9 + - pip: + - "-r ../requirements.txt" + - "-r ../requirements_dev.txt" + - "-r ../docs/requirements.txt" + - "-e ../" diff --git a/binder/postBuild b/binder/postBuild new file mode 100644 index 0000000..0b87871 --- /dev/null +++ b/binder/postBuild @@ -0,0 +1,9 @@ +npm config set @here:registry https://repo.platform.here.com/artifactory/api/npm/here-node/ +jupyter nbextension install --py --symlink --sys-prefix here_map_widget +jupyter nbextension enable --py --sys-prefix here_map_widget +jupyter labextension install @jupyter-widgets/jupyterlab-manager js + +# Notebooks with extensions that auto-run code must be "trusted" to work the first time +jupyter trust examples/*.ipynb + +jupyter lab build --dev-build=False --minimize=False \ No newline at end of file diff --git a/docs/source/installation.rst b/docs/source/installation.rst index d79f7db..c853c7b 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -139,6 +139,4 @@ Installation Example - Validating: OK $ jupyter labextension install @jupyter-widgets/jupyterlab-manager @here/maps-api-for-javascript-widget-for-jupyter-noteboo - Building jupyterlab assets (build:prod:minimize) - - $ npm config delete @here:registry https://repo.platform.here.com/artifactory/api/npm/here-node/ \ No newline at end of file + Building jupyterlab assets (build:prod:minimize) \ No newline at end of file diff --git a/examples/README.md b/examples/README.md index 4742aaf..b4b6378 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,6 +2,12 @@ The example notebooks in this directory demonstrate various functionalities of `HERE Map Widget for Jupyter`. +## Prerequisites +Before you run the Notebooks make sure you have: +- A HERE developer account, free and available under [HERE Developer Portal](https://developer.here.com) +- An [API key](https://developer.here.com/documentation/identity-access-management/dev_guide/topics/dev-apikey.html) from the [HERE Developer Portal](https://developer.here.com) +- An XYZ API access token from your XYZ Hub server or the [XYZ portal](https://www.here.xyz) see also it's [Getting + Started](https://www.here.xyz/getting-started/). ## Notebooks - [Add ipywidgets over map](./add_ipywidgets.ipynb) - Display interactive ipywidget over map and control traits of the map. diff --git a/examples/add_ipywidgets.ipynb b/examples/add_ipywidgets.ipynb index 5df1d5c..c2f284d 100644 --- a/examples/add_ipywidgets.ipynb +++ b/examples/add_ipywidgets.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -61,7 +81,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/basemaps.ipynb b/examples/basemaps.ipynb index 4b580ad..e8c33e2 100644 --- a/examples/basemaps.ipynb +++ b/examples/basemaps.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -160,7 +180,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/choropleth_layer.ipynb b/examples/choropleth_layer.ipynb index 2a149ca..b4a5561 100644 --- a/examples/choropleth_layer.ipynb +++ b/examples/choropleth_layer.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -161,7 +181,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/circle.ipynb b/examples/circle.ipynb index 62cc453..01ea763 100644 --- a/examples/circle.ipynb +++ b/examples/circle.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -39,7 +59,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/custom_icons.ipynb b/examples/custom_icons.ipynb index d818ff7..62280ac 100644 --- a/examples/custom_icons.ipynb +++ b/examples/custom_icons.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -61,7 +81,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/custom_marker_icon.ipynb b/examples/custom_marker_icon.ipynb index 25899b2..58dda69 100644 --- a/examples/custom_marker_icon.ipynb +++ b/examples/custom_marker_icon.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -45,7 +65,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/datahub_space.ipynb b/examples/datahub_space.ipynb index 23d9a7a..b4a0aa1 100644 --- a/examples/datahub_space.ipynb +++ b/examples/datahub_space.ipynb @@ -1,12 +1,24 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key and XYZ access token. \n", + " Please see README.md for more info on API key and XYZ access token.\n", + "
" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "#! pip install xyzspaces" + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here.\n", + "os.environ[\"XYZ_TOKEN\"] = \"MY-XYZ-TOKEN\" # replace your XYZ access token here." ] }, { @@ -107,7 +119,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/datahub_space_style.ipynb b/examples/datahub_space_style.ipynb index 4292ce0..e4383d9 100644 --- a/examples/datahub_space_style.ipynb +++ b/examples/datahub_space_style.ipynb @@ -1,5 +1,26 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key and XYZ access token. \n", + " Please see README.md for more info on API key and XYZ access token.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here.\n", + "os.environ[\"XYZ_TOKEN\"] = \"MY-XYZ-TOKEN\" # replace your XYZ access token here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -59,7 +80,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/distance_measurement_control.ipynb b/examples/distance_measurement_control.ipynb index 06f4973..55d9d3f 100644 --- a/examples/distance_measurement_control.ipynb +++ b/examples/distance_measurement_control.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -54,7 +74,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/dom_marker.ipynb b/examples/dom_marker.ipynb index ee412f2..9d1d343 100644 --- a/examples/dom_marker.ipynb +++ b/examples/dom_marker.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -36,7 +56,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/extrusion.ipynb b/examples/extrusion.ipynb index 372d6cd..a603a48 100644 --- a/examples/extrusion.ipynb +++ b/examples/extrusion.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -141,7 +161,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/forest_fire_analysis.ipynb b/examples/forest_fire_analysis.ipynb index 716d461..29d2380 100644 --- a/examples/forest_fire_analysis.ipynb +++ b/examples/forest_fire_analysis.ipynb @@ -1,5 +1,26 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key and XYZ access token. \n", + " Please see README.md for more info on API key and XYZ access token.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here.\n", + "os.environ[\"XYZ_TOKEN\"] = \"MY-XYZ-TOKEN\" # replace your XYZ access token here." + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -35,7 +56,14 @@ "metadata": {}, "outputs": [], "source": [ - "xyz_token = os.environ[\"XYZ_TOKEN\"]\n", + "
\n", + "Warning: Before running below cells please make sure you have API key and XYZ access token. \n", + " Please see README.md for more info on API key and XYZ access token.\n", + "
\n", + "\n", + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here.\n", + "os.environ[\"XYZ_TOKEN\"] = \"MY-XYZ-TOKEN\" # replace your XYZ access token here.xyz_token = os.environ[\"XYZ_TOKEN\"]\n", "xyz = XYZ(credentials=xyz_token)" ] }, @@ -233,7 +261,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/geodata.ipynb b/examples/geodata.ipynb index 22f8438..f16a2c6 100644 --- a/examples/geodata.ipynb +++ b/examples/geodata.ipynb @@ -1,12 +1,23 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "#!pip install geopandas" + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." ] }, { @@ -51,7 +62,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/group_objects.ipynb b/examples/group_objects.ipynb index 9c218f0..9cb83ad 100644 --- a/examples/group_objects.ipynb +++ b/examples/group_objects.ipynb @@ -1,12 +1,38 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "from here_map_widget import LineString, Polyline, Marker, Group\n", + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
\n", + "\n", + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here.from here_map_widget import LineString, Polyline, Marker, Group\n", "from here_map_widget import Map, Bbox, Rectangle, Point, Circle, LineString, Polygon\n", "import os\n", "\n", @@ -68,7 +94,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/image_overlay.ipynb b/examples/image_overlay.ipynb index 999a5ab..4a972cf 100644 --- a/examples/image_overlay.ipynb +++ b/examples/image_overlay.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -56,7 +76,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/infobubble.ipynb b/examples/infobubble.ipynb index 75721fc..5d41d03 100644 --- a/examples/infobubble.ipynb +++ b/examples/infobubble.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -161,7 +181,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/japan_data.ipynb b/examples/japan_data.ipynb index b9db853..3ec3a4f 100644 --- a/examples/japan_data.ipynb +++ b/examples/japan_data.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -54,7 +74,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/kml.ipynb b/examples/kml.ipynb index 0d8cecb..1508a42 100644 --- a/examples/kml.ipynb +++ b/examples/kml.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -44,7 +64,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/map_basics_demo.ipynb b/examples/map_basics_demo.ipynb index b29a7c9..fa33a95 100644 --- a/examples/map_basics_demo.ipynb +++ b/examples/map_basics_demo.ipynb @@ -1,5 +1,26 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key and XYZ access token. \n", + " Please see README.md for more info on API key and XYZ access token.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here.\n", + "os.environ[\"XYZ_TOKEN\"] = \"MY-XYZ-TOKEN\" # replace your XYZ access token here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -428,7 +449,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/map_settings_control.ipynb b/examples/map_settings_control.ipynb index 8ddedfa..6df2b6d 100644 --- a/examples/map_settings_control.ipynb +++ b/examples/map_settings_control.ipynb @@ -1,5 +1,26 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key and XYZ access token. \n", + " Please see README.md for more info on API key and XYZ access token.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here.\n", + "os.environ[\"XYZ_TOKEN\"] = \"MY-XYZ-TOKEN\" # replace your XYZ access token here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -61,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/marker_cluster.ipynb b/examples/marker_cluster.ipynb index 6758130..08eefa6 100644 --- a/examples/marker_cluster.ipynb +++ b/examples/marker_cluster.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -53,7 +73,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/marker_trace_on_linestring.ipynb b/examples/marker_trace_on_linestring.ipynb index bfcf9ce..140cdf6 100644 --- a/examples/marker_trace_on_linestring.ipynb +++ b/examples/marker_trace_on_linestring.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -112,7 +132,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/movable_shapes_objects.ipynb b/examples/movable_shapes_objects.ipynb index a7ab414..473696e 100644 --- a/examples/movable_shapes_objects.ipynb +++ b/examples/movable_shapes_objects.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -65,7 +85,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/polygon.ipynb b/examples/polygon.ipynb index 62aadea..9666ead 100644 --- a/examples/polygon.ipynb +++ b/examples/polygon.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -125,7 +145,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/rectangle.ipynb b/examples/rectangle.ipynb index 1950d13..229aba5 100644 --- a/examples/rectangle.ipynb +++ b/examples/rectangle.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -39,7 +59,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/search_control.ipynb b/examples/search_control.ipynb index 67c3422..d977060 100644 --- a/examples/search_control.ipynb +++ b/examples/search_control.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -94,7 +114,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/examples/splitmap_control.ipynb b/examples/splitmap_control.ipynb index 2b32094..d8b73b3 100644 --- a/examples/splitmap_control.ipynb +++ b/examples/splitmap_control.ipynb @@ -1,5 +1,25 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Warning: Before running below cells please make sure you have API key. \n", + " Please see README.md for more info on API key.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here." + ] + }, { "cell_type": "code", "execution_count": null, @@ -46,7 +66,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.9" } }, "nbformat": 4, diff --git a/here_map_widget/_version.py b/here_map_widget/_version.py index 878495d..c3769f4 100644 --- a/here_map_widget/_version.py +++ b/here_map_widget/_version.py @@ -4,9 +4,9 @@ """Project version information.""" # Module version -version_info = (0, 1, 0) +version_info = (0, 1, 1) # Module version accessible using here_map_widget.__version__ __version__ = "%s.%s.%s" % (version_info[0], version_info[1], version_info[2],) -EXTENSION_VERSION = "^0.1.0" +EXTENSION_VERSION = "^0.1.1" diff --git a/js/lib/embed.js b/js/lib/embed.js index 13a2926..4f9c5b8 100644 --- a/js/lib/embed.js +++ b/js/lib/embed.js @@ -10,4 +10,4 @@ // already be loaded by the notebook otherwise. // Export widget models and views, and the npm package version number. -module.exports['version'] = require('../package.json').version; +module.exports = require('./index.js'); diff --git a/js/package.json b/js/package.json index 7792797..724e9f8 100644 --- a/js/package.json +++ b/js/package.json @@ -1,12 +1,12 @@ { "name": "@here/map-widget-for-jupyter", - "version": "0.1.0", + "version": "0.1.1", "description": "Use HERE Maps API for JavaScript in your Jupyter Notebook.", "author": { "name": "HERE Europe B.V.", "url": "https://here.com" }, - "license": "SEE LICENSE IN LICENSE", + "license": "MIT", "main": "lib/index.js", "repository": { "type": "git", diff --git a/js/webpack.config.js b/js/webpack.config.js index ffde2bc..e1e6935 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -77,7 +77,7 @@ module.exports = [ filename: 'index.js', path: path.resolve(__dirname, 'dist'), libraryTarget: 'amd', - publicPath: 'https://unpkg.com/@here/map-widget-for-jupyter@' + version + '/dist/' + publicPath: 'https://unpkg.com/map-widget-for-jupyter@' + version + '/dist/' }, devtool: 'source-map', module: { diff --git a/requirements.txt b/requirements.txt index 07c0297..8ec4386 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -ipywidgets -branca \ No newline at end of file +ipywidgets>=7.6.0,<8 +branca>=0.3.1,<0.5 \ No newline at end of file diff --git a/setup.py b/setup.py index 4e731eb..6bdc960 100644 --- a/setup.py +++ b/setup.py @@ -16,19 +16,18 @@ from glob import glob here = os.path.dirname(os.path.abspath(__file__)) -node_root = os.path.join(here, 'js') -is_repo = os.path.exists(os.path.join(here, '.git')) +node_root = os.path.join(here, "js") +is_repo = os.path.exists(os.path.join(here, ".git")) -npm_path = os.pathsep.join([ - os.path.join(node_root, 'node_modules', '.bin'), - os.environ.get('PATH', os.defpath), -]) +npm_path = os.pathsep.join( + [os.path.join(node_root, "node_modules", ".bin"), os.environ.get("PATH", os.defpath),] +) from distutils import log log.set_verbosity(log.DEBUG) -log.info('setup.py entered') -log.info('$PATH=%s' % os.environ['PATH']) +log.info("setup.py entered") +log.info("$PATH=%s" % os.environ["PATH"]) def js_prerelease(command, strict=False): @@ -36,23 +35,23 @@ def js_prerelease(command, strict=False): class DecoratedCommand(command): def run(self): - jsdeps = self.distribution.get_command_obj('jsdeps') + jsdeps = self.distribution.get_command_obj("jsdeps") if not is_repo and all(os.path.exists(t) for t in jsdeps.targets): # sdist, nothing to do command.run(self) return try: - self.distribution.run_command('jsdeps') + self.distribution.run_command("jsdeps") except Exception as e: missing = [t for t in jsdeps.targets if not os.path.exists(t)] if strict or missing: - log.warn('rebuilding js and css failed') + log.warn("rebuilding js and css failed") if missing: - log.error('missing files: %s' % missing) + log.error("missing files: %s" % missing) raise e else: - log.warn('rebuilding js and css failed (not a problem)') + log.warn("rebuilding js and css failed (not a problem)") log.warn(str(e)) command.run(self) update_package_data(self.distribution) @@ -62,22 +61,22 @@ def run(self): def update_package_data(distribution): """update package_data to catch changes during setup""" - build_py = distribution.get_command_obj('build_py') + build_py = distribution.get_command_obj("build_py") # distribution.package_data = find_package_data() # re-init build_py options which load package_data build_py.finalize_options() class NPM(Command): - description = 'install package.json dependencies using npm' + description = "install package.json dependencies using npm" user_options = [] - node_modules = os.path.join(node_root, 'node_modules') + node_modules = os.path.join(node_root, "node_modules") targets = [ - os.path.join(here, 'here_map_widget', 'static', 'extension.js'), - os.path.join(here, 'here_map_widget', 'static', 'index.js') + os.path.join(here, "here_map_widget", "static", "extension.js"), + os.path.join(here, "here_map_widget", "static", "index.js"), ] def initialize_options(self): @@ -87,22 +86,22 @@ def finalize_options(self): pass def get_npm_name(self): - npmName = 'npm'; - if platform.system() == 'Windows': - npmName = 'npm.cmd'; + npmName = "npm" + if platform.system() == "Windows": + npmName = "npm.cmd" - return npmName; + return npmName def has_npm(self): - npmName = self.get_npm_name(); + npmName = self.get_npm_name() try: - check_call([npmName, '--version']) + check_call([npmName, "--version"]) return True except: return False def should_run_npm_install(self): - package_json = os.path.join(node_root, 'package.json') + package_json = os.path.join(node_root, "package.json") node_modules_exists = os.path.exists(self.node_modules) return self.has_npm() @@ -110,26 +109,39 @@ def run(self): has_npm = self.has_npm() if not has_npm: log.error( - "`npm` unavailable. If you're running this command using sudo, make sure `npm` is available to sudo") + "`npm` unavailable. If you're running this command using sudo, make sure `npm` is available to sudo" + ) env = os.environ.copy() - env['PATH'] = npm_path + env["PATH"] = npm_path if self.should_run_npm_install(): log.info("Installing build dependencies with npm. This may take a while...") npmName = self.get_npm_name() - check_call(['npm', 'config', 'set', - '@here:registry https://repo.platform.here.com/artifactory/api/npm/here-node/'], - stdout=sys.stdout, stderr=sys.stderr) - check_call([npmName, 'install'], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr) - check_call(['npm', 'pack'], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr) + if platform.system() == "Windows": + check_call( + f"npm config set @here:registry https://repo.platform.here.com/artifactory/api/npm/here-node/ && {npmName} install", + cwd=node_root, + stdout=sys.stdout, + stderr=sys.stderr, + shell=True, + ) + else: + check_call( + f"npm config set @here:registry https://repo.platform.here.com/artifactory/api/npm/here-node/; {npmName} install", + cwd=node_root, + stdout=sys.stdout, + stderr=sys.stderr, + shell=True, + ) + check_call(["npm", "pack"], cwd=node_root, stdout=sys.stdout, stderr=sys.stderr) os.utime(self.node_modules, None) for t in self.targets: if not os.path.exists(t): - msg = 'Missing file: %s' % t + msg = "Missing file: %s" % t if not has_npm: - msg += '\nnpm is required to build a development version of a widget extension' + msg += "\nnpm is required to build a development version of a widget extension" raise ValueError(msg) # update package data in case this created new files @@ -137,14 +149,14 @@ def run(self): version_ns = {} -with open(os.path.join(here, 'here_map_widget', '_version.py')) as f: +with open(os.path.join(here, "here_map_widget", "_version.py")) as f: exec(f.read(), {}, version_ns) # Get the core dependencies and installs with open(os.path.join(here, "requirements.txt"), encoding="utf-8") as f: all_reqs = f.read().split("\n") -with open(os.path.join(here, 'README.md'), encoding='utf-8') as f: +with open(os.path.join(here, "README.md"), encoding="utf-8") as f: long_description = f.read() # get extra dependencies @@ -152,37 +164,35 @@ def run(self): dev_reqs = f.read().strip().split("\n") install_requires = [x.strip() for x in all_reqs if "git+" not in x] -dependency_links = [ - x.strip().replace("git+", "") for x in all_reqs if x.startswith("git+") -] +dependency_links = [x.strip().replace("git+", "") for x in all_reqs if x.startswith("git+")] -with open(os.path.join(node_root, 'package.json')) as fj: +with open(os.path.join(node_root, "package.json")) as fj: package_json = json.load(fj) -tgz = '%s-%s.tgz' % ('here-map-widget-for-jupyter', package_json['version']) +tgz = "%s-%s.tgz" % ("here-map-widget-for-jupyter", package_json["version"]) setup_args = { - 'version': version_ns['__version__'], - 'include_package_data': True, - 'data_files': [ - ('share/jupyter/nbextensions/map-widget-for-jupyter', glob('here_map_widget/static/*')), - ('etc/jupyter/nbconfig/notebook.d', ['map-widget-for-jupyter.json']), - ('share/jupyter/lab/extensions', ['js/' + tgz]), + "version": version_ns["__version__"], + "include_package_data": True, + "data_files": [ + ("share/jupyter/nbextensions/map-widget-for-jupyter", glob("here_map_widget/static/*")), + ("etc/jupyter/nbconfig/notebook.d", ["map-widget-for-jupyter.json"]), + ("share/jupyter/lab/extensions", ["js/" + tgz]), ], - 'install_requires': install_requires, - 'dependency_links': dependency_links, - 'packages': find_packages(), - 'zip_safe': False, - 'cmdclass': { - 'build_py': js_prerelease(build_py), - 'egg_info': js_prerelease(egg_info), - 'sdist': js_prerelease(sdist, strict=True), - 'jsdeps': NPM, + "install_requires": install_requires, + "dependency_links": dependency_links, + "packages": find_packages(), + "zip_safe": False, + "cmdclass": { + "build_py": js_prerelease(build_py), + "egg_info": js_prerelease(egg_info), + "sdist": js_prerelease(sdist, strict=True), + "jsdeps": NPM, }, - 'url': 'https://github.com/heremaps/here-map-widget-for-jupyter', - 'long_description': long_description, - 'long_description_content_type': 'text/markdown', - 'extras_require': {"dev": dev_reqs} + "url": "https://github.com/heremaps/here-map-widget-for-jupyter", + "long_description": long_description, + "long_description_content_type": "text/markdown", + "extras_require": {"dev": dev_reqs}, } setup(**setup_args)