Skip to content

Commit 8a24161

Browse files
authored
Merge pull request #371 from bollwyvl/gh-370-hatchling
Adopt hatchling, plugins for python package build
2 parents bf858b1 + e405fbe commit 8a24161

File tree

13 files changed

+222
-213
lines changed

13 files changed

+222
-213
lines changed

.github/workflows/publish.yaml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,26 @@ jobs:
3535

3636
steps:
3737
- uses: actions/checkout@v3
38+
3839
- uses: actions/setup-python@v4
3940
with:
4041
python-version: "3.11"
4142

43+
- uses: actions/setup-node@v3
44+
with:
45+
cache: yarn
46+
node-version: 18.x
47+
registry-url: https://registry.npmjs.org
48+
cache-dependency-path: labextension/yarn.lock
49+
50+
- name: Update root build packages
51+
run: |
52+
pip install --upgrade build pip
53+
4254
- name: Build dist
4355
run: |
44-
pip install jupyter_packaging wheel jupyterlab~=3.0
45-
python setup.py sdist bdist_wheel
56+
pyproject-build
57+
cd dist && sha256sum * | tee SHA256SUMS
4658
4759
- name: Check dist sizes
4860
run: |
@@ -53,8 +65,9 @@ jobs:
5365
- name: Javascript package
5466
run: |
5567
mkdir jsdist
56-
cd labextension
57-
jlpm pack --filename ../jsdist/labextension-jlpmpack.tgz
68+
cd jsdist
69+
npm pack ../labextension
70+
sha256sum * | tee SHA256SUMS
5871
5972
- name: Upload Python artifact
6073
uses: actions/upload-artifact@v3
@@ -112,9 +125,11 @@ jobs:
112125
name: jsdist
113126
path: jsdist
114127

115-
- run: npm publish --dry-run ./jsdist/labextension-jlpmpack.tgz
128+
- run: |
129+
npm publish --dry-run ./jsdist/jupyterhub-jupyter-server-proxy-*.tgz
116130
117-
- run: npm publish ./jsdist/labextension-jlpmpack.tgz
131+
- run: |
132+
npm publish ./jsdist/jupyterhub-jupyter-server-proxy-*.tgz
118133
if: startsWith(github.ref, 'refs/tags')
119134
env:
120135
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yaml

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,61 +43,71 @@ jobs:
4343

4444
steps:
4545
- uses: actions/checkout@v3
46+
4647
- uses: actions/setup-python@v4
4748
with:
4849
python-version: "${{ matrix.python-version }}"
4950

