Skip to content

Commit 3c9b7cc

Browse files
authored
Enhance setup (#6)
* Enhance setup * Fix pyproject * Fix build workflow * Fix manifest * Bump to 3.1.0
1 parent 26a75b9 commit 3c9b7cc

File tree

5 files changed

+110
-47
lines changed

5 files changed

+110
-47
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
yarn-
4646
4747
- name: Install dependencies
48-
run: python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9
48+
run: python -m pip install -U jupyterlab~=3.0 check-manifest
4949
- name: Build the extension
5050
run: |
5151
jlpm
@@ -54,3 +54,45 @@ jobs:
5454
5555
jupyter labextension list 2>&1 | grep -ie "@jlab-enhanced/favorites.*OK"
5656
python -m jupyterlab.browser_check
57+
58+
- name: Build package
59+
run: |
60+
set -eux
61+
check-manifest -v
62+
63+
pip install build
64+
python -m build --sdist
65+
cp dist/*.tar.gz myextension.tar.gz
66+
pip uninstall -y myextension jupyterlab
67+
rm -rf myextension
68+
69+
- uses: actions/upload-artifact@v2
70+
with:
71+
name: myextension-sdist
72+
path: myextension.tar.gz
73+
74+
test_isolated:
75+
needs: build
76+
runs-on: ubuntu-latest
77+
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v2
81+
- name: Install Python
82+
uses: actions/setup-python@v2
83+
with:
84+
python-version: '3.8'
85+
architecture: 'x64'
86+
- uses: actions/download-artifact@v2
87+
with:
88+
name: myextension-sdist
89+
- name: Install and Test
90+
run: |
91+
set -eux
92+
# Remove NodeJS, twice to take care of system and locally installed node versions.
93+
sudo rm -rf $(which node)
94+
sudo rm -rf $(which node)
95+
pip install myextension.tar.gz
96+
pip install jupyterlab
97+
jupyter labextension list 2>&1 | grep -ie "@jlab-enhanced/favorites.*OK"
98+
python -m jupyterlab.browser_check --no-chrome-test

MANIFEST.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include LICENSE
22
include README.md
33
include pyproject.toml
4+
include requirements.txt
45
include jupyter-config/jupyterlab-favorites.json
56

67
include package.json
@@ -13,8 +14,14 @@ graft jupyterlab_favorites/labextension
1314
# Javascript files
1415
graft src
1516
graft style
17+
graft schema
18+
graft tests
1619
prune **/node_modules
1720
prune lib
21+
prune binder
22+
23+
exclude jupyterlab-favorites.gif
24+
exclude *.sh
1825

1926
# Patterns to exclude from any directory
2027
global-exclude *~

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jlab-enhanced/favorites",
3-
"version": "3.0.1",
3+
"version": "3.1.0",
44
"description": "Add the ability to save favorite folders to JupyterLab for quicker browsing",
55
"keywords": [
66
"jupyter",

pyproject.toml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
[build-system]
2-
requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1"]
3+
build-backend = "jupyter_packaging.build_api"
4+
5+
[tool.jupyter-packaging.options]
6+
skip-if-exists = ["jupyterlab_favorites/labextension/static/style.js"]
7+
ensured-targets = ["jupyterlab_favorites/labextension/static/style.js", "jupyterlab_favorites/labextension/package.json"]
8+
9+
[tool.jupyter-packaging.builder]
10+
factory = "jupyter_packaging.npm_builder"
11+
12+
[tool.jupyter-packaging.build-args]
13+
build_cmd = "build:prod"
14+
npm = ["jlpm"]
15+
16+
[tool.check-manifest]
17+
ignore = ["jupyterlab_favorites/labextension/**", "yarn.lock", ".*", "package-lock.json"]

setup.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,94 @@
11
"""
2-
jupyterlab-favorites setup
2+
jupyterlab_search_replace setup
33
"""
44
import json
5+
import sys
56
from pathlib import Path
67

7-
from jupyter_packaging import (
8-
create_cmdclass,
9-
install_npm,
10-
ensure_targets,
11-
combine_commands,
12-
skip_if_exists
13-
)
148
import setuptools
159

1610
HERE = Path(__file__).parent.resolve()
1711

1812
# The name of the project
1913
name = "jupyterlab-favorites"
20-
python_name = name.replace("-", "_")
2114

22-
lab_path = (HERE / python_name / "labextension")
15+
lab_path = HERE / name.replace("-", "_") / "labextension"
2316

2417
# Representative files that should exist after a successful build
25-
jstargets = [
26-
str(lab_path / "package.json"),
27-
]
28-
29-
package_data_spec = {
30-
name: ["*"],
31-
}
18+
ensured_targets = [str(lab_path / "package.json"), str(lab_path / "static/style.js")]
3219

3320
labext_name = "@jlab-enhanced/favorites"
3421

3522
data_files_spec = [
36-
("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"),
37-
("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"),
23+
(
24+
"share/jupyter/labextensions/%s" % labext_name,
25+
str(lab_path.relative_to(HERE)),
26+
"**",
27+
),
28+
("share/jupyter/labextensions/%s" % labext_name, str("."), "install.json"),
3829
]
3930

40-
cmdclass = create_cmdclass("jsdeps",
41-
package_data_spec=package_data_spec,
42-
data_files_spec=data_files_spec
43-
)
44-
45-
js_command = combine_commands(
46-
install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]),
47-
ensure_targets(jstargets),
48-
)
49-
50-
is_repo = (HERE / ".git").exists()
51-
if is_repo:
52-
cmdclass["jsdeps"] = js_command
53-
else:
54-
cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command)
55-
5631
long_description = (HERE / "README.md").read_text()
5732

