Skip to content

Commit af675eb

Browse files
authored
Merge pull request #117 from blink1073/switch-to-hatch
2 parents 1d2eb69 + 3f63269 commit af675eb

File tree

9 files changed

+186
-228
lines changed

9 files changed

+186
-228
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,86 +4,67 @@ on:
44
push:
55
branches: master
66
pull_request:
7-
branches: "*"
7+
8+
concurrency:
9+
group: ci-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
defaults:
13+
run:
14+
shell: bash -eux {0}
815

916
jobs:
1017
build:
11-
runs-on: ubuntu-latest
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-latest, windows-latest, macos-latest]
23+
python-version: ["3.7", "3.10"]
1224
steps:
1325
- name: Checkout
1426
uses: actions/checkout@v2
1527

16-
- name: Install node
17-
uses: actions/setup-node@v2
18-
with:
19-
node-version: "12.x"
20-
21-
- name: Install Python
22-
uses: actions/setup-python@v2
23-
with:
24-
python-version: "3.7"
25-
architecture: "x64"
26-
27-
- name: Setup pip cache
28-
uses: actions/cache@v2
29-
with:
30-
path: ~/.cache/pip
31-
key: pip-3.7-${{ hashFiles('package.json') }}
32-
restore-keys: |
33-
pip-3.7-
34-
pip-
35-
36-
- name: Get npm cache directory
37-
id: npm-cache
38-
run: |
39-
echo "::set-output name=dir::$(npm config get cache)"
40-
41-
- uses: actions/cache@v2
42-
with:
43-
path: ${{ steps.npm-cache.outputs.dir }}
44-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
45-
restore-keys: |
46-
${{ runner.os }}-node-
28+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
4729

4830
- name: Install dependencies
4931
run: |
50-
python -m pip install -U pip setuptools cookiecutter
32+
python -m pip install -U cookiecutter jupyterlab~=3.0
5133
52-
- name: Test the extension
34+
- name: Install the extension
5335
run: |
5436
cookiecutter . --config-file tests/testconfig.yaml --no-input
55-
pushd jupyter-widget-testwidgets
37+
cd jupyter-widget-testwidgets
5638
python -m pip install --upgrade -v -e ".[test, examples, docs]"
57-
yarn run lint:check
5839
59-
pytest
40+
- name: Test the extension
41+
working-directory: jupyter-widget-testwidgets
42+
run: |
43+
python -m pytest
6044
yarn run test
61-
popd
6245
63-
- name: Check docs can be build + links
46+
- name: Linting
47+
if: ${{ matrix.os == 'ubuntu-latest' }}
48+
working-directory: jupyter-widget-testwidgets
6449
run: |
65-
sudo apt install -y pandoc
66-
pushd jupyter-widget-testwidgets/docs
67-
make html
68-
python -m pytest --check-links
69-
popd
50+
yarn run lint:check
7051
71-
- name: Make a non-local install so the data_files get populated
52+
- name: Validate extension usage
53+
working-directory: jupyter-widget-testwidgets
7254
run: |
73-
pip uninstall -y jupyter_widget_testwidgets
74-
pushd jupyter-widget-testwidgets
75-
76-
pip install .
77-
78-
# Validate nbextension (enable does not use exit code):
79-
jupyter nbextension enable --py --sys-prefix jupyter_widget_testwidgets
80-
python -c "from notebook.nbextensions import validate_nbextension; import sys; sys.exit(validate_nbextension('jupyter_widget_testwidgets/extension') or 0)"
55+
# Validate nbextension
56+
jupyter nbextension list 2>&1 | grep -ie "jupyter-js-widgets/extension.*enabled"
8157
8258
# Validate labextension
83-
pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7
84-
# Make sure our lab extension was installed.
59+
jupyter labextension list
8560
jupyter labextension list 2>&1 | grep -ie "jupyter-widget-testwidgets.*OK"
8661
# Make sure our lab extension can be develop installed.
8762
jupyter labextension develop . --overwrite
8863
89-
popd
64+
- name: Check docs can be build + links
65+
if: ${{ matrix.os == 'ubuntu-latest' }}
66+
working-directory: jupyter-widget-testwidgets/docs
67+
run: |
68+
sudo apt install -y pandoc
69+
make html SPHINXOPTS="-W"
70+
python -m pytest --check-links

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
*.pyc
44
.cache
55
.vscode
6+
7+
myproject