51+
- uses: actions/setup-node@v3
52+
with:
53+
cache: yarn
54+
node-version: 18.x
55+
registry-url: https://registry.npmjs.org
56+
cache-dependency-path: labextension/yarn.lock
57+
58+
- name: Update root build packages
59+
run: |
60+
pip install --upgrade build pip
61+
5062
- name: Build Python package
5163
run: |
52-
pip install jupyter_packaging wheel jupyterlab
53-
python setup.py sdist bdist_wheel
64+
pyproject-build
5465
55-
- name: Install Python dependencies
66+
- name: Install Python package
5667
# NOTE: See CONTRIBUTING.md for a local development setup that differs
5768
# slightly from this.
5869
#
5970
# Pytest options are set in tests/pytest.ini.
6071
run: |
61-
pip install --upgrade pip
62-
pip install jupyter_packaging jupyterlab~=${{ matrix.jupyterlab-version }}.0
63-
pip install ./dist/jupyter_server_proxy-*.whl
64-
pip install pytest pytest-cov pytest-html
65-
# Ensure we don't accidentally depend on notebook
66-
if [ "${{ matrix.jupyter-app }}" == "notebook" ]; then
67-
pip install "notebook<7"
68-
fi
72+
pip install -vv $(ls ./dist/jupyter_server_proxy-*.whl)\[acceptance\] 'jupyterlab~=${{ matrix.jupyterlab-version }}.0'
73+
74+
- name: List Python packages
75+
run: |
6976
pip freeze
77+
pip check
7078
7179
- name: Run tests
7280
run: |
7381
JUPYTER_TOKEN=secret jupyter-${{ matrix.jupyter-app }} --config=./tests/resources/jupyter_server_config.py &
7482
sleep 5
7583
cd tests
76-
pytest
84+
pytest -k "not acceptance"
7785
7886
- name: Upload pytest and coverage reports
7987
if: always()
8088
uses: actions/upload-artifact@v3
8189
with:
82-
name: unit-tests-${{ matrix.python-version }}-${{ matrix.jupyter-app }}-${{ matrix.jupyterlab-version }}-${{ github.run_number }}
90+
name: |-
91+
unit-tests-${{ matrix.python-version }}-${{ matrix.jupyter-app }}-${{ matrix.jupyterlab-version }}-${{ github.run_number }}
8392
path: |
8493
./build/pytest
8594
./build/coverage
8695
8796
- name: Check the Notebook Server extension is installed
8897
run: |
8998
jupyter serverextension list
90-
jupyter serverextension list 2>&1 | grep -ie "jupyter_server_proxy.*enabled" -
99+
jupyter serverextension list 2>&1 | grep -iE "jupyter_server_proxy.*OK" -
91100
92101
- name: Check the Jupyter Server extension is installed
93102
run: |
94103
pip install jupyter-server
95104
jupyter server extension list
96-
jupyter server extension list 2>&1 | grep -ie "jupyter_server_proxy.*enabled" -
105+
jupyter server extension list 2>&1 | grep -iE "jupyter_server_proxy.*OK" -
97106
98107
- name: Install JupyterLab Extension
99108
if: matrix.jupyterlab-version == '2'
100109
run: |
110+
export NODE_OPTIONS=--openssl-legacy-provider
101111
cd labextension
102112
jupyter labextension install . --no-build --debug
103113
jupyter lab build --minimize=False --debug
@@ -108,25 +118,21 @@ jobs:
108118
# jupyterlab.browser_check with jupyterlab 2 and a modern version of
109119
# python (3.11+).
110120
#
111-
if: ${{ !(matrix.jupyterlab-version == '2' && startsWith(matrix.python-version, '3.1')) }}
121+
if: ${{ !(matrix.jupyterlab-version == '2' && startsWith(matrix.python-version, '3.11')) }}
112122
run: |
113123
jupyter labextension list
114-
jupyter labextension list 2>&1 | grep -ie '@jupyterhub/jupyter-server-proxy.*OK.*'
124+
jupyter labextension list 2>&1 | grep -iE '@jupyterhub/jupyter-server-proxy.*OK.*'
115125
python -m jupyterlab.browser_check
116126
117-
- name: Install Acceptance test dependencies
118-
run: |
119-
# the acceptance test requires notebook to run
120-
pip install "notebook<7" "robotframework-jupyterlibrary>=0.4.2"
121-
122127
- name: Run acceptance tests
123128
run: |
124-
pytest -k acceptance -s
129+
pytest -s -k "acceptance"
125130
126131
- name: Upload acceptance test reports
127132
if: always()
128133
uses: actions/upload-artifact@v3
129134
with:
130-
name: acceptance-tests-${{ matrix.python-version }}-${{ matrix.jupyter-app }}-${{ matrix.jupyterlab-version }}-${{ github.run_number }}
135+
name: |-
136+
acceptance-tests-${{ matrix.python-version }}-${{ matrix.jupyter-app }}-${{ matrix.jupyterlab-version }}-${{ github.run_number }}
131137
path: |
132138
./build/robot

CONTRIBUTING.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ the README.md file.
1010
### Python package
1111

1212
```bash
13-
pip install -e .[test]
13+
pip install -e ".[test]"
1414

1515
# explicit install needed with editable mode (-e) jupyter
1616
jupyter serverextension enable --sys-prefix jupyter_server_proxy
@@ -19,7 +19,7 @@ jupyter server extension enable --sys-prefix jupyter_server_proxy
1919

2020
Before running tests, you need a server that we can test against.
2121

22-
```
22+
```bash
2323
JUPYTER_TOKEN=secret jupyter-lab --config=./tests/resources/jupyter_server_config.py --no-browser
2424
```
2525

