From ef674bcb5775bf13dff5e3d0528998a4c16408ae Mon Sep 17 00:00:00 2001 From: gjmooney Date: Wed, 10 Jan 2024 14:04:28 +0100 Subject: [PATCH 1/4] Migrate to Hatch --- environment-dev.yml | 1 + ipyleaflet/__init__.py | 2 +- ipyleaflet/_version.py | 5 +- pyproject.toml | 112 +++++++++++++++++++++++++++++- setup.cfg | 4 +- setup.py | 150 +++++++++++++++++++++-------------------- 6 files changed, 193 insertions(+), 81 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index 01f717f51..ffdd82f86 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -3,6 +3,7 @@ channels: - conda-forge dependencies: - pip + - build - wheel - jupyterlab~=4.0 - jupyter-packaging~=0.12 diff --git a/ipyleaflet/__init__.py b/ipyleaflet/__init__.py index bd3d72d28..9523c8bcd 100644 --- a/ipyleaflet/__init__.py +++ b/ipyleaflet/__init__.py @@ -3,7 +3,7 @@ # import sys -from ._version import version_info, __version__ # noqa +from ._version import __version__ # noqa from .leaflet import * # noqa from .basemaps import basemaps # noqa diff --git a/ipyleaflet/_version.py b/ipyleaflet/_version.py index b18e5c347..6a5176e6d 100644 --- a/ipyleaflet/_version.py +++ b/ipyleaflet/_version.py @@ -2,8 +2,9 @@ # Distributed under the terms of the Modified BSD License. # -version_info = (0, 18, 1) +# version_info = (0, 18, 1) -__version__ = "%s.%s.%s" % (version_info[0], version_info[1], version_info[2]) +# __version__ = "%s.%s.%s" % (version_info[0], version_info[1], version_info[2]) EXTENSION_VERSION = "^0.18" +__version__ = "0.18.1" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 223f81c1c..cb1ffee77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,113 @@ +# [build-system] +# # avoid 3.6 so we don't need the rust buildchain +# requires = ["jupyter_packaging~=0.12", "jupyterlab~=4.0.8", "setuptools>=40.8.0", "wheel"] +# build-backend = "setuptools.build_meta" + + [build-system] -# avoid 3.6 so we don't need the rust buildchain -requires = ["jupyter_packaging~=0.12", "jupyterlab~=4.0.8", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = [ + "hatchling", + "jupyterlab==4.*", +] +build-backend = "hatchling.build" + +[project] +name = "ipyleaflet" +version = "0.18.1" +description = "A Jupyter widget for dynamic Leaflet maps" +readme = "README.md" +authors = [ + { name = "Project Jupyter", email = "jupyter@googlegroups.com" }, +] +keywords = [ + "ipython", "jupyter", "widgets", "graphics", "GIS", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Topic :: Multimedia :: Graphics", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", +] +dependencies = [ + "ipywidgets>=7.6.0,<9", + "traittypes>=0.2.1,<3", + "xyzservices>=2021.8.1", + "branca>=0.5.0", +] + +# [project.license] +# file = "LICENSE.txt" + +[project.optional-dependencies] + +[project.urls] +Homepage = "https://github.com/jupyter-widgets/ipyleaflet" + +[tool.hatch.build] +artifacts = [ + "ipyleaflet/nbextension/index.*", + "ipyleaflet/labextension", +] + +# TODO nbextension +[tool.hatch.build.targets.wheel.shared-data] +"ipyleaflet/nbextension" = "share/jupyter/nbextensions/jupyter-leaflet" +"ipyleaflet/labextension" = "share/jupyter/labextensions/jupyter-Leaflet" +"jupyter-leaflet.json" = "etc/jupyter/nbconfig/notebook.d/jupyter-leaflet.json" + +[tool.hatch.build.targets.sdist] +exclude = [ + ".github", +] + +[tool.hatch.build.hooks.jupyter-builder] +ensured-targets = [ + "ipyleaflet/nbextension/index.js", + "ipyleaflet/labextension/package.json", +] +dependencies = [ + "hatch-jupyter-builder>=0.8.1", +] +build-function = "hatch_jupyter_builder.npm_builder" + +[tool.hatch.build.hooks.jupyter-builder.build-kwargs] +path = "./js" +build_cmd = "build:extensions" +npm = [ + "jlpm", # TODO jlpm? +] + +# TODO tbump? +# [tool.tbump] +# field = [ +# { name = "channel", default = "" }, +# { name = "release", default = "" }, +# ] + +# [tool.tbump.version] +# current = "0.13.1" +# regex = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)((?Pa|b|rc|.dev)(?P\\d+))?" + +# [tool.tbump.git] +# message_template = "Bump to {new_version}" +# tag_template = "v{new_version}" + +# [[tool.tbump.file]] +# src = "pyproject.toml" +# version_template = "version = \"{major}.{minor}.{patch}{channel}{release}\"" + +# [[tool.tbump.file]] +# src = "ipyleaflet/_version.py" + +# [[tool.tbump.file]] +# src = "package.json" +# version_template = "\"version\": \"{major}.{minor}.{patch}{channel}{release}" [tool.ruff] extend-include = ["*.ipynb"] diff --git a/setup.cfg b/setup.cfg index 0c9e0fc14..44e9bfee4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ -[metadata] -license_file = LICENSE +# [metadata] +# license_file = LICENSE diff --git a/setup.py b/setup.py index b5c041ddb..336050996 100644 --- a/setup.py +++ b/setup.py @@ -1,85 +1,89 @@ -# -*- coding: utf-8 -*- +__import__("setuptools").setup() -import os -from setuptools import setup, find_packages +# Copyright (c) Jupyter Development Team. -from jupyter_packaging import ( - create_cmdclass, - install_npm, - ensure_targets, - combine_commands, - get_version, - skip_if_exists, -) +# # -*- coding: utf-8 -*- -# the name of the package -name = "ipyleaflet" -long_description = "A Jupyter widget for dynamic Leaflet maps" +# import os +# from setuptools import setup, find_packages -here = os.path.dirname(os.path.abspath(__file__)) +# from jupyter_packaging import ( +# create_cmdclass, +# install_npm, +# ensure_targets, +# combine_commands, +# get_version, +# skip_if_exists, +# ) -# Get ipyleaflet version -version = get_version(os.path.join(name, "_version.py")) +# # the name of the package +# name = "ipyleaflet" +# long_description = "A Jupyter widget for dynamic Leaflet maps" -js_dir = os.path.join(here, "js") +# here = os.path.dirname(os.path.abspath(__file__)) -# Representative files that should exist after a successful build -jstargets = [ - os.path.join("ipyleaflet/nbextension", "index.js"), - os.path.join("ipyleaflet/labextension", "package.json"), -] +# # Get ipyleaflet version +# version = get_version(os.path.join(name, "_version.py")) -data_files_spec = [ - ("share/jupyter/nbextensions/jupyter-leaflet", "ipyleaflet/nbextension", "*.*"), - ("share/jupyter/labextensions/jupyter-leaflet", "ipyleaflet/labextension", "**"), - ("etc/jupyter/nbconfig/notebook.d", ".", "jupyter-leaflet.json"), -] +# js_dir = os.path.join(here, "js") -cmdclass = create_cmdclass("jsdeps", data_files_spec=data_files_spec) -js_command = combine_commands( - install_npm(js_dir, npm=["yarn"], build_cmd="build"), - ensure_targets(jstargets), -) +# # Representative files that should exist after a successful build +# jstargets = [ +# os.path.join("ipyleaflet/nbextension", "index.js"), +# os.path.join("ipyleaflet/labextension", "package.json"), +# ] -is_repo = os.path.exists(os.path.join(here, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +# data_files_spec = [ +# ("share/jupyter/nbextensions/jupyter-leaflet", "ipyleaflet/nbextension", "*.*"), +# ("share/jupyter/labextensions/jupyter-leaflet", "ipyleaflet/labextension", "**"), +# ("etc/jupyter/nbconfig/notebook.d", ".", "jupyter-leaflet.json"), +# ] -setup_args = dict( - name=name, - version=version, - description="A Jupyter widget for dynamic Leaflet maps", - long_description=long_description, - license="MIT License", - python_requires=">=3.7", - include_package_data=True, - install_requires=[ - "ipywidgets>=7.6.0,<9", - "traittypes>=0.2.1,<3", - "xyzservices>=2021.8.1", - "branca>=0.5.0", - ], - packages=find_packages(), - zip_safe=False, - cmdclass=cmdclass, - author="Project Jupyter", - author_email="jupyter@googlegroups.com", - url="https://github.com/jupyter-widgets/ipyleaflet", - keywords=["ipython", "jupyter", "widgets", "graphics", "GIS"], - classifiers=[ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - "Topic :: Multimedia :: Graphics", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - ], -) +# cmdclass = create_cmdclass("jsdeps", data_files_spec=data_files_spec) +# js_command = combine_commands( +# install_npm(js_dir, npm=["yarn"], build_cmd="build"), +# ensure_targets(jstargets), +# ) -setup(**setup_args) +# is_repo = os.path.exists(os.path.join(here, ".git")) +# if is_repo: +# cmdclass["jsdeps"] = js_command +# else: +# cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +# setup_args = dict( +# # name=name, +# # version=version, +# # description="A Jupyter widget for dynamic Leaflet maps", +# # long_description=long_description, +# # license="MIT License", +# python_requires=">=3.7", +# include_package_data=True, +# # install_requires=[ +# # "ipywidgets>=7.6.0,<9", +# # "traittypes>=0.2.1,<3", +# # "xyzservices>=2021.8.1", +# # "branca>=0.5.0", +# # ], +# packages=find_packages(), +# zip_safe=False, +# cmdclass=cmdclass, +# # author="Project Jupyter", +# # author_email="jupyter@googlegroups.com", +# # url="https://github.com/jupyter-widgets/ipyleaflet", +# # keywords=["ipython", "jupyter", "widgets", "graphics", "GIS"], +# # classifiers=[ +# # "Development Status :: 4 - Beta", +# # "Intended Audience :: Developers", +# # "Intended Audience :: Science/Research", +# # "Topic :: Multimedia :: Graphics", +# # "License :: OSI Approved :: MIT License", +# # "Programming Language :: Python :: 3", +# # "Programming Language :: Python :: 3.7", +# # "Programming Language :: Python :: 3.8", +# # "Programming Language :: Python :: 3.9", +# # "Programming Language :: Python :: 3.10", +# # ], +# ) + +# setup(**setup_args) From d26ba08c8d2a6cad2e8ed8dfd5270f36c7719741 Mon Sep 17 00:00:00 2001 From: gjmooney Date: Wed, 10 Jan 2024 14:15:10 +0100 Subject: [PATCH 2/4] Remove extraneous build script --- js/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/js/package.json b/js/package.json index 9681f6e78..bb58764b5 100644 --- a/js/package.json +++ b/js/package.json @@ -25,7 +25,6 @@ "build:lib": "tsc", "build:nbextension": "webpack --no-devtool", "build:labextension": "jupyter labextension build .", - "build:extensions": "yarn run build && yarn run build:labextension", "clean": "yarn run clean:lib && yarn run clean:nbextension && yarn run clean:labextension", "clean:lib": "rimraf lib", "clean:nbextension": "rimraf ../ipyleaflet/nbextension/index.js", From 7a5133c27eabecaab1b993f6fbd0d16ab51b9867 Mon Sep 17 00:00:00 2001 From: gjmooney Date: Wed, 10 Jan 2024 14:15:23 +0100 Subject: [PATCH 3/4] Fix a typo --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cb1ffee77..e24bdc2ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ artifacts = [ # TODO nbextension [tool.hatch.build.targets.wheel.shared-data] "ipyleaflet/nbextension" = "share/jupyter/nbextensions/jupyter-leaflet" -"ipyleaflet/labextension" = "share/jupyter/labextensions/jupyter-Leaflet" +"ipyleaflet/labextension" = "share/jupyter/labextensions/jupyter-leaflet" "jupyter-leaflet.json" = "etc/jupyter/nbconfig/notebook.d/jupyter-leaflet.json" [tool.hatch.build.targets.sdist] @@ -78,7 +78,7 @@ build-function = "hatch_jupyter_builder.npm_builder" [tool.hatch.build.hooks.jupyter-builder.build-kwargs] path = "./js" -build_cmd = "build:extensions" +build_cmd = "build" npm = [ "jlpm", # TODO jlpm? ] From c44a38b6d6a1ca7864093b0b88ca4eaf3ecf9e85 Mon Sep 17 00:00:00 2001 From: gjmooney Date: Wed, 10 Jan 2024 14:55:34 +0100 Subject: [PATCH 4/4] Remove commented lines --- ipyleaflet/_version.py | 5 --- pyproject.toml | 40 +------------------ setup.cfg | 2 - setup.py | 89 +----------------------------------------- 4 files changed, 2 insertions(+), 134 deletions(-) delete mode 100644 setup.cfg diff --git a/ipyleaflet/_version.py b/ipyleaflet/_version.py index 6a5176e6d..00a8253d1 100644 --- a/ipyleaflet/_version.py +++ b/ipyleaflet/_version.py @@ -1,10 +1,5 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -# - -# version_info = (0, 18, 1) - -# __version__ = "%s.%s.%s" % (version_info[0], version_info[1], version_info[2]) EXTENSION_VERSION = "^0.18" __version__ = "0.18.1" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index e24bdc2ed..3c9ac9b7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,3 @@ -# [build-system] -# # avoid 3.6 so we don't need the rust buildchain -# requires = ["jupyter_packaging~=0.12", "jupyterlab~=4.0.8", "setuptools>=40.8.0", "wheel"] -# build-backend = "setuptools.build_meta" - - [build-system] requires = [ "hatchling", @@ -41,11 +35,6 @@ dependencies = [ "branca>=0.5.0", ] -# [project.license] -# file = "LICENSE.txt" - -[project.optional-dependencies] - [project.urls] Homepage = "https://github.com/jupyter-widgets/ipyleaflet" @@ -55,7 +44,6 @@ artifacts = [ "ipyleaflet/labextension", ] -# TODO nbextension [tool.hatch.build.targets.wheel.shared-data] "ipyleaflet/nbextension" = "share/jupyter/nbextensions/jupyter-leaflet" "ipyleaflet/labextension" = "share/jupyter/labextensions/jupyter-leaflet" @@ -80,35 +68,9 @@ build-function = "hatch_jupyter_builder.npm_builder" path = "./js" build_cmd = "build" npm = [ - "jlpm", # TODO jlpm? + "jlpm", ] -# TODO tbump? -# [tool.tbump] -# field = [ -# { name = "channel", default = "" }, -# { name = "release", default = "" }, -# ] - -# [tool.tbump.version] -# current = "0.13.1" -# regex = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)((?Pa|b|rc|.dev)(?P\\d+))?" - -# [tool.tbump.git] -# message_template = "Bump to {new_version}" -# tag_template = "v{new_version}" - -# [[tool.tbump.file]] -# src = "pyproject.toml" -# version_template = "version = \"{major}.{minor}.{patch}{channel}{release}\"" - -# [[tool.tbump.file]] -# src = "ipyleaflet/_version.py" - -# [[tool.tbump.file]] -# src = "package.json" -# version_template = "\"version\": \"{major}.{minor}.{patch}{channel}{release}" - [tool.ruff] extend-include = ["*.ipynb"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 44e9bfee4..000000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -# [metadata] -# license_file = LICENSE diff --git a/setup.py b/setup.py index 336050996..20b64fb33 100644 --- a/setup.py +++ b/setup.py @@ -1,89 +1,2 @@ -__import__("setuptools").setup() - # Copyright (c) Jupyter Development Team. - -# # -*- coding: utf-8 -*- - -# import os -# from setuptools import setup, find_packages - -# from jupyter_packaging import ( -# create_cmdclass, -# install_npm, -# ensure_targets, -# combine_commands, -# get_version, -# skip_if_exists, -# ) - -# # the name of the package -# name = "ipyleaflet" -# long_description = "A Jupyter widget for dynamic Leaflet maps" - -# here = os.path.dirname(os.path.abspath(__file__)) - -# # Get ipyleaflet version -# version = get_version(os.path.join(name, "_version.py")) - -# js_dir = os.path.join(here, "js") - -# # Representative files that should exist after a successful build -# jstargets = [ -# os.path.join("ipyleaflet/nbextension", "index.js"), -# os.path.join("ipyleaflet/labextension", "package.json"), -# ] - -# data_files_spec = [ -# ("share/jupyter/nbextensions/jupyter-leaflet", "ipyleaflet/nbextension", "*.*"), -# ("share/jupyter/labextensions/jupyter-leaflet", "ipyleaflet/labextension", "**"), -# ("etc/jupyter/nbconfig/notebook.d", ".", "jupyter-leaflet.json"), -# ] - -# cmdclass = create_cmdclass("jsdeps", data_files_spec=data_files_spec) -# js_command = combine_commands( -# install_npm(js_dir, npm=["yarn"], build_cmd="build"), -# ensure_targets(jstargets), -# ) - -# is_repo = os.path.exists(os.path.join(here, ".git")) -# if is_repo: -# cmdclass["jsdeps"] = js_command -# else: -# cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) - -# setup_args = dict( -# # name=name, -# # version=version, -# # description="A Jupyter widget for dynamic Leaflet maps", -# # long_description=long_description, -# # license="MIT License", -# python_requires=">=3.7", -# include_package_data=True, -# # install_requires=[ -# # "ipywidgets>=7.6.0,<9", -# # "traittypes>=0.2.1,<3", -# # "xyzservices>=2021.8.1", -# # "branca>=0.5.0", -# # ], -# packages=find_packages(), -# zip_safe=False, -# cmdclass=cmdclass, -# # author="Project Jupyter", -# # author_email="jupyter@googlegroups.com", -# # url="https://github.com/jupyter-widgets/ipyleaflet", -# # keywords=["ipython", "jupyter", "widgets", "graphics", "GIS"], -# # classifiers=[ -# # "Development Status :: 4 - Beta", -# # "Intended Audience :: Developers", -# # "Intended Audience :: Science/Research", -# # "Topic :: Multimedia :: Graphics", -# # "License :: OSI Approved :: MIT License", -# # "Programming Language :: Python :: 3", -# # "Programming Language :: Python :: 3.7", -# # "Programming Language :: Python :: 3.8", -# # "Programming Language :: Python :: 3.9", -# # "Programming Language :: Python :: 3.10", -# # ], -# ) - -# setup(**setup_args) +__import__("setuptools").setup() \ No newline at end of file