cookiecutter.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"author_name": "",
3-
"author_email": "",
4-
"github_project_name": "",
5-
"github_organization_name": "",
2+
"author_name": "me",
3+
"author_email": "[email protected]",
4+
"github_project_name": "myproject",
5+
"github_organization_name": "myorg",
66
"python_package_name": "{{ cookiecutter.github_project_name | replace('-', '_') }}",
77
"npm_package_name": "{{ cookiecutter.github_project_name }}",
88
"npm_package_version": "0.1.0",

{{cookiecutter.github_project_name}}/.github/workflows/build.yml

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,38 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
16+
python-version: ["3.7", "3.10"]
1217
steps:
1318
- name: Checkout
1419
uses: actions/checkout@v2
15-
- name: Install node
16-
uses: actions/setup-node@v1
17-
with:
18-
node-version: "12.x"
19-
- name: Install Python
20-
uses: actions/setup-python@v2
21-
with:
22-
python-version: "3.7"
23-
architecture: "x64"
2420

25-
- name: Setup pip cache
26-
uses: actions/cache@v2
27-
with:
28-
path: ~/.cache/pip
29-
key: pip-3.7-${{ hashFiles('package.json') }}
30-
restore-keys: |
31-
pip-3.7-
32-
pip-
33-
34-
- name: Get npm cache directory
35-
id: npm-cache
36-
run: |
37-
echo "::set-output name=dir::$(npm config get cache)"
38-
- uses: actions/cache@v2
39-
with:
40-
path: ${{ steps.npm-cache.outputs.dir }}
41-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
42-
restore-keys: |
43-
${{ runner.os }}-node-
21+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
4422

4523
- name: Install dependencies
4624
run: |
47-
python -m pip install -U pip setuptools codecov
25+
python -m pip install -U codecov
4826
npm install -g codecov
4927
- name: Test the extension
5028
run: |
5129
python -m pip install --upgrade -v -e ".[test, examples, docs]"
52-
yarn run lint:check
53-
54-
pytest
30+
python -m pytest
5531
yarn run test
5632
33+
- name: Linting
34+
if: ${{ matrix.os == 'ubuntu-latest' }}
35+
working-directory: jupyter-widget-testwidgets
36+
run: |
37+
yarn run lint:check
38+
5739
- name: Check docs can be build + links
40+
if: ${{ matrix.os == 'ubuntu-latest' }}
41+
working-directory: jupyter-widget-testwidgets/docs
5842
run: |
5943
sudo apt install -y pandoc
60-
pushd docs
6144
make html
6245
python -m pytest --check-links
63-
popd

{{cookiecutter.github_project_name}}/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,14 @@ After a change wait for the build to finish and then refresh your browser and th
7070

7171
#### Python:
7272
If you make a change to the python code then you will need to restart the notebook kernel to have it take effect.
73+
74+
## Updating the version
75+
76+
To update the version, install tbump and use it to bump the version.
77+
By default it will also create a tag.
78+
79+
```bash
80+
pip install tbump
81+
tbump <new-version>
82+
```
83+

{{cookiecutter.github_project_name}}/docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
#
8989
# This is also used if you do content translation via gettext catalogs.
9090
# Usually you set "language" from the command line for these cases.
91-
language = None
91+
language = "en"
9292

