using_uv/Files/jl_w_pylock.txt
2025-10-19 23:37:17 -04:00

40 lines
1.5 KiB
Text

Using pylock.toml:
1. Create a requirements.in file that has the full path to the local libraries folder:
.local-libraries/tufte-0.7.0-py3-none-any.whl
.local-libraries/clear_run_to_selected-0.3.0-py3-none-any.whl
This is somewhat inconvenient because it means that the requirements.in file has to be updated when the version of one of these libraries changes.
2. Use uv to create the pylock.toml file:
uv pip compile requirements.in -o pylock.toml
3. Have uv create the venv:
uv venv
uv pip sync pylock.toml
4. Use the t.sh script to run Jupyter lab. The script creates environment variables for the Jupyter paths, adds .venv/bin to the PATH and and starts jupyter with the lab option:
#!/bin/bash
export JUPYTERLAB_SETTINGS_DIR="${PWD}/.jupyter/lab/user-settings"
export JUPYTER_DATA_DIR="${PWD}/.jupyter/data"
export JUPYTER_CONFIG_DIR="${PWD}/.jupyter"
export VIRTUAL_ENV_PROMPT=.venv
export PATH=".venv/bin:$PATH"
jupyter lab
5. Note that this approach pins all of the versions, including all the versions for Jupyter Lab. One can argue that this is good in the sense that users will not run new libraries created after the date when the current lock file was generated. However, if we want to always be just 30 days behind the most recent versions, we have to continually:
- update the update the requirements.in file and the wheels in the local-libraries folder
- recreate the `pylock.toml` file generated from the requirements.in file
- re-run the command `uv pip sync pylock.toml`