From 069425ac75faa3096b602337fab4d0d208b3c7bb Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Fri, 3 Nov 2023 23:55:40 +0000 Subject: [PATCH 1/2] Fix the links to src/jupytext --- docs/advanced-options.md | 2 +- docs/formats-scripts.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/advanced-options.md b/docs/advanced-options.md index d668a26ad..c4514a85d 100644 --- a/docs/advanced-options.md +++ b/docs/advanced-options.md @@ -39,4 +39,4 @@ You might want to make some cell active only when the notebook is run in Jupyter ## More options -There are a couple more options available - please have a look at the `JupytextConfiguration` class in [config.py](https://github.com/mwouts/jupytext/blob/main/jupytext/config.py). +There are a couple more options available - please have a look at the `JupytextConfiguration` class in [config.py](https://github.com/mwouts/jupytext/blob/main/src/jupytext/config.py). diff --git a/docs/formats-scripts.md b/docs/formats-scripts.md index 65e88566f..445bba1b4 100644 --- a/docs/formats-scripts.md +++ b/docs/formats-scripts.md @@ -2,7 +2,7 @@ ## The `percent` format -The `percent` format is a representation of Jupyter notebooks as scripts, in which all cells are explicitly delimited with a commented double percent sign `# %%`. The `percent` format is currently available for these [languages](https://github.com/mwouts/jupytext/blob/main/jupytext/languages.py). +The `percent` format is a representation of Jupyter notebooks as scripts, in which all cells are explicitly delimited with a commented double percent sign `# %%`. The `percent` format is currently available for these [languages](https://github.com/mwouts/jupytext/blob/main/src/jupytext/languages.py). The format was introduced by Spyder in 2013, and is now supported by many editors, including - [Spyder IDE](https://docs.spyder-ide.org/editor.html#defining-code-cells), @@ -70,7 +70,7 @@ By default, [Jupyter magics](advanced-options.md#magic-commands) are commented i ## The `light` format -The `light` format was introduced by Jupytext. That format can represent any script in one of these [languages](https://github.com/mwouts/jupytext/blob/main/jupytext/languages.py) as a Jupyter notebook. +The `light` format was introduced by Jupytext. That format can represent any script in one of these [languages](https://github.com/mwouts/jupytext/blob/main/src/jupytext/languages.py) as a Jupyter notebook. When a script in the `light` format is converted to a notebook, Jupytext code paragraphs are turned into code cells, and comments that are not adjacent to code are converted to Markdown cells. Cell breaks occurs on blank lines outside of functions, classes or multiline comments. From 865a242f85e5361b38bcdf8bfb52171d0b9a6d80 Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Sat, 11 Nov 2023 22:38:38 +0000 Subject: [PATCH 2/2] Update the development environment (#1156) * pre-commit autoupdate * Update the conda environments * Update the development instructions * Remove unused files --- .ci/environment-ci.yml | 4 +-- .lgtm.yml | 4 --- .pre-commit-config.yaml | 24 +++++-------- Makefile | 19 ---------- docs/developing.md | 22 +++++------- environment.yml | 16 +++------ .../jupyterlab-jupytext-extension/README.md | 15 ++++---- make.bat | 35 ------------------- 8 files changed, 30 insertions(+), 109 deletions(-) delete mode 100644 .lgtm.yml delete mode 100644 Makefile delete mode 100644 make.bat diff --git a/.ci/environment-ci.yml b/.ci/environment-ci.yml index db74a0316..5243e0b6b 100644 --- a/.ci/environment-ci.yml +++ b/.ci/environment-ci.yml @@ -15,7 +15,7 @@ dependencies: - nbformat>=5.1.2 - pyyaml - toml - - markdown-it-py~=1.0 + - markdown-it-py - mdit-py-plugins - pip - pytest @@ -25,7 +25,7 @@ dependencies: - flake8 - autopep8 - black - - isort>=5.3.0 + - isort - pandoc==2.16.2 - sphinx-gallery<0.8 - pre-commit diff --git a/.lgtm.yml b/.lgtm.yml deleted file mode 100644 index e741b2ed7..000000000 --- a/.lgtm.yml +++ /dev/null @@ -1,4 +0,0 @@ -extraction: - python: - index: - exclude: demo diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d26ef1e74..e66eccbfe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ exclude: > repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-json - id: check-yaml @@ -26,23 +26,11 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v3.9.0 + rev: v3.15.0 hooks: - id: pyupgrade args: ["--py38-plus"] - - repo: https://github.com/myint/autoflake - rev: v2.2.0 - hooks: - - id: autoflake - args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable'] - - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.0 - hooks: - - id: ruff - args: ["--fix", "--show-fixes"] - - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: @@ -52,6 +40,12 @@ repos: args: ["--profile", "black"] - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.11.0 hooks: - id: black + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.5 + hooks: + - id: ruff + args: ["--fix", "--show-fixes"] diff --git a/Makefile b/Makefile deleted file mode 100644 index e837d6813..000000000 --- a/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -SOURCEDIR = . -BUILDDIR = .build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/developing.md b/docs/developing.md index 38f256f5f..5c78aa2a6 100644 --- a/docs/developing.md +++ b/docs/developing.md @@ -22,11 +22,14 @@ Most of Jupytext's code is written in Python. To develop the Python part of Jupy ``` conda env create --file environment.yml # or conda env update --file ... conda activate jupytext-dev -python -m ipykernel install --name jupytext-dev --user -pip install -e . ``` -We use the [pre-commit](https://pre-commit.com) package to run pre-commit scripts like `black` and `flake8` on the code. +Install the `jupytext` package in development mode with +``` +pip install -e '.[dev]' +``` + +We use the [pre-commit](https://pre-commit.com) package to run pre-commit scripts like `black` and `ruff` on the code. Install it with ``` pre-commit install @@ -37,20 +40,11 @@ Tests are executed with `pytest`. You can run them in parallel with for instance pytest -n 5 ``` -Build the `jupytext` package and install it with -``` -pip install -U build wheel -python -m build -pip install dist/jupytext-x.x.x-py3-none-any.whl +Some tests require a Jupyter kernel pointing to the current environment: ``` - -or with -``` -pip install . +python -m ipykernel install --name jupytext-dev --user ``` -Finally, note that you can use `HATCH_BUILD_HOOKS_ENABLE=false` if you don't need the lab extension - the build time will be slightly shorter. - ## Jupytext's extension for JupyterLab Our extension for JupyterLab adds a series of Jupytext commands to JupyterLab. The code is in `packages/labextension`. See the `README.md` there for instructions on how to develop that extension. diff --git a/environment.yml b/environment.yml index d1c389df8..87959902c 100644 --- a/environment.yml +++ b/environment.yml @@ -12,7 +12,6 @@ dependencies: - mdit-py-plugins - nbconvert - ipykernel - - jupyter_contrib_nbextensions - pytest - pytest-xdist - pytest-randomly @@ -20,17 +19,10 @@ dependencies: - pre-commit - gitpython - pylint - - flake8==3.9.1 - - black==21.4b2 - - isort==5.8.0 + - flake8 + - black==23.11.0 + - isort==5.12.0 - autopep8 - sphinx-gallery<0.8 - - pip - - setuptools - - twine - pandoc==2.16.2 - # make html in docs folder - - sphinx - - tox-conda - - pip: - - sphinx_copybutton + - nodejs>=20 diff --git a/jupyterlab/packages/jupyterlab-jupytext-extension/README.md b/jupyterlab/packages/jupyterlab-jupytext-extension/README.md index 7c29efcc2..d36e2d420 100644 --- a/jupyterlab/packages/jupyterlab-jupytext-extension/README.md +++ b/jupyterlab/packages/jupyterlab-jupytext-extension/README.md @@ -13,26 +13,25 @@ Most users do not need to install this extension, since it is already included i Please install [Jupytext](https://github.com/mwouts/jupytext/blob/main/README.md#Install) first. As mentioned above, both the `pip` and `conda` packages do include the latest version of the JupyterLab extension, so in most cases you don't need to specifically install this `npm` package. -In case you're not using JupyterLab 3.x, you will have to install an older version of the extension that is compatible with your version. Please first install `jupytext` using `pip` or `conda`, and then downgrade the extension to a version compatible with your version of Jupyter Lab with: +In case you're not using JupyterLab 4.x, you will have to install an older version of the extension that is compatible with your version. Please first install `jupytext` using `pip` or `conda`, and then downgrade the extension to a version compatible with your version of Jupyter Lab with: ```bash +jupyter labextension install jupyterlab-jupytext@1.3.11 # for JupyterLab 3.x jupyter labextension install jupyterlab-jupytext@1.2.2 # for JupyterLab 2.x jupyter labextension install jupyterlab-jupytext@1.1.1 # for JupyterLab 1.x ``` # How to develop this extension -We assume that you have activated the conda environment described in [CONTRIBUTING.md](https://github.com/mwouts/jupytext/blob/main/CONTRIBUTING.md). - -Then you can rebuild the Jupytext python package (with `python -m build`) and reinstall it (`pip install dist/jupytext-x.x.x-py3-none-any.whl`). - -Alternatively, if you prefer to develop iteratively, you could install a development version of the extension with +Please follow the instructions at [developing.md](../../../docs/developing.md), i.e. +create a Python environment with a recent version of `nodejs`, and install +a development version of Jupytext by running ```bash -jupyter labextension develop . --overwrite +pip install -e '.[dev]' ``` -Read more on this on the [JupyterLab documentation](https://jupyterlab.readthedocs.io/en/latest/extension/extension_dev.html#developing-a-prebuilt-extension). +at the root of the Jupytext repository. # How to publish a new version of the extension on npm diff --git a/make.bat b/make.bat deleted file mode 100644 index 08745c27c..000000000 --- a/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=. -set BUILDDIR=.build - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% - -:end -popd