9393
# List of patterns, relative to source directory, that match files and
9494
# directories to ignore when looking for source files.
Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,112 @@
11
[build-system]
2-
requires = ["jupyter_packaging==0.7.9", "jupyterlab==3.*", "setuptools>=40.8.0", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = [
3+
"hatchling>=1.3.1",
4+
"jupyterlab==3.*",
5+
]
6+
build-backend = "hatchling.build"
7+
8+
[project]
9+
name = "{{ cookiecutter.python_package_name }}"
10+
description = "{{ cookiecutter.project_short_description }}"
11+
readme = "README.md"
12+
license = { file = "LICENSE.txt" }
13+
requires-python = ">=3.7"
14+
authors = [
15+
{ name = "{{ cookiecutter.author_name }}", email = "{{ cookiecutter.author_email }}" },
16+
]
17+
keywords = [
18+
"IPython",
19+
"Jupyter",
20+
"Widgets",
21+
]
22+
classifiers = [
23+
"Framework :: Jupyter",
24+
"Intended Audience :: Developers",
25+
"Intended Audience :: Science/Research",
26+
"License :: OSI Approved :: BSD License",
27+
"Programming Language :: Python",
28+
"Programming Language :: Python :: 3",
29+
"Programming Language :: Python :: 3.7",
30+
"Programming Language :: Python :: 3.8",
31+
"Programming Language :: Python :: 3.9",
32+
"Programming Language :: Python :: 3.10",
33+
]
34+
dependencies = [
35+
"ipywidgets>=7.0.0",
36+
]
37+
version = "0.1.0.dev0"
38+
39+
[project.optional-dependencies]
40+
docs = [
41+
"jupyter_sphinx",
42+
"nbsphinx",
43+
"nbsphinx-link",
44+
"pypandoc",
45+
"pytest_check_links",
46+
"recommonmark",
47+
"sphinx>=1.5",
48+
"sphinx_rtd_theme",
49+
]
50+
examples = []
51+
test = [
52+
"nbval",
53+
"pytest-cov",
54+
"pytest>=6.0",
55+
]
56+
57+
[project.urls]
58+
Homepage = "https://github.com/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.github_project_name }}"
59+
60+
[tool.hatch.build]
61+
artifacts = [
62+
"{{ cookiecutter.python_package_name }}/nbextension/index.*",
63+
"{{ cookiecutter.python_package_name }}/labextension/*.tgz",
64+
"{{ cookiecutter.python_package_name }}/labextension",
65+
]
66+
67+
[tool.hatch.build.targets.wheel.shared-data]
68+
"{{ cookiecutter.python_package_name }}/nbextension" = "share/jupyter/nbextensions/{{ cookiecutter.python_package_name }}"
69+
"{{ cookiecutter.python_package_name }}/labextension" = "share/jupyter/labextensions/{{ cookiecutter.python_package_name }}"
70+
"./install.json" = "share/jupyter/labextensions/{{ cookiecutter.python_package_name }}/install.json"
71+
"./{{ cookiecutter.python_package_name }}.json" = "etc/jupyter/nbconfig/notebook.d/{{ cookiecutter.python_package_name }}.json"
72+
73+
[tool.hatch.build.targets.sdist]
74+
exclude = [
75+
".github",
76+
]
77+
78+
[tool.hatch.build.hooks.jupyter-builder]
79+
build-function = "hatch_jupyter_builder.npm_builder"
80+
ensured-targets = [
81+
"{{ cookiecutter.python_package_name }}/nbextension/index.js",
82+
"{{ cookiecutter.python_package_name }}/labextension/package.json",
83+
]
84+
skip-if-exists = [
85+
"{{ cookiecutter.python_package_name }}/nbextension/index.js",
86+
"{{ cookiecutter.python_package_name }}/labextension/package.json",
87+
]
88+
dependencies = [
89+
"hatch-jupyter-builder>=0.5.0",
90+
]
91+
92+
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
93+
path = "."
94+
build_cmd = "build:prod"
95+
96+
[tool.tbump]
97+
field = [
98+
{ name = "channel", default = "" },
99+
{ name = "release", default = "" },
100+
]
101+
file = [
102+
{ src = "pyproject.toml", version_template = "version = \"{major}.{minor}.{patch}{channel}{release}\"" },
103+
{ src = "{{ cookiecutter.python_package_name }}/_version.py" },
104+
]
105+
106+
[tool.tbump.version]
107+
current = "0.1.0.dev0"
108+
regex = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)((?P<channel>a|b|rc|.dev)(?P<release>\\d+))?"
109+
110+
[tool.tbump.git]
111+
message_template = "Bump to {new_version}"
112+
tag_template = "v{new_version}"

{{cookiecutter.github_project_name}}/setup.cfg

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)