@@ -39,15 +39,15 @@ To install these in addition to the [Python package](#python-package) test
3939
dependencies, run:
4040

4141
```bash
42-
pip install -e .[test,acceptance]
42+
pip install -e ".[acceptance]"
4343
```
4444

4545
In addition, compatible versions of:
4646

4747
- `geckodriver`
4848
- `firefox`
4949

50-
Needs to be on your `$PATH` and compatible with each other.
50+
Need to be on your `$PATH` and compatible with each other.
5151

5252
To run _only_ the acceptance tests, use the `-k` switch:
5353

@@ -74,11 +74,47 @@ jlpm build:prod # Build:
7474
jlpm install:extension # Symlink into `{sys.prefix}/share/jupyter/labextensions`
7575
```
7676

77-
You can watch the source directory and automatically rebuild the `lib` folder:
77+
You can watch the source directory and automatically rebuild the `labextension/lib`
78+
and `jupyter_server_proxy/labextension` folders:
79+
80+
```bash
81+
cd labextension
82+
jlpm watch
83+
```
84+
85+
### Documentation
86+
87+
The documentation uses a fairly standard [Sphinx](https://www.sphinx-doc.org)
88+
build chain, and requires `make` on Linux/MacOS, which cannot be installed with
89+
`pip`.
90+
91+
In addition to any system packages, building the documentation requires
92+
additional packages. To install the needed packages:
93+
94+
```bash
95+
pip install -r docs/requirements.txt
96+
```
97+
98+
Once installed, enter the docs folder with:
7899

79100
```bash
80-
jlpm watch # ... watch the source directory in another terminal tab
101+
cd docs
81102
```
82103

83-
However, the built-in `jupyter labextension watch` does _not_ work with this repo,
84-
as the `package.json` and `setup.py` would need to be at the same level.
104+
... then build the HTML site:
105+
106+
```bash
107+
make
108+
```
109+
110+
... or check that all hyperlinks can be resolved:
111+
112+
```bash
113+
make linkcheck
114+
```
115+
116+
... or start an auto-reloading server and open a web browser:
117+
118+
```bash
119+
make devenv
120+
```

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ contains information on installation & usage.
3535
## Security warning
3636

3737
Jupyter Server Proxy is often used to start a user defined process listening to
38-
some network port (e.g. http://localhost:4567) for a user starting a Jupyter Server
38+
some network port (e.g. `http://localhost:4567`) for a user starting a Jupyter Server
3939
that only that user has permission to access. The user can then access the
4040
started process proxied through the Jupyter Server.
4141

@@ -47,7 +47,7 @@ A common strategy to enforce access proxied via Jupyter Server is to start
4747
Jupyter Server within a container and only allow network access to the Jupyter
4848
Server via the container.
4949

50-
For more insights, see [Ryan Lovetts comment about
50+
> For more insights, see [Ryan Lovett's comment about
5151
it](https://github.com/jupyterhub/jupyter-server-proxy/pull/359#issuecomment-1350118197).
5252

5353
## Install
@@ -58,18 +58,22 @@ it](https://github.com/jupyterhub/jupyter-server-proxy/pull/359#issuecomment-135
5858

5959
### Python package
6060

61-
#### pip
61+
#### `pip`
6262

63-
```
63+
```bash
6464
pip install jupyter-server-proxy
6565
```
6666

67-
#### conda
67+
#### `conda`
6868

69-
```
69+
```bash
7070
conda install jupyter-server-proxy -c conda-forge
7171
```
7272

73+
#### Local development
74+
75+
> See the [contributing guide](https://github.com/jupyterhub/jupyter-server-proxy/blob/main/CONTRIBUTING.md).
76+
7377
### JupyterLab extension
7478

7579
Note that as the JupyterLab extension only is a graphical interface to
@@ -79,30 +83,27 @@ requires the python package to be installed.
7983
As of version 3.0.0 the Python package ships with a JupyterLab 3 compatible
8084
extension, making this step only needed for JupyterLab 2.
8185

82-
```
86+
```bash
8387
jupyter labextension install @jupyterhub/jupyter-server-proxy
8488
```
8589

8690
## Disable
8791

8892
### Server extension
8993

90-
``` 
91-
jupyter serverextension disable jupyter_server_proxy
94+
```bash
95+
jupyter serverextension disable --sys-prefix jupyter_server_proxy
96+
jupyter server extension disable --sys-prefix jupyter_server_proxy
9297
```
9398

9499
### Notebook classic extension
95100

96-
```
97-
jupyter nbextension disable --py jupyter_server_proxy
101+
```bash
102+
jupyter nbextension disable --sys-prefix --py jupyter_server_proxy
98103
```
99104

100105
### JupyterLab extension
101106

102-
```
107+
```bash
103108
jupyter labextension disable @jupyterhub/jupyter-server-proxy
104109
```
105-
106-
## Local development
107-
108-
See [CONTRIBUTING.md](CONTRIBUTING.md).

RELEASE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ These are instructions on how to make a release.
2020
```shell
2121
rm labextension/yarn.lock
2222

23-
pip install jupyter_packaging wheel jupyterlab~=3.0
24-
python setup.py sdist bdist_wheel
23+
pip install --upgrade pip build
24+
pyproject-build
2525
```
2626

2727
2. Create a PR updating `docs/source/changelog.md` with [github-activity][] and

labextension/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# @jupyterhub/jupyter-server-proxy labextension
1+
# `@jupyterhub/jupyter-server-proxy`
22

3-
This JupyterLab extension that is bundled and requires with the PyPI package
4-
jupyter-server-proxy adds items to the JupyterLab [Launcher] representing the
5-
configured server processes.
3+
A JupyterLab extension that adds items to the JupyterLab [Launcher] representing the
4+
configured server processes managed by the python package `jupyter-server-proxy` (required).
65

76
[launcher]: https://jupyterlab.readthedocs.io/en/stable/extension/extension_points.html#launcher
87

@@ -25,7 +24,7 @@ conda install jupyter-server-proxy
2524
```
2625

2726
> As a _prebuilt_ extension, it will "just work," only a simple page reload should be required
28-
> to see launcher items. However, a full restart of `jupyter_server` or `notebook` is required
27+
> to see launcher items. However, a full restart of `jupyter_server` or `notebook` is required
2928
> to reload the `jupyter_server_proxy` serverextension which provides most of the functionality.
3029
3130
### JupyterLab 2

labextension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
3939
"install:extension": "jupyter labextension develop --overwrite .",
4040
"watch": "run-p watch:src watch:labextension",
41-
"watch:src": "jlpm build:lib -w",
41+
"watch:src": "jlpm build:lib -w --preserveWatchOutput",
4242
"watch:labextension": "jupyter labextension watch .",
4343
"deduplicate": "yarn-deduplicate -s fewer --fail"
4444
},

0 commit comments

Comments
 (0)