Skip to content

Update to Jupyter Packaging 10, adopt the releaser #38

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

Merged
merged 12 commits into from
Sep 30, 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
11 changes: 7 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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'`)
Expand All @@ -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
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

<!-- <START NEW CHANGELOG ENTRY> -->

## 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!

<!-- <END NEW CHANGELOG ENTRY> -->
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include LICENSE
include README.md
include *.md
include pyproject.toml
include jupyter-config/jupyterlab-snippets.json

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dependencies:
# labextension build dependencies
- nodejs >=14,<15
- pip
- wheel
- wheel
File renamed without changes.
5 changes: 2 additions & 3 deletions binder/postBuild
100755 → 100644
Original file line number Diff line number Diff line change
@@ -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.
"""
Expand Down Expand Up @@ -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
Expand All @@ -45,4 +44,4 @@ jupyter labextension list


echo "JupyterLab with jupyterlab-snippets is ready to run with:"
echo " jupyter lab"
echo " jupyter lab"
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
22 changes: 20 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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/**"]

62 changes: 25 additions & 37 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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",
Expand All @@ -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)