diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a4ac396..5442864 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,17 +12,18 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Install node uses: actions/setup-node@v1 with: - node-version: '12.x' + node-version: '14.x' + - name: Install Python uses: actions/setup-python@v2 with: - python-version: '3.7' + python-version: '3.9' architecture: 'x64' - - name: Setup pip cache uses: actions/cache@v2 with: @@ -35,6 +36,7 @@ jobs: - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Setup yarn cache uses: actions/cache@v2 id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) @@ -45,7 +47,8 @@ jobs: yarn- - name: Install dependencies - run: python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9 + run: python -m pip install -U jupyterlab~=3.0 jupyter-packaging~=0.10 + - name: Build the extension run: | jlpm diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml new file mode 100644 index 0000000..6b37c41 --- /dev/null +++ b/.github/workflows/check-release.yml @@ -0,0 +1,69 @@ +name: Check Release +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: write + +jobs: + check_release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + architecture: 'x64' + + - name: Install node + uses: actions/setup-node@v2 + with: + node-version: '14.x' + + - name: Get pip cache dir + id: pip-cache + run: | + echo "::set-output name=dir::$(pip cache dir)" + + - name: Cache pip + uses: actions/cache@v1 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Cache checked links + uses: actions/cache@v2 + with: + path: ~/.cache/pytest-link-check + key: ${{ runner.os }}-linkcheck-${{ hashFiles('**/.md') }}-md-links + restore-keys: | + ${{ runner.os }}-linkcheck- + + - name: Upgrade packaging dependencies + run: | + pip install --upgrade pip setuptools wheel jupyter-packaging~=0.10 --user + + - name: Install Dependencies + run: | + pip install . + + - name: Check Release + uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Distributions + uses: actions/upload-artifact@v2 + with: + name: jupyterlab-snippets-releaser-dist-${{ github.run_number }} + path: .jupyter_releaser_checkout/dist \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a5a1a1a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog + + + +## 0.4.0 + +### Changes + +- Don't list hidden folder #25 +- Correct hidden folder removal #26 +- Port to JupyterLab 3 #33 + +Many thanks @fcollonval for the contributions! + + \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index cfcc808..5cccd75 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include LICENSE -include README.md +include *.md include pyproject.toml include jupyter-config/jupyterlab-snippets.json diff --git a/README.md b/README.md index b1913bf..c7ac472 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![Github Actions Status](https://github.com/QuantStack/jupyterlab-snippets/workflows/Build/badge.svg) [![Version](https://img.shields.io/pypi/v/jupyterlab-snippets.svg)](https://pypi.python.org/project/jupyterlab-snippets) [![Conda Version](https://img.shields.io/conda/vn/conda-forge/jupyterlab-snippets.svg)](https://anaconda.org/conda-forge/jupyterlab-snippets) -[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/QuantStack/jupyterlab-snippets/stable?urlpath=lab/tree/binder/notebook.ipynb) +[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/QuantStack/jupyterlab-snippets/stable?urlpath=lab/tree/binder/example.ipynb) Snippets Extension for JupyterLab. diff --git a/binder/environment.yml b/binder/environment.yml index 407a028..6f5b37f 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -16,4 +16,4 @@ dependencies: # labextension build dependencies - nodejs >=14,<15 - pip - - wheel + - wheel \ No newline at end of file diff --git a/binder/notebook.ipynb b/binder/example.ipynb similarity index 100% rename from binder/notebook.ipynb rename to binder/example.ipynb diff --git a/binder/postBuild b/binder/postBuild old mode 100755 new mode 100644 index 6dae9bb..2a15e72 --- a/binder/postBuild +++ b/binder/postBuild @@ -1,6 +1,5 @@ #!/usr/bin/env sh """ perform a development install of jupyterlab-snippets - On Binder, this will run _after_ the environment has been fully created from the environment.yml in this directory. """ @@ -32,7 +31,7 @@ cd .. python -m pip check # install the labextension -python -m pip install -e . +python -m pip install . # verify the environment the extension didn't break anything python -m pip check @@ -45,4 +44,4 @@ jupyter labextension list echo "JupyterLab with jupyterlab-snippets is ready to run with:" -echo " jupyter lab" +echo " jupyter lab" \ No newline at end of file diff --git a/package.json b/package.json index 36b027f..71131a0 100644 --- a/package.json +++ b/package.json @@ -88,5 +88,14 @@ "extension": true, "outputDir": "jupyterlab_snippets/labextension" }, + "jupyter-releaser": { + "skip": ["check-links"], + "hooks": { + "before-build-npm": [ + "python -m pip install jupyterlab~=3.1", + "jlpm" + ] + } + }, "styleModule": "style/index.js" } \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index ba04c53..0e8c9fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,21 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10", "jupyterlab~=3.0", "tornado~=6.1"] +build-backend = "jupyter_packaging.build_api" + +[license] +file="LICENSE" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_snippets/labextension/static/style.js"] +ensured-targets = ["jupyterlab_snippets/labextension/static/style.js", "jupyterlab_snippets/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["binder/**", "*.json", "*.ipynb", "*.gif", "yarn.lock", ".*", "jupyterlab_snippets/labextension/**", "jupyter-boilerplate-converter/**"] + diff --git a/setup.py b/setup.py index 7923702..16ffdbf 100644 --- a/setup.py +++ b/setup.py @@ -4,64 +4,36 @@ import json from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, - install_npm, - ensure_targets, - combine_commands, - skip_if_exists -) import setuptools HERE = Path(__file__).parent.resolve() # The name of the project -name = "jupyterlab-snippets" -package = name.replace("-", "_") +NAME = "jupyterlab-snippets" +PY_NAME = NAME.replace('-', '_') -lab_path = (HERE / package / "labextension") +lab_path = (HERE / PY_NAME / "labextension") # Representative files that should exist after a successful build -jstargets = [ +ensured_targets = [ str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - package: ["*"], -} - -labext_name = "jupyterlab-snippets" - data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % NAME, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % NAME, str(HERE), "install.json"), ("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jupyterlab_snippets.json"), ("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jupyterlab_snippets.json"), ] -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="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = (HERE / ".git").exists() -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) - long_description = (HERE / "README.md").read_text() # Get the package info from package.json pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( - name=name, + name=NAME, version=pkg_json["version"], url=pkg_json["homepage"], author=pkg_json["author"]["name"], @@ -70,7 +42,6 @@ license=pkg_json["license"], long_description=long_description, long_description_content_type="text/markdown", - cmdclass=cmdclass, packages=setuptools.find_packages(), install_requires=[ "jupyterlab~=3.0", @@ -89,9 +60,26 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Framework :: Jupyter", + "Framework :: Jupyter :: JupyterLab", + "Framework :: Jupyter :: JupyterLab :: 3", + "Framework :: Jupyter :: JupyterLab :: Extensions", + "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="build:prod", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args)