From 96671df35822f09721fd2e5df7118ce4fa2225ea Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Wed, 14 Jul 2021 15:11:46 +0200 Subject: [PATCH] Update to jupyter-packaging 0.10 (#179) * Update to jupyter-packaging 0.10 * Update to jupyter-packaging 0.10 on CI * Update pyproject metadata * Update target * Update targets * Update build command * Update MANIFEST.in * Fix build backend * Add build:prod command to packages * Update RELEASE.md * Enable server extension in dev mode * Enable for the notebook server * Fix typo * Add jupyter labextension develop . to the Binder * Update dev instructions --- .github/workflows/build.yml | 6 +- .github/workflows/buildutils.yml | 4 +- .github/workflows/release.yml | 8 +- CONTRIBUTING.md | 6 ++ MANIFEST.in | 2 +- RELEASE.md | 2 +- binder/postBuild | 3 + packages/application-extension/package.json | 1 + packages/application/package.json | 1 + packages/docmanager-extension/package.json | 1 + packages/help-extension/package.json | 1 + packages/lab-extension/tsconfig.json | 7 +- packages/notebook-extension/package.json | 1 + packages/terminal-extension/package.json | 1 + packages/tree-extension/package.json | 1 + packages/ui-components/package.json | 1 + pyproject.toml | 18 +++- setup.cfg | 39 +++++++ setup.py | 106 +++++--------------- 19 files changed, 112 insertions(+), 97 deletions(-) create mode 100644 setup.cfg diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3ef5d237a..4ae65a018f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,7 +47,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip wheel - python -m pip install jupyter_packaging + python -m pip install jupyter_packaging~=0.10 - name: Install the package run: | python -m pip install . @@ -82,10 +82,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip wheel - python -m pip install setuptools jupyter_packaging "jupyterlab>=3,<4" + python -m pip install setuptools jupyter_packaging~=0.10 "jupyterlab>=3,<4" build - name: Build pypi distributions run: | - python setup.py sdist bdist_wheel + python -m build - name: Build npm distributions run: | mkdir pkgs diff --git a/.github/workflows/buildutils.yml b/.github/workflows/buildutils.yml index 0ca3a7687f..0492ed3fdc 100644 --- a/.github/workflows/buildutils.yml +++ b/.github/workflows/buildutils.yml @@ -27,7 +27,7 @@ jobs: architecture: 'x64' - name: Install dependencies run: | - python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9 pip + python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.10 pip jlpm jlpm run build - name: Configure git identity to commit @@ -72,7 +72,7 @@ jobs: architecture: 'x64' - name: Install dependencies run: | - python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9 pip + python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.10 pip jlpm jlpm run build - name: Publish to npm in dry-run mode diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a66cc55a0..c846e7a567 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,7 +47,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip wheel - python -m pip install jupyter_packaging + python -m pip install jupyter_packaging~=0.10 - name: Install the package run: | python -m pip install . @@ -82,10 +82,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip wheel - python -m pip install setuptools jupyter_packaging "jupyterlab>=3,<4" + python -m pip install setuptools jupyter_packaging~=0.10 "jupyterlab>=3,<4" build - name: Build pypi distributions run: | - python setup.py sdist bdist_wheel + python -m build - name: Build npm distributions run: | mkdir pkgs @@ -184,7 +184,7 @@ jobs: architecture: 'x64' - name: Install dependencies run: | - python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9 pip + python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.10 pip jlpm jlpm run build - uses: actions/download-artifact@v2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b7a3522540..1680989a0d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,6 +23,12 @@ conda activate retrolab # Install package in development mode pip install -e . + +# Link the RetroLab JupyterLab extension +jupyter labextension develop . --overwrite + +# Enable the server extension +jupyter server extension enable retrolab ``` `retrolab` follows a monorepo structure. To build all the packages at once: diff --git a/MANIFEST.in b/MANIFEST.in index b8c017305e..29d4182f09 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include LICENSE -include README.md +include *.md include pyproject.toml include jupyter-config/retrolab.json diff --git a/RELEASE.md b/RELEASE.md index cfc3d2d220..b3ed146ee5 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -63,7 +63,7 @@ Make sure the `dist/` folder is empty. - `jlpm` - `jlpm run lerna version x.y.z --no-push --amend --force-publish` -4. Run: `python setup.py sdist bdist_wheel` +4. Run: `python -m pip install build && python -m build` 5. Double check the size of the bundles in the `dist/` folder 6. Test the release by installing the wheel or sdist: `python -m pip install ./dist/retrolab-x.y.z-py3-none-any.whl 7. `export TWINE_USERNAME=mypypi_username` diff --git a/binder/postBuild b/binder/postBuild index 5928c080e6..3413ce500e 100644 --- a/binder/postBuild +++ b/binder/postBuild @@ -3,3 +3,6 @@ set -euo pipefail jlpm && jlpm run build python -m pip install -e . +jupyter labextension develop . --overwrite +jupyter server extension enable retrolab +jupyter serverextension enable retrolab diff --git a/packages/application-extension/package.json b/packages/application-extension/package.json index 7f52ffa0f6..4300b3d121 100644 --- a/packages/application-extension/package.json +++ b/packages/application-extension/package.json @@ -32,6 +32,7 @@ ], "scripts": { "build": "tsc -b", + "build:prod": "tsc -b", "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", "docs": "typedoc src", "prepublishOnly": "npm run build", diff --git a/packages/application/package.json b/packages/application/package.json index 0c68ea35f7..8f37ef1d97 100644 --- a/packages/application/package.json +++ b/packages/application/package.json @@ -31,6 +31,7 @@ ], "scripts": { "build": "tsc -b", + "build:prod": "tsc -b", "build:test": "tsc --build tsconfig.test.json", "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", "docs": "typedoc src", diff --git a/packages/docmanager-extension/package.json b/packages/docmanager-extension/package.json index 437dcbdaf8..cd58be73d2 100644 --- a/packages/docmanager-extension/package.json +++ b/packages/docmanager-extension/package.json @@ -32,6 +32,7 @@ ], "scripts": { "build": "tsc -b", + "build:prod": "tsc -b", "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", "docs": "typedoc src", "prepublishOnly": "npm run build", diff --git a/packages/help-extension/package.json b/packages/help-extension/package.json index e00ae3bdd7..255f148a29 100644 --- a/packages/help-extension/package.json +++ b/packages/help-extension/package.json @@ -32,6 +32,7 @@ ], "scripts": { "build": "tsc -b", + "build:prod": "tsc -b", "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", "docs": "typedoc src", "prepublishOnly": "npm run build", diff --git a/packages/lab-extension/tsconfig.json b/packages/lab-extension/tsconfig.json index 399b75b7ac..1b9e4bfd7f 100644 --- a/packages/lab-extension/tsconfig.json +++ b/packages/lab-extension/tsconfig.json @@ -4,5 +4,10 @@ "outDir": "lib", "rootDir": "src" }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "references": [ + { + "path": "../ui-components" + } + ] } diff --git a/packages/notebook-extension/package.json b/packages/notebook-extension/package.json index 7b4dcaf1c5..18eba99c2f 100644 --- a/packages/notebook-extension/package.json +++ b/packages/notebook-extension/package.json @@ -32,6 +32,7 @@ ], "scripts": { "build": "tsc -b", + "build:prod": "tsc -b", "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", "docs": "typedoc src", "prepublishOnly": "npm run build", diff --git a/packages/terminal-extension/package.json b/packages/terminal-extension/package.json index 18ce492c1e..323d51fbd2 100644 --- a/packages/terminal-extension/package.json +++ b/packages/terminal-extension/package.json @@ -32,6 +32,7 @@ ], "scripts": { "build": "tsc -b", + "build:prod": "tsc -b", "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", "docs": "typedoc src", "prepublishOnly": "npm run build", diff --git a/packages/tree-extension/package.json b/packages/tree-extension/package.json index 548cd9a364..bccc1f98cf 100644 --- a/packages/tree-extension/package.json +++ b/packages/tree-extension/package.json @@ -32,6 +32,7 @@ ], "scripts": { "build": "tsc -b", + "build:prod": "tsc -b", "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", "docs": "typedoc src", "prepublishOnly": "npm run build", diff --git a/packages/ui-components/package.json b/packages/ui-components/package.json index 3af1e33ec5..bf9140ec58 100644 --- a/packages/ui-components/package.json +++ b/packages/ui-components/package.json @@ -29,6 +29,7 @@ ], "scripts": { "build": "tsc -b", + "build:prod": "tsc -b", "build:test": "tsc --build tsconfig.test.json", "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo", "cleansvg": "svgo --config svgo.yaml", diff --git a/pyproject.toml b/pyproject.toml index 619cd4e56f..39c3f7564e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.1.0rc1,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10", "jupyterlab>=3.1.0rc1,==3.1.*"] +build-backend = "jupyter_packaging.build_api" + +[license] +file="LICENSE" + +[tool.jupyter-packaging.options] +skip-if-exists = ["retrolab/labextension/static/style.js", "retrolab/static/bundle.js"] +ensured-targets = ["retrolab/labextension/static/style.js", "retrolab/static/bundle.js"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000..e7a0e13fd6 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,39 @@ +[metadata] +name = retrolab +version = attr: retrolab._version.__version__ +description = JupyterLab Distribution with a retro look and feel +long_description = file: README.md +long_description_content_type = text/markdown +license_file = LICENSE +author = Jupyter Development Team +author_email = jupyter@googlegroups.com +url = https://github.com/jupyterlab/retrolab +platforms = Linux, Mac OS X, Windows +keywords = Jupyter, JupyterLab, Notebook +classifiers = + Intended Audience :: Developers + Intended Audience :: System Administrators + Intended Audience :: Science/Research + License :: OSI Approved :: BSD License + Programming Language :: Python + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Framework :: Jupyter + +[options] +zip_safe = False +include_package_data = True +packages = find: +python_requires = >=3.6 +install_requires = + jupyterlab>=3.1.0rc1,<4 + jupyterlab_server~=2.3 + jupyter_server~=1.4 + nbclassic~=0.2 + tornado>=6.1.0 + +[options.entry_points] +console_scripts = + jupyter-retro = retrolab.app:main diff --git a/setup.py b/setup.py index 3789bddd8a..1a2458e685 100644 --- a/setup.py +++ b/setup.py @@ -1,45 +1,28 @@ -""" -retrolab setup -""" -import os +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. + +from pathlib import Path -from jupyter_packaging import ( - get_version, - create_cmdclass, - combine_commands, - install_npm, - ensure_targets, - skip_if_exists, -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project NAME = "retrolab" -PACKAGE_NAME = NAME.replace("-", "_") - -# Get our version -version = get_version(os.path.join(PACKAGE_NAME, "_version.py")) - -main_bundle_dest = os.path.join(HERE, PACKAGE_NAME, "static") -main_bundle_source = os.path.join(HERE, "app") labext_name = "@retrolab/lab-extension" -lab_extension_dest = os.path.join(HERE, PACKAGE_NAME, "labextension") -lab_extension_source = os.path.join(HERE, "packages", "lab-extension") +lab_extension_dest = HERE / NAME / "labextension" +main_bundle_dest = HERE / NAME / "static" # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_extension_dest, "package.json"), - os.path.join(main_bundle_dest, "bundle.js"), +ensured_targets = [ + str(lab_extension_dest / "static" / "style.js"), + str(main_bundle_dest / "bundle.js"), ] -package_data_spec = {PACKAGE_NAME: ["*", "templates/*", "static/**"]} - data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_extension_dest, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_extension_dest), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ( "etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", @@ -52,62 +35,19 @@ ), ] -cmdclass = create_cmdclass( - "jsdeps", package_data_spec=package_data_spec, data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="install", npm=["jlpm"]), - install_npm(HERE, build_cmd="build", npm=["jlpm"]), - install_npm(main_bundle_source, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) - +try: + from jupyter_packaging import wrap_installers, npm_builder, get_data_files -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() + # In develop mode, just run yarn + builder = npm_builder(build_cmd='build', npm='jlpm', force=True) + cmdclass = wrap_installers(post_develop=builder, ensured_targets=ensured_targets) -setup_args = dict( - name=NAME, - version=version, - url="https://github.com/jupyterlab/retrolab", - author="Project Jupyter", - description="JupyterLab Distribution with a retro look and feel", - long_description=long_description, - long_description_content_type="text/markdown", - cmdclass=cmdclass, - packages=setuptools.find_packages(), - install_requires=[ - "jupyterlab>=3.1.0rc1,<4", - "jupyterlab_server~=2.3", - "jupyter_server~=1.4", - "nbclassic~=0.2", - "tornado>=6.1.0", - ], - zip_safe=False, - include_package_data=True, - python_requires=">=3.6", - license="BSD-3-Clause", - platforms="Linux, Mac OS X, Windows", - keywords=["Jupyter", "JupyterLab", "Notebook"], - classifiers=[ - "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", - "Framework :: Jupyter", - ], - entry_points={"console_scripts": ["jupyter-retro = retrolab.app:main"]}, -) + setup_args = dict( + cmdclass=cmdclass, + data_files=get_data_files(data_files_spec) + ) +except ImportError: + setup_args = dict() if __name__ == "__main__":