Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to hatch #168

Merged
merged 12 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[flake8]
max-line-length=200
# Ignore style and complexity
# E: style errors
# W: style warnings
# F401: module imported but unused
# F811: redefinition of unused `name` from line `N`
# F841: local variable assigned but never used
ignore = E, C, W, F401, F403, F811, F841, E402, I100, I101, D400
exclude =
jupyter-resource-usage/tests,
helm-chart,
hooks,
setup.py,
statuspage,
versioneer.py
25 changes: 0 additions & 25 deletions MANIFEST.in

This file was deleted.

7 changes: 1 addition & 6 deletions jupyter_resource_usage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import json
from pathlib import Path

from ._version import __version__
from .server_extension import load_jupyter_server_extension

HERE = Path(__file__).parent.resolve()

data = json.loads((HERE / "labextension" / "package.json").read_text())


def _jupyter_labextension_paths():
return [{"src": "labextension", "dest": data["name"]}]
return [{"src": "labextension", "dest": "@jupyter-server/resource-usage"}]


def _jupyter_server_extension_points():
Expand Down
117 changes: 103 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,104 @@
[build-system]
requires = ["jupyter_packaging~=0.10", "jupyterlab~=3.0"]
build-backend = "jupyter_packaging.build_api"
requires = [
"hatchling",
"jupyterlab~=3.0",
]
build-backend = "hatchling.build"

[license]
file="LICENSE"
[project]
name = "jupyter-resource-usage"
description = "Jupyter Extension to show resource usage"
readme = "README.md"
requires-python = ">=3.7"
authors = [
{ name = "Jupyter Development Team" },
]
keywords = [
"IPython",
"Jupyter",
"JupyterLab",
]
classifiers = [
"Framework :: Jupyter",
"Framework :: Jupyter :: JupyterLab",
"Framework :: Jupyter :: JupyterLab :: 3",
"Framework :: Jupyter :: JupyterLab :: Extensions",
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"jupyter_server>=1.0",
"prometheus_client",
"psutil~=5.6",
]
dynamic = ["version"]

[tool.jupyter-packaging.options]
skip-if-exists = ["jupyter_resource_usage/labextension/static/style.js"]
ensured-targets = ["jupyter_resource_usage/labextension/static/style.js", "jupyter_resource_usage/labextension/package.json"]
[project.license]
file = "LICENSE"

[tool.jupyter-packaging.builder]
factory = "jupyter_packaging.npm_builder"
[project.optional-dependencies]
dev = [
"autopep8",
"black",
"flake8",
"mock",
"pytest",
"pytest-cov>=2.6.1",
]

[tool.jupyter-packaging.build-args]
[project.urls]
Homepage = "https://github.com/jupyter-server/jupyter-resource-usage"

[tool.hatch.build.targets.wheel.shared-data]
"jupyter_resource_usage/static" = "share/jupyter/nbextensions/jupyter_resource_usage"
"jupyter_resource_usage/labextension/package.json" = "share/jupyter/labextensions/@jupyter-server/resource-usage/package.json"
"jupyter_resource_usage/labextension/static" = "share/jupyter/labextensions/@jupyter-server/resource-usage/static"
"install.json" = "share/jupyter/labextensions/@jupyter-server/resource-usage/install.json"
"jupyter-config/jupyter_server_config.d" = "etc/jupyter/jupyter_server_config.d"
"jupyter-config/jupyter_notebook_config.d" = "etc/jupyter/jupyter_notebook_config.d"
"jupyter-config/nbconfig/notebook.d" = "etc/jupyter/nbconfig/notebook.d"

[tool.hatch.version]
path = "jupyter_resource_usage/_version.py"

[tool.hatch.build.targets.sdist]
artifacts = ["jupyter_resource_usage/labextension"]
exclude = [".github", "binder"]

[tool.hatch.build.hooks.jupyter-builder]
dependencies = [
"hatch-jupyter-builder>=0.8.2",
]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"jupyter_resource_usage/labextension/static/style.js",
"jupyter_resource_usage/labextension/package.json",
]
skip-if-exists = [
"jupyter_resource_usage/labextension/static/style.js",
]

[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
build_cmd = "build:prod"
npm = [
"jlpm",
]
force = true

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
npm = ["jlpm"]
npm = [
"jlpm",
]
source_dir = "packages/labextension"
build_dir = "jupyter_resource_usage/labextension"

Expand Down Expand Up @@ -44,7 +128,12 @@ name = "release"
default = ""

[tool.jupyter-releaser.hooks]
before-build-npm = ["python -m pip install jupyterlab~=3.0", "jlpm", "jlpm clean", "jlpm build:prod"]
before-build-npm = [
"python -m pip install jupyterlab~=3.0",
"jlpm",
"jlpm clean",
"jlpm build:prod",
]

[tool.check-manifest]
ignore = ["binder/**", "packages/**", "*.json", "*.png", "yarn.lock", ".*", "jupyter_resource_usage/labextension/**", "jupyter_resource_usage/static/**"]
[tool.check-wheel-contents]
ignore = ["W002", "W004"]
63 changes: 0 additions & 63 deletions setup.cfg

This file was deleted.

56 changes: 2 additions & 54 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,2 @@
from pathlib import Path

import setuptools

# The directory containing this file
HERE = Path(__file__).parent.resolve()

# The name of the project
NAME = "jupyter-resource-usage"
PACKAGE_NAME = NAME.replace("-", "_")
LABEXT_NAME = "@jupyter-server/resource-usage"
NBEXT_NAME = "jupyter_resource_usage"


lab_path = HERE / PACKAGE_NAME / "labextension"
nb_path = HERE / PACKAGE_NAME / "static"
src_path = HERE / "packages" / "labextension"

# Representative files that should exist after a successful build
ensured_targets = [str(lab_path / "package.json"), str(lab_path / "static/style.js")]

data_files_spec = [
("share/jupyter/nbextensions/%s" % NBEXT_NAME, nb_path, "**"),
("share/jupyter/labextensions/%s" % LABEXT_NAME, lab_path, "**"),
("share/jupyter/labextensions/%s" % LABEXT_NAME, HERE, "install.json"),
(
"etc/jupyter/jupyter_server_config.d",
"jupyter-config/jupyter_server_config.d",
"jupyter_resource_usage.json",
),
(
"etc/jupyter/jupyter_notebook_config.d",
"jupyter-config/jupyter_notebook_config.d",
"jupyter_resource_usage.json",
),
(
"etc/jupyter/nbconfig/notebook.d",
"jupyter-config/nbconfig/notebook.d",
"jupyter_resource_usage.json",
),
]

try:
from jupyter_packaging import wrap_installers, npm_builder, get_data_files

builder = npm_builder(build_cmd="build:prod", npm="jlpm", force=True)
cmdclass = wrap_installers(post_develop=builder, ensured_targets=ensured_targets)
setup_args = dict(cmdclass=cmdclass, data_files=get_data_files(data_files_spec))
except ImportError:
setup_args = dict()


if __name__ == "__main__":
setuptools.setup(**setup_args)
# setup.py shim for use with applications that require it.
__import__("setuptools").setup()