Jupyterlab build from source: how to release it, say as a pip (or conda) package?

I am able to build jupyterlab from source (jlpm run build; jlpm run build:core; jupyter lab build all works). So I am attempting to run test: jlpm run build:testutils. It succeed to run a number of tests (except in the module @jupyterlab/services which timeout).

Now I am ready to release it such that I can install this jupyterlab build into different docker images or conda environments. Following the essence of this: https://github.com/jupyterlab/jupyterlab/blob/ad0f1a5bc745a32086403cb89b98f33c09756e98/RELEASE.md
0. In running jlpm bumpversion minor, it ran into module not found for dependency-graph. After npm installing it, it failed in git status --porcelain (as I am not using a git to github). So I skip this step.

  1. In running # npm run publish:all, which translates to node buildutils/lib/publish.js, I ran into
    Error: Cannot find module ‘dependency-graph’.
    So I fix by npm install ‘dependency-graph’. Then repeat the steps for sort-package-json then package-json.
  2. npm run publish:all

npm run clean:slate

@ clean:slate /src/jupyterlab-2.2.x
python clean.py && python -m pip install -v -e .

Found existing installation: jupyterlab 2.2.9
Uninstalling jupyterlab-2.2.9:
Successfully uninstalled jupyterlab-2.2.9
fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
File “clean.py”, line 42, in
subprocess.check_call(git_clean_command, cwd=here)
File “/opt/conda/envs/jupyterlab-dev/lib/python3.6/subprocess.py”, line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘git’, ‘clean’, ‘-dfx’, ‘–exclude=.iml’, '–exclude=!packages/**/.iml’, ‘–exclude=!/node_modules//.iml’, ‘–exclude=.idea/’, ‘–exclude=!packages//.idea/', '–exclude=!/node_modules/**/.idea/’, '–exclude=.code-workspace’, ‘–exclude=!packages//*.code-workspace’, '–exclude=!/node_modules//*.code-workspace’, ‘–exclude=.history’, '–exclude=!packages//.history’, ‘–exclude=!/node_modules//.history’, ‘–exclude=.vscode’, ‘–exclude=!packages//.vscode’, '–exclude=!/node_modules/**/.vscode’]’ returned non-zero exit status 128.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ clean:slate: python clean.py && python -m pip install -v -e .
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ clean:slate script.

Any idea or suggestion in how to fix this?
Note that I just want to package the built source and release it into an installable package so that it can be installed by pip or by conda.
Thanks very much!!

1 Like

I think I got further now, and be able to create a .whl for pip install.
Basically, I just follow the key steps in buildutils/src/publish.ts:

$ node buildutils/lib/update-core-mode.js # integrity check
$ python setup.py sdist # generate the tar gz
$ python setup.py bdist_wheel  # generate the .whl
$ python -m pip install -U twine # install twine package
$ twine check dist/* # check both .whl and targz in dist/

Need help!!

Unfortunately, the modified source code in the packages/*-extension/src/index.ts were not added to the generated sdist tar file and wheel file.

It just picked up what were in the staging/, and called webpack to generate the content in static/. The staging files were what was installed from standard npm install (and nothing from the modified dev source). What is needed is to propagate the changes in the dev source code to staging, and I cannot find any way to do it.

Does anyone know how to propagate the changes in source code (visible in jupyterlab --dev-mode) and propagate to staging/ (so that the changes can be packaged into a release wheel file)? Thanks!

1 Like

Eventually, I found a solution, a rather hack: i just figure out which staging files corresponding to my dev source, and update those manually (through a script). Since I have only a few source code, this was not too bad.

See also my answer at your other post: Jupterlab source build - how are the content of directory staging/ got populated? - #4 by jasongrout

Hello,

I’m honored to use JupyterLab and I’ve successfully completed the development process. However, when packaging and building, I found that my development changes did not take effect in the generated .whl file.

I have carefully read through the previous discussions but I’m still unclear on a few points. Currently, I have modified contents under jupyterlab/packages/application/src in development mode and used python -m build for packaging. Yet, I noticed no changes in the packaged content.

Upon inspecting pyproject.toml, I observed that the ‘packages’ section has been excluded. But I’m uncertain about how to proceed from here.

Here’s a relevant segment of the configuration in pyproject.toml:

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod:minimize"
path = "jupyterlab/staging"
source_dir = "jupyterlab/staging"
build_dir = "jupyterlab/static"
npm = ["node", "yarn.js"]

I believe this code snippet is related to the issue at hand, but I’m unsure about how it fits into the bigger picture.

Any advice or suggestions would be greatly appreciated. Thank you very much in advance!

Best regards,
eason