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

Update for JupyterLab 3 #83

Closed
wants to merge 5 commits into from
Closed
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
20 changes: 14 additions & 6 deletions {{cookiecutter.github_project_name}}/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
"url": "https://github.com/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.github_project_name }}"
},
"scripts": {
"build": "npm run build:lib && npm run build:nbextension",
"build:labextension": "npm run clean:labextension && mkdirp {{ cookiecutter.python_package_name }}/labextension && cd {{ cookiecutter.python_package_name }}/labextension && npm pack ../..",
"build": "npm run build:lib && npm run build:nbextension && npm run build:labextension",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually a good idea to change this line? I personally develop mostly in Jupyter Notebook, and having npm run build trigger a jupyter labextension build . is not very friendly with this workflow, it will simply fail in envs where JupyterLab is not installed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is it actually supposed to work with JupyterLab 2? It seems to fail with Please supply at least one subcommand: check, disable, enable, install, link, list, uninstall, unlink, update

"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to make the build command default to --development, similar to jupyterlab/extension-cookiecutter-ts#98

"build:lib": "tsc",
"build:nbextension": "webpack -p",
"build:all": "npm run build:labextension && npm run build:nbextension",
"clean": "npm run clean:lib && npm run clean:nbextension",
"clean": "npm run clean:lib && npm run clean:nbextension && npm run clean:labextension",
"clean:lib": "rimraf lib",
"clean:labextension": "rimraf {{ cookiecutter.python_package_name }}/labextension",
"clean:nbextension": "rimraf {{ cookiecutter.python_package_name }}/nbextension/static/index.js",
Expand All @@ -51,9 +51,10 @@
"watch:nbextension": "webpack --watch"
},
"dependencies": {
"@jupyter-widgets/base": "^1.1.10 || ^2 || ^3"
"@jupyter-widgets/base": "^1.1.10 || ^2 || ^3 || ^4"
},
"devDependencies": {
"@jupyterlab/builder": "^3.0.0",
"@phosphor/application": "^1.6.0",
"@phosphor/widgets": "^1.6.0",
"@types/expect.js": "^0.3.29",
Expand Down Expand Up @@ -90,6 +91,13 @@
"webpack-cli": "^3.1.2"
},
"jupyterlab": {
"extension": "lib/plugin"
"extension": "lib/plugin",
"outputDir": "{{ cookiecutter.python_package_name }}/labextension/",
"sharedPackages": {
"@jupyter-widgets/base": {
"bundled": false,
vidartf marked this conversation as resolved.
Show resolved Hide resolved
"singleton": true
}
}
}
}
16 changes: 11 additions & 5 deletions {{cookiecutter.github_project_name}}/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
name = '{{ cookiecutter.python_package_name }}'

# Ensure a valid python version
ensure_python('>=3.4')
ensure_python('>=3.6')

# Get our version
version = get_version(pjoin(name, '_version.py'))

nb_path = pjoin(HERE, name, 'nbextension', 'static')
lab_path = pjoin(HERE, name, 'labextension')
# lab_path = pjoin(HERE, name, 'labextension')
lab3_path = pjoin(HERE, name, 'labextension')

# Representative files that should exist after a successful build
jstargets = [
Expand All @@ -39,22 +40,26 @@
package_data_spec = {
name: [
'nbextension/static/*.*js*',
'labextension/*.tgz'
# 'labextension/*.tgz',
'labextension/*'
]
}

labext_name = "{{ cookiecutter.npm_package_name }}"

data_files_spec = [
('share/jupyter/nbextensions/{{ cookiecutter.python_package_name}}',
nb_path, '*.js*'),
('share/jupyter/lab/extensions', lab_path, '*.tgz'),
("share/jupyter/labextensions/%s" % labext_name, lab3_path, "*.*"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the JupyterLab extension cookiecutter:

Suggested change
("share/jupyter/labextensions/%s" % labext_name, lab3_path, "*.*"),
("share/jupyter/labextensions/%s" % labext_name, lab3_path, "**"),

# ('share/jupyter/lab/extensions', lab_path, '*.tgz'),
vidartf marked this conversation as resolved.
Show resolved Hide resolved
('etc/jupyter/nbconfig/notebook.d' , HERE, '{{ cookiecutter.python_package_name}}.json')
]


cmdclass = create_cmdclass('jsdeps', package_data_spec=package_data_spec,
data_files_spec=data_files_spec)
cmdclass['jsdeps'] = combine_commands(
install_npm(HERE, build_cmd='build:all'),
install_npm(HERE, build_cmd='build'),
ensure_targets(jstargets),
)

Expand Down Expand Up @@ -85,6 +90,7 @@
'Framework :: Jupyter',
],
include_package_data = True,
python_requires=">=3.6",
install_requires = [
'ipywidgets>=7.0.0',
],
Expand Down