Skip to content

Update example to use hatch #1169

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

Merged
merged 1 commit into from
Jan 8, 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ docs/source/other/full-config.rst
.history
.vscode/*
!.vscode/*.template

# Compiled static file in example.
examples/simple/simple_ext1/static/bundle.js
39 changes: 37 additions & 2 deletions examples/simple/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
[build-system]
requires = ["jupyter_packaging~=0.5.0", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["hatchling","hatch-nodejs-version"]
build-backend = "hatchling.build"

[project]
name = "jupyter-server-example"
description = "Jupyter Server Example"
readme = "README.md"
license = ""
requires-python = ">=3.8"
dependencies = [
"jinja2",
"jupyter_server",
]
dynamic = ["version"]

[project.optional-dependencies]
test = [
"pytest",
"pytest-asyncio",
]

[project.scripts]
jupyter-simple-ext1 = "simple_ext1.application:main"
jupyter-simple-ext11 = "simple_ext11.application:main"
jupyter-simple-ext2 = "simple_ext2.application:main"

[tool.hatch.version]
source = "nodejs"

[tool.hatch.build.targets.wheel.shared-data]
"etc/jupyter/jupyter_server_config.d" = "etc/jupyter/jupyter_server_config.d"

[tool.hatch.build.hooks.jupyter-builder]
dependencies = [
"hatch-jupyter-builder>=0.8.2",
]
build-function = "hatch_jupyter_builder.npm_builder"
64 changes: 2 additions & 62 deletions examples/simple/setup.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,2 @@
"""Example Jupyter Server setup."""
import os

from jupyter_packaging import create_cmdclass # type:ignore
from setuptools import setup

VERSION = "0.0.1"


def get_data_files():
"""Get the data files for the package."""
data_files = [
(
"etc/jupyter/jupyter_server_config.d",
"etc/jupyter/jupyter_server_config.d/",
"*.json",
),
]

def add_data_files(path):
for (dirpath, _, filenames) in os.walk(path):
if filenames:
paths = [(dirpath, dirpath, filename) for filename in filenames]
data_files.extend(paths)

# Add all static and templates folders.
add_data_files("simple_ext1/static")
add_data_files("simple_ext1/templates")
add_data_files("simple_ext2/static")
add_data_files("simple_ext2/templates")
return data_files


cmdclass = create_cmdclass(data_files_spec=get_data_files())

setup_args = {
"name": "jupyter_server_example",
"version": VERSION,
"description": "Jupyter Server Example",
"long_description": open("README.md").read(),
"python_requires": ">=3.8",
"install_requires": [
"jupyter_server",
"jinja2",
],
"extras_require": {
"test": ["pytest", "pytest-asyncio"],
},
"include_package_data": True,
"cmdclass": cmdclass,
"entry_points": {
"console_scripts": [
"jupyter-simple-ext1 = simple_ext1.application:main",
"jupyter-simple-ext11 = simple_ext11.application:main",
"jupyter-simple-ext2 = simple_ext2.application:main",
]
},
}


if __name__ == "__main__":
setup(**setup_args)
# setup.py shim for use with applications that require it.
__import__("setuptools").setup()
144 changes: 0 additions & 144 deletions examples/simple/simple_ext1/static/bundle.js

This file was deleted.

4 changes: 2 additions & 2 deletions examples/simple/simple_ext1/static/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function main() {
let div = document.getElementById("mydiv");
div.innerText = "Hello from Typescript";
let div = document.getElementById("mydiv");
div.innerText = "Hello from Typescript";
}
window.addEventListener("load", main);
2 changes: 1 addition & 1 deletion examples/simple/simple_ext1/static/tsconfig.tsbuildinfo
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"signature": "3e0a459888f32b42138d5a39f706ff2d55d500ab1031e0988b5568b0f67c2303"
},
"../../src/index.ts": {
"version": "fd4f62325debd29128c1990caa4d546f2c48c21ea133fbcbb3e29f9fbef55e49",
"version": "a5398b1577287a9a5a7e190a9a7283ee67b12fcc0dbc6d2cac55ef25ed166bb2",
"signature": "ed4b087ea2a2e4a58647864cf512c7534210bfc2f9d236a2f9ed5245cf7a0896"
}
},
Expand Down