Skip to content
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

Use hatch backend #6425

Merged
merged 10 commits into from
Jun 13, 2022
Merged

Use hatch backend #6425

merged 10 commits into from
Jun 13, 2022

Conversation

blink1073
Copy link
Contributor

@blink1073 blink1073 commented May 14, 2022

  • Uses new hatch_jupyter_builder plugin
  • hatch is a newly minted pypa project, and appears to be a drop-in replacement for our use of setuptools / jupyter-packaging

@github-actions
Copy link
Contributor

Binder 👈 Launch a Binder on branch blink1073/notebook/use-hatch

@blink1073
Copy link
Contributor Author

We're blocked by pypa/hatch#243.

@blink1073
Copy link
Contributor Author

Found a workaround using force-include

@ofek
Copy link

ofek commented May 18, 2022

FYI just released https://github.com/pypa/hatch/releases/tag/hatchling-v1.0.0

Also I think you can copy what you did here ipython/ipyparallel@e3e896a

@blink1073
Copy link
Contributor Author

Thanks, and congratulations!

@blink1073
Copy link
Contributor Author

We can remove setup.py once jupyter-server/jupyter_releaser#319 is released, then this should be good to go!

@ofek
Copy link

ofek commented May 18, 2022

It's undocumented until I find an auto-generator for non-Click CLIs, but if build deps are met you can do hatchling version

@blink1073
Copy link
Contributor Author

if build deps are met you can do hatchling version

Thanks! Perhaps https://sphinx-argparse.readthedocs.io/en/stable/?

@blink1073
Copy link
Contributor Author

Perhaps sphinx-argparse.readthedocs.io/en/stable?

Ah, you are using mkdocs...

@blink1073
Copy link
Contributor Author

@jtpio, any idea why the snapshot tests are failing?

@jtpio
Copy link
Member

jtpio commented May 18, 2022

It looks like the menu and toolbar customization files are missing (defined in schema) for one of the failures:

image

@blink1073
Copy link
Contributor Author

It looks like the menu and toolbar customization files are missing (defined in schema) for one of the failures

Thanks!

@blink1073
Copy link
Contributor Author

Hmm, after adding the schemas the tests don't appear to start at all.

@jtpio
Copy link
Member

jtpio commented May 20, 2022

Hmm, after adding the schemas the tests don't appear to start at all.

hmm strange. For the UI tests the package is first installed with the following:

python -m pip install -vv notebook*.whl

Will check locally.

@jtpio
Copy link
Member

jtpio commented May 20, 2022

Nice, CI is now passing with fcdb15f.

Looks like there are a few conflicts after the merge of #6429.

add flake8 config

add artifacts

cleanup

use tbump to get current version

cleanup for new dep versions

clean up workflows

switch back to bumpversion

fix verion

fixup

fixup

fixup

fixup

fix version check

fixups

try version handling again

version cleanup

fix typescript error

undo bump2version changes

include schemas and add build timeouts

fix workflow syntax

more workflow cleanup

clean up config
@jtpio
Copy link
Member

jtpio commented May 31, 2022

Ah I thought CI was already uploading the built assets as artifacts.

Maybe we could add the following step to the check release workflow so it's easier to inspect the sdist and wheel?

- name: Upload Distributions
  uses: actions/upload-artifact@v2
  with:
    name: notebook-jupyter-releaser-dist-${{ github.run_number }}
    path: .jupyter_releaser_checkout/dist

@blink1073
Copy link
Contributor Author

blink1073 commented May 31, 2022

Good call. I also played with my wip comparison script and got this output now:

python ../extension-cookiecutter-ts/compare.py ../notebook_orig . sdist

Removed_files:
notebook-7.0.0a4/jupyter-config/jupyter_server_config.d
notebook-7.0.0a4/jupyter-config/jupyter_server_config.d/notebook.json
notebook-7.0.0a4/notebook/labextension/static/remoteEntry.4fb60df0e7df1388ab11.js


Added files:
notebook-7.0.0a4/notebook/labextension/static/remoteEntry.5ea5fe7dc5a5fbc91231.js
notebook-7.0.0a4/jupyter_config.json
notebook-7.0.0a4/lerna.json
notebook-7.0.0a4/pyrightconfig.json
notebook-7.0.0a4/.eslintrc.json

@blink1073
Copy link
Contributor Author

blink1073 commented May 31, 2022

Here's the latest output:

Successfully built notebook-7.0.0a4.tar.gz
Removed_files:
notebook-7.0.0a4/jupyter-config/jupyter_server_config.d
notebook-7.0.0a4/notebook/labextension/static/remoteEntry.4fb60df0e7df1388ab11.js


