Skip to content

Commit

Permalink
Merge pull request #61 from cmd-ntrf/pyproject
Browse files Browse the repository at this point in the history
Make setup.py install labextension and replace setup.py by pyproject.toml
  • Loading branch information
cmd-ntrf authored Mar 29, 2023
2 parents 5453398 + e27e47c commit 2664e67
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 99 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
pip install build wheel twine
- name: Build dist
run: |
pyproject-build
cd dist && sha256sum * | tee SHA256SUMS
- name: Publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ jupyterlmod.egg-info/
*.lock
*env*/
package-lock.json
jupyterlmod/labextension
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ proxy server launchers to JupyterLab UI when modules with matching names are loa
pip install jupyterlmod
```

### jupyterlab

```
jupyter labextension install jupyterlab-lmod
```

### Disable jupyter-server-proxy notebook and lab extensions

To avoid having items in the launcher that cannot be launched because the binaries location are not in PATH,
Expand Down Expand Up @@ -63,3 +57,27 @@ c.Lmod.launcher_pins = ['Desktop', 'RStudio']
![Jupyter notebook demo](https://i.imgur.com/pK1Q5gG.gif)

![JupyterLab demo](https://i.imgur.com/1HDH7iN.gif)


## develop

### requirements

- pip >= 23
- [build](https://pypi.org/project/build/)
- nodejs >= 18.x

### build

- wheel and tarball:
```shell
pyproject-build
```
- labextension
```shell
cd jupyterlab
npm install
npm run build
# To install extension in jupyterlab in develop mode:
npm run install:extension
```
45 changes: 0 additions & 45 deletions jupyterlab/package.json

This file was deleted.

File renamed without changes.
69 changes: 69 additions & 0 deletions labextension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "@cmd-ntrf/jupyterlab-lmod",
"version": "4.0.0",
"description": "Lmod JupyterLab extension",
"keywords": [
"jupyter",
"jupyterlab",
"jupyterlab-extension"
],
"homepage": "https://github.com/cmd-ntrf/jupyter-lmod",
"bugs": {
"url": "https://github.com/cmd-ntrf/jupyter-lmod/issues"
},
"license": "MIT",
"author": {
"name": "Felix-Antoine Fortin",
"email": "[email protected]"
},
"contributors": [
{ "name": "Étienne Dubeau" },
{ "name": "Guillaume Moutier" },
{ "name": "Alex Domingo" }
],
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"style/*.css"
],
"main": "lib/labextension/src/index.js",
"types": "lib/labextension/src/index.d.ts",
"style": "style/index.css",
"repository": {
"type": "git",
"url": "https://github.com/cmd-ntrf/jupyter-lmod.git"
},
"scripts": {
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
"build:prod": "jlpm run build:lib && jlpm run build:labextension",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"build:lib": "tsc",
"clean": "jlpm run clean:lib",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"clean:labextension": "rimraf jupyterlab-lmod/labextension",
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
"eslint": "eslint . --ext .ts,.tsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx",
"eslint:check:junit": "eslint . --ext .ts,.tsx --format junit --output-file linting.xml",
"install:extension": "jupyter labextension develop --overwrite .",
"prepare": "jlpm run clean && jlpm run build:prod",
"watch": "run-p watch:src watch:labextension",
"watch:src": "tsc -w",
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyterlab/application": "^2.0.0 || ^3.0.0",
"@jupyterlab/launcher": "^2.0.0 || ^3.0.0",
"@jupyterlab/server-proxy": "^3.1.0"
},
"devDependencies": {
"rimraf": "~3.0.2",
"typescript": "~4.1.3",
"@jupyterlab/builder": "^3.6.1"
},
"jupyterlab": {
"extension": true,
"schemaDir": "schema",
"outputDir": "../jupyterlmod/labextension"
}
}
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions jupyterlab/tsconfig.json → labextension/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"compilerOptions": {
"lib": ["es2017", "dom"],
"lib": ["es2018", "dom"],
"module": "commonjs",
"esModuleInterop" : true,
"moduleResolution": "node",
"noEmitOnError": true,
"noUnusedLocals": true,
"outDir": "./lib",
"target": "es2017",
"target": "es2018",
"strict": true,
"strictNullChecks": false,
"noImplicitAny": false,
Expand Down
100 changes: 100 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
[build-system]
requires = [
"hatch-jupyter-builder >=0.5",
"hatch-nodejs-version",
"hatchling >=1.4.0",
"jupyterlab >=3.4.7,<4.0.0",
]
build-backend = "hatchling.build"

[project]
name = "jupyterlmod"
dynamic = [
"authors",
"description",
"keywords",
"urls",
"version",
]
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.6"
classifiers = [
"Framework :: Jupyter",
"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",
"Programming Language :: Python :: 3.10",
]
dependencies = [
"jupyter-core",
"jupyter-server",
]

[tool.hatch.metadata.hooks.nodejs]
path = "labextension/package.json"
fields = ["description", "authors", "urls"]

[tool.hatch.build]
artifacts = [
"jupyterlmod.egg-info/",
"jupyterlmod/labextension",
]

[tool.hatch.build.targets.wheel]
packages = ["jupyterlmod", "lmod"]

[tool.hatch.build.targets.wheel.shared-data]
"jupyterlmod/static" = "share/jupyter/nbextensions/jupyterlmod"
"jupyterlmod/etc/jupyterlmod_serverextension.json" = "etc/jupyter/jupyter_notebook_config.d/jupyterlmod_serverextension.json"
"jupyterlmod/etc/jupyterlmod_jupyterserverextension.json" = "etc/jupyter/jupyter_server_config.d/jupyterlmod_jupyterserverextension.json"
"jupyterlmod/etc/jupyterlmod_nbextension.json" = "etc/jupyter/nbconfig/tree.d/jupyterlmod_nbextension.json"
"jupyterlmod/labextension" = "share/jupyter/labextensions/@cmd-ntrf/jupyterlab-lmod"
"./install.json" = "share/jupyter/labextensions/@cmd-ntrf/jupyterlab-lmod/install.json"

[tool.hatch.version]
source = "nodejs"
path = "labextension/package.json"

[tool.hatch.build.targets.sdist]
exclude = [
".github",
]

[tool.hatch.build.hooks.jupyter-builder]
ensured-targets = [
"jupyterlmod/labextension/package.json",
]
dependencies = [
"hatch-jupyter-builder>=0.8.2",
]
build-function = "hatch_jupyter_builder.npm_builder"

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
path = "labextension"
build_cmd = "build:prod"
npm = [
"jlpm",
]

[tool.tbump]
field = [
{ name = "channel", default = "" },
{ name = "release", default = "" },
]

[tool.tbump.version]
current = "4.0.0"
regex = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)((?P<channel>a|b|rc|.dev)(?P<release>\\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}\""
44 changes: 1 addition & 43 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,43 +1 @@
#!/usr/bin/env python
# coding: utf-8
from glob import glob
from setuptools import setup

setup_args = dict(
name = 'jupyterlmod',
packages = ['jupyterlmod', 'lmod'],
version = "3.1.0",
description = "jupyterlmod: notebook server extension to interact with Lmod system",
long_description = "Jupyter interactive notebook server extension that allows user to select software modules to load with Lmod before launching kernels.",
author = "Félix-Antoine Fortin",
author_email = "[email protected]",
url = "http://www.calculquebec.ca",
license = "MIT",
platforms = "Linux, Mac OS X",
keywords = ['Interactive', 'Interpreter', 'Shell', 'Web', 'Lmod'],
classifiers = [
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
],
install_requires = [
'jupyter-core',
'jupyter-server'
],
data_files=[
('share/jupyter/nbextensions/jupyterlmod', glob('jupyterlmod/static/*')),
('etc/jupyter/jupyter_notebook_config.d', ['jupyterlmod/etc/jupyterlmod_serverextension.json']),
("etc/jupyter/jupyter_server_config.d", ['jupyterlmod/etc/jupyterlmod_jupyterserverextension.json']),
('etc/jupyter/nbconfig/tree.d', ['jupyterlmod/etc/jupyterlmod_nbextension.json'])
],
zip_safe=False
)

def main():
setup(**setup_args)

if __name__ == '__main__':
main()
# this file intentionally left blank for legacy tools to find

0 comments on commit 2664e67

Please sign in to comment.