5833
# Get the package info from package.json
5934
pkg_json = json.loads((HERE / "package.json").read_bytes())
35+
version = (
36+
pkg_json["version"]
37+
.replace("-alpha.", "a")
38+
.replace("-beta.", "b")
39+
.replace("-rc.", "rc")
40+
)
6041

6142
setup_args = dict(
62-
name=python_name,
63-
version=pkg_json["version"],
43+
name=name,
44+
version=version,
6445
url=pkg_json["homepage"],
6546
author=pkg_json["author"],
6647
description=pkg_json["description"],
6748
license=pkg_json["license"],
6849
long_description=long_description,
6950
long_description_content_type="text/markdown",
70-
cmdclass=cmdclass,
7151
packages=setuptools.find_packages(),
72-
install_requires=[
73-
"jupyterlab~=3.0",
74-
],
7552
zip_safe=False,
7653
include_package_data=True,
77-
python_requires=">=3.6",
54+
python_requires=">=3.7",
7855
platforms="Linux, Mac OS X, Windows",
7956
keywords=pkg_json["keywords"],
8057
classifiers=[
8158
"License :: OSI Approved :: BSD License",
8259
"Programming Language :: Python",
8360
"Programming Language :: Python :: 3",
84-
"Programming Language :: Python :: 3.6",
8561
"Programming Language :: Python :: 3.7",
8662
"Programming Language :: Python :: 3.8",
8763
"Programming Language :: Python :: 3.9",
64+
"Programming Language :: Python :: 3.10",
8865
"Framework :: Jupyter",
66+
"Framework :: Jupyter :: JupyterLab",
67+
"Framework :: Jupyter :: JupyterLab :: 3",
68+
"Framework :: Jupyter :: JupyterLab :: Extensions",
69+
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
8970
],
9071
)
9172

73+
try:
74+
from jupyter_packaging import wrap_installers, npm_builder, get_data_files
75+
76+
post_develop = npm_builder(
77+
build_cmd="install:extension", source_dir="src", build_dir=lab_path
78+
)
79+
setup_args["cmdclass"] = wrap_installers(
80+
post_develop=post_develop, ensured_targets=ensured_targets
81+
)
82+
setup_args["data_files"] = get_data_files(data_files_spec)
83+
except ImportError as e:
84+
import logging
85+
86+
logging.basicConfig(format="%(levelname)s: %(message)s")
87+
logging.warning(
88+
"Build tool `jupyter-packaging` is missing. Install it with pip or conda."
89+
)
90+
if not ("--name" in sys.argv or "--version" in sys.argv):
91+
raise e
9292

9393
if __name__ == "__main__":
9494
setuptools.setup(**setup_args)

0 commit comments

Comments
 (0)