-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updates build system to hatchling and deprecates setup.py - Bumps jupyter package compats in python and javascript
- Loading branch information
1 parent
ed377cf
commit cdc664b
Showing
6 changed files
with
117 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
## Requirements | ||
|
||
* JupyterLab >= 3.0 | ||
* JupyterLab >= 4.0 | ||
|
||
## Install | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,95 @@ | ||
[build-system] | ||
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1"] | ||
build-backend = "jupyter_packaging.build_api" | ||
requires = [ | ||
"hatchling>=1.5.0", | ||
"jupyterlab>=4.0.0,<5", | ||
"hatch-nodejs-version>=0.3.2" | ||
] | ||
build-backend = "hatchling.build" | ||
|
||
[tool.jupyter-packaging.options] | ||
skip-if-exists = ["webio_jupyter_extension/labextension/static/style.js"] | ||
ensured-targets = ["webio_jupyter_extension/labextension/static/style.js", "webio_jupyter_extension/labextension/package.json"] | ||
[project] | ||
name = "webio-jupyter-extension" | ||
readme = "README.md" | ||
license = { file = "LICENSE" } | ||
requires-python = ">=3.8" | ||
classifiers = [ | ||
"Framework :: Jupyter", | ||
"Framework :: Jupyter :: JupyterLab", | ||
"Framework :: Jupyter :: JupyterLab :: 4", | ||
"Framework :: Jupyter :: JupyterLab :: Extensions", | ||
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", | ||
"License :: OSI Approved :: BSD License", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
] | ||
dependencies = [ | ||
"jupyter_server>=2.0.1,<3" | ||
] | ||
dynamic = ["version", "description", "authors", "urls", "keywords"] | ||
|
||
[tool.jupyter-packaging.builder] | ||
factory = "jupyter_packaging.npm_builder" | ||
[tool.hatch.version] | ||
source = "nodejs" | ||
|
||
[tool.jupyter-packaging.build-args] | ||
[tool.hatch.metadata.hooks.nodejs] | ||
fields = ["description", "authors", "urls"] | ||
|
||
[tool.hatch.build.targets.wheel.shared-data] | ||
"install.json" = "share/jupyter/labextensions/webio-jupyterlab-provider/install.json" | ||
"webio_jupyter_extension/labextension" = "share/jupyter/labextensions/webio-jupyterlab-provider" | ||
"webio_jupyter_extension/nbextension" = "share/jupyter/nbextensions/webio-jupyter-nbextension" | ||
"jupyter-config/notebook-config" = "etc/jupyter/nbconfig/notebook.d" | ||
"jupyter-config/server-config" = "etc/jupyter/jupyter_server_config.d" | ||
"jupyter-config/nb-config" = "etc/jupyter/jupyter_notebook_config.d" | ||
|
||
[tool.hatch.build.targets.sdist] | ||
exclude = [".github", "binder"] | ||
artifacts = [ | ||
"webio_jupyter_extension/labextension", | ||
"webio_jupyter_extension/nbextension" | ||
] | ||
|
||
[tool.hatch.build.hooks.version] | ||
path = "webio_jupyter_extension/_version.py" | ||
|
||
[tool.hatch.build.hooks.jupyter-builder] | ||
dependencies = [ | ||
"hatch-jupyter-builder>=0.8.1", | ||
] | ||
build-function = "hatch_jupyter_builder.npm_builder" | ||
ensured-targets = [ | ||
"webio_jupyter_extension/labextension/static/style.js", | ||
"webio_jupyter_extension/labextension/package.json", | ||
] | ||
skip-if-exists = [ | ||
"webio_jupyter_extension/labextension/static/style.js", | ||
] | ||
|
||
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs] | ||
build_dir = "webio_jupyter_extension/labextension" | ||
source_dir = "webio-jupyter-labextension" | ||
build_cmd = "install:extension" | ||
npm = [ | ||
"jlpm", | ||
] | ||
|
||
[tool.hatch.build.hooks.jupyter-builder.build-kwargs] | ||
build_cmd = "build:prod" | ||
npm = ["jlpm"] | ||
|
||
[tool.check-manifest] | ||
ignore = ["webio_jupyter_extension/labextension/**", "yarn.lock", ".*", "package-lock.json"] | ||
[tool.jupyter-releaser.options] | ||
version_cmd = "hatch version" | ||
|
||
[tool.jupyter-releaser.hooks] | ||
before-build-npm = [ | ||
"python -m pip install 'jupyterlab>=4.0.0,<5'", | ||
"jlpm", | ||
"jlpm build:prod" | ||
] | ||
before-build-python = ["jlpm clean:all"] | ||
|
||
[tool.check-wheel-contents] | ||
ignore = ["W002"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,3 @@ | ||
""" | ||
webio_jupyter_extension setup | ||
""" | ||
import json | ||
import sys | ||
from pathlib import Path | ||
|
||
import setuptools | ||
|
||
HERE = Path(__file__).parent.resolve() | ||
|
||
# The name of the project | ||
name = "webio_jupyter_extension" | ||
|
||
lab_path = (HERE / name.replace("-", "_") / "labextension") | ||
nbextension_path = (HERE / name.replace("-", "_") / "nbextension") | ||
|
||
# Representative files that should exist after a successful build | ||
ensured_targets = [ | ||
str(lab_path / "package.json"), | ||
str(lab_path / "static/style.js") | ||
] | ||
|
||
# Get the package info from package.json | ||
pkg_json = json.loads((HERE / "package.json").read_bytes()) | ||
labext_name = pkg_json["name"] | ||
|
||
data_files_spec = [ | ||
# labextension files | ||
(f"share/jupyter/labextensions/{labext_name}", str("."), "install.json"), | ||
(f"share/jupyter/labextensions/{labext_name}", str(lab_path.relative_to(HERE)), "**"), | ||
|
||
# nbextension files | ||
('share/jupyter/nbextensions/webio-jupyter-nbextension', str(nbextension_path.relative_to(HERE)), '**'), | ||
('etc/jupyter/nbconfig/notebook.d' , "jupyter-config/notebook-config", 'webio-jupyter-nbextension.json'), | ||
|
||
# serverextension files | ||
("etc/jupyter/jupyter_server_config.d", "jupyter-config/server-config", f"{name}.json"), | ||
# For backward compatibility with notebook server | ||
("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/nb-config", f"{name}.json"), | ||
] | ||
|
||
long_description = (HERE / "README.md").read_text() | ||
|
||
|
||
setup_args = dict( | ||
name=name, | ||
version=pkg_json["version"], | ||
description=pkg_json["description"], | ||
license=pkg_json["license"], | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
packages=setuptools.find_packages(), | ||
install_requires=[], | ||
zip_safe=False, | ||
include_package_data=True, | ||
python_requires=">=3.6", | ||
platforms="Linux, Mac OS X, Windows", | ||
keywords=["Jupyter", "JupyterLab", "JupyterLab3"], | ||
classifiers=[ | ||
"License :: OSI Approved :: BSD License", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Framework :: Jupyter", | ||
"Framework :: Jupyter :: JupyterLab", | ||
"Framework :: Jupyter :: JupyterLab :: 3", | ||
"Framework :: Jupyter :: JupyterLab :: Extensions", | ||
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", | ||
], | ||
) | ||
|
||
try: | ||
from jupyter_packaging import ( | ||
wrap_installers, | ||
npm_builder, | ||
get_data_files | ||
) | ||
post_develop = npm_builder( | ||
build_cmd="install:extension", source_dir="src", build_dir=lab_path | ||
) | ||
setup_args["cmdclass"] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) | ||
setup_args["data_files"] = get_data_files(data_files_spec) | ||
except ImportError as e: | ||
import logging | ||
logging.basicConfig(format="%(levelname)s: %(message)s") | ||
logging.warning("Build tool `jupyter-packaging` is missing. Install it with pip or conda.") | ||
if not ("--name" in sys.argv or "--version" in sys.argv): | ||
raise e | ||
|
||
if __name__ == "__main__": | ||
setuptools.setup(**setup_args) | ||
# setup.py shim for use with versions of JupyterLab that require | ||
# it for extensions. | ||
__import__("setuptools").setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 4 additions & 18 deletions
22
webio_jupyter_extension/webio_jupyter_extension/_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,4 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
__all__ = ["__version__"] | ||
|
||
def _fetchVersion(): | ||
HERE = Path(__file__).parent.resolve() | ||
|
||
for settings in HERE.rglob("package.json"): | ||
try: | ||
with settings.open() as f: | ||
return json.load(f)["version"] | ||
except FileNotFoundError: | ||
pass | ||
|
||
raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}") | ||
|
||
__version__ = _fetchVersion() | ||
# This file is auto-generated by Hatchling. As such, do not: | ||
# - modify | ||
# - track in version control e.g. be sure to add to .gitignore | ||
__version__ = VERSION = '0.2.0' |