Added files:
notebook-7.0.0a4/notebook/labextension/static/remoteEntry.5ea5fe7dc5a5fbc91231.js
Successfully built notebook-7.0.0a4-py3-none-any.whl
Removed_files:
notebook/labextension/static/remoteEntry.4fb60df0e7df1388ab11.js
notebook-7.0.0a4.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/remoteEntry.4fb60df0e7df1388ab11.js
notebook-7.0.0a4.dist-info/top_level.txt

Added files:
notebook-7.0.0a4.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/remoteEntry.5ea5fe7dc5a5fbc91231.js
notebook/labextension/static/remoteEntry.5ea5fe7dc5a5fbc91231.js

@jtpio
Copy link
Member

jtpio commented Jun 1, 2022

Looking good!

@jtpio
Copy link
Member

jtpio commented Jun 1, 2022

The Binder for this PR fails to build because of the following error:

image

Which seems to be related to the jupyter labextension develop command expecting to find a setup.py:

https://github.com/jupyterlab/jupyterlab/blob/6099bcb4d32902bd61b82df818cdd2df3fe1685c/jupyterlab/federated_labextensions.py#L427-L438

@jtpio
Copy link
Member

jtpio commented Jun 1, 2022

Which seems to be related to the jupyter labextension develop command expecting to find a setup.py:

This is likely to be fixed by jupyterlab/jupyterlab#12606.

@blink1073
Copy link
Contributor Author

Yeah I think we need to use a setup.py shim for extensions that are targeting versions of jupyterlab that require it. Once we have 3.x and 4.x versions that don't require it, the cookiecutter itself can be updated to not include it. For the migration script, we can include it if there was already one there and eventually remove it.

@blink1073
Copy link
Contributor Author

Drat, now we have the issue that symlinks can't be created over existing files. With setuptools the shared data was not written in editable mode. It feels like we need to fix a few bugs and backport them in JupyterLab before doing any migrations. We shouldn't need a setup.py and we shouldn't error out when overwriting symlinks.

@ofek
Copy link

ofek commented Jun 1, 2022

Hatchling resolves symlinks fyi

@blink1073
Copy link
Contributor Author

The issue is the JupyterLab build command is trying to create symlinks over the files that are placed into /share and causing an error. This issue is purely of our own making. 😄

@blink1073
Copy link
Contributor Author

Ah, the symlink error was actually from a file in this repository, the binder is working now. I actually think this PR is good to go now.

@blink1073 blink1073 marked this pull request as ready for review June 10, 2022 22:18
source = "code"

[tool.hatch.build.targets.wheel.shared-data]
"notebook/labextension" = "share/jupyter/labextensions/@jupyter-notebook/lab-extension"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blink1073 I'm not an expert on the filesystem layout for JupyterLab extensions, but should this be

Suggested change
"notebook/labextension" = "share/jupyter/labextensions/@jupyter-notebook/lab-extension"
"notebook/labextension" = "share/jupyter/labextensions/@jupyter-notebook"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this should be kept since it maps to "notebook/labextension" on the left hand side?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree

Copy link

@agoose77 agoose77 Jun 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I could be wrong but I thought the output directory contents were supposed to end up in share/jupyter/labextensions/@jupyter-notebook/

If you look e.g. at the wheel for jupyterlab-katex, the contents of /jupyterlab_katex-3.3.0.data/data/share/jupyter/labextensions/@jupyterlab/katex-extension/ is

schemas
static
install.json
package.json

whereas in notebook's wheel we currently have the following files in /notebook-7.0.0a4.data/data/share/jupyter/labextensions/@jupyter-notebook/:

lab-extension

E.g. this is jupyterlab-myst which works: https://github.com/agoose77/jupyterlab-myst/blob/320b15187ee605b1f948619e9e1f9cfa672eaf00/pyproject.toml#L57

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension is nested in our case, under @jupyter-notebook. The full extension name is @jupyter-notebook/lab-extension.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'm with you. This is where the fact that / is allowed in NPM package names threw me for a second!

@@ -1,4 +0,0 @@
{
"LabApp": { "collaborative": true, "expose_app_in_browser": true },
"JupyterNotebookApp": { "collaborative": true, "expose_app_in_browser": true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we want to keep this file, so RTC can be tested on Binder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored

Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!

Looking good on Binder and also locally using the assets built by the releaser.

Left a small comment about the config for testing RTC on Binder, but otherwise looks good!

@blink1073 blink1073 merged commit 614e478 into jupyter:main Jun 13, 2022
@blink1073 blink1073 deleted the use-hatch branch June 13, 2022 15:19
@jtpio
Copy link
Member

jtpio commented Jun 13, 2022

Starting a new pre-release with this change.

@jtpio
Copy link
Member

jtpio commented Jun 13, 2022

Ah looks like something is wrong with the Python version: #6448

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants