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

JupyterLab 3 update #683

Merged
merged 2 commits into from
Jan 5, 2021
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
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ jobs:
python-version: 3.7
- name: Build package
run: |
pip install wheel
pip install wheel jupyter-packaging jupyterlab=3
python setup.py sdist bdist_wheel
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.1.0
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ future
gits*
.ipynb_checkpoints
docs/_build
jupytext/labextension

# Will be created by postBuild
demo/get_started.ipynb
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include *.md
include *.txt
include *.rst

graft jupytext/labextension

graft tests
global-exclude *__pycache__
global-exclude *.pyc
Expand Down
5 changes: 5 additions & 0 deletions install.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "jupytext",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupytext"
}
4 changes: 4 additions & 0 deletions jupytext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
TextFileContentsManager = reraise(err)


def _jupyter_labextension_paths(): # pragma: no cover
return [{"src": "labextension", "dest": "jupyterlab-jupytext"}]


def load_jupyter_server_extension(app): # pragma: no cover
"""Use Jupytext's contents manager"""
if hasattr(app.contents_manager_class, "default_jupytext_formats"):
Expand Down
35 changes: 24 additions & 11 deletions packages/labextension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,20 @@
"url": "https://github.com/mwouts/jupytext.git"
},
"scripts": {
"build": "tsc",
"clean": "rimraf lib",
"prepare": "npm run clean && npm run build",
"watch": "tsc -w"
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"build:lib": "tsc",
"build:prod": "jlpm run build:lib && jlpm run build:labextension",
"clean": "jlpm run clean:lib",
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
"clean:labextension": "rimraf jupyterlab-jupytext/labextension",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"install:extension": "jupyter labextension develop --overwrite .",
"prepare": "jlpm run clean && jlpm run build:prod",
"watch": "run-p watch:src watch:labextension",
"watch:labextension": "jupyter labextension watch .",
"watch:src": "tsc -w"
},
"jupyterlab": {
"discovery": {
Expand All @@ -43,16 +53,19 @@
}
},
"extension": true,
"schemaDir": "schema"
"schemaDir": "schema",
"outputDir": "../../jupytext/labextension"
},
"dependencies": {
"@jupyterlab/application": "^2.0",
"@jupyterlab/apputils": "^2.0",
"@jupyterlab/notebook": "^2.0",
"@jupyterlab/nbformat": "^2.0"
"@jupyterlab/application": "^3.0.0",
"@jupyterlab/apputils": "^3.0.0",
"@jupyterlab/nbformat": "^3.0.0",
"@jupyterlab/notebook": "^3.0.0"
},
"devDependencies": {
"rimraf": "^3.0.0",
"typescript": "~3.7.3"
"@jupyterlab/builder": "^3.0.0",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"typescript": "~4.0.3"
}
}
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0,==3.*", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ipykernel
sphinx-gallery<=0.7.0
setuptools
toml
jupyterlab==3.0.0
jupyter-packaging

# Python 2
pathlib
Expand Down
81 changes: 53 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
import re
from setuptools import setup, find_packages

from jupyter_packaging import (
create_cmdclass,
install_npm,
ensure_targets,
combine_commands,
)

this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
# replace Markdown links (docs/[NAME].md with (https://jupytext.readthedocs.io/en/latest/[NAME].html
Expand All @@ -17,6 +24,51 @@
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
version = version_match.group(1)

lab_path = path.join(this_directory, "jupytext", "labextension")
nb_path = path.join(this_directory, "jupytext", "nbextension")

jupyter_config_path = path.join(this_directory, "jupyter-config")
notebook_config_path = path.join(jupyter_config_path, "jupyter_notebook_config.d")
jupyter_server_config_path = path.join(jupyter_config_path, "jupyter_server_config.d")
nbconfig_path = path.join(jupyter_config_path, "nbconfig", "notebook.d")

data_files_spec = [
# Install labextension
("share/jupyter/labextensions/jupyterlab-jupytext", lab_path, "**"),
("share/jupyter/labextensions/jupyterlab-jupytext", this_directory, "install.json"),
# Install nbextension
("share/jupyter/nbextensions/jupytext", nb_path, "**"),
("share/jupyter/nbextensions/jupytext", nbconfig_path, "jupytext.json"),
# Install config files
(
"etc/jupyter/jupyter_server_config.d",
jupyter_server_config_path,
"jupytext.json",
),
("etc/jupyter/jupyter_notebook_config.d", notebook_config_path, "jupytext.json"),
("etc/jupyter/nbconfig/notebook.d", nbconfig_path, "jupytext.json"),
]

# Representative files that should exist after a successful build
jstargets = [
path.join(lab_path, "package.json"),
]

cmdclass = create_cmdclass(
"jsdeps",
package_data_spec={"jupytext": ["nbextension/**"]},
data_files_spec=data_files_spec,
)

cmdclass["jsdeps"] = combine_commands(
install_npm(
path.join(this_directory, "packages", "labextension"),
build_cmd="build:prod",
npm=["jlpm"],
),
ensure_targets(jstargets),
)

setup(
name="jupytext",
version=version,
Expand All @@ -28,34 +80,7 @@
long_description_content_type="text/markdown",
url="https://github.com/mwouts/jupytext",
packages=find_packages(exclude=["tests"]),
package_data={"jupytext": ["nbextension/*.*"]},
data_files=[
(
"etc/jupyter/nbconfig/notebook.d",
["jupyter-config/nbconfig/notebook.d/jupytext.json"],
),
(
"etc/jupyter/jupyter_notebook_config.d",
["jupyter-config/jupyter_notebook_config.d/jupytext.json"],
),
(
"etc/jupyter/jupyter_server_config.d",
["jupyter-config/jupyter_server_config.d/jupytext.json"],
),
(
"share/jupyter/nbextensions/jupytext",
[
"jupytext/nbextension/index.js",
"jupytext/nbextension/README.md",
"jupytext/nbextension/jupytext_menu.png",
"jupytext/nbextension/jupytext.yml",
],
),
(
"share/jupyter/lab/extensions",
["packages/labextension/jupyterlab-jupytext-1.2.3.tgz"],
),
],
cmdclass=cmdclass,
entry_points={"console_scripts": ["jupytext = jupytext.cli:jupytext"]},
tests_require=["pytest"],
install_requires=["nbformat>=4.0.0", "pyyaml", "toml", "markdown-it-py~=0.6.0"],
Expand Down