Skip to content

Commit

Permalink
Merge pull request #171 from ktaletsk/master
Browse files Browse the repository at this point in the history
Move to prebuilt extension system
  • Loading branch information
Steven Silvester committed Sep 15, 2021
2 parents e6b3c5f + aff8a02 commit 6123d51
Show file tree
Hide file tree
Showing 38 changed files with 1,673 additions and 1,474 deletions.
55 changes: 45 additions & 10 deletions .github/workflows/build.yml
Expand Up @@ -10,13 +10,48 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Install node
uses: actions/setup-node@v2.2.0
with:
node-version: '14.x'
- name: Run a one-line script
run: echo Hello, world!
- name: Install dependencies
run: python -m pip install -U jupyter_packaging~=0.10.4 jupyterlab~=3.0.16 pip wheel
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Install node
uses: actions/setup-node@v2.2.0
with:
node-version: '14.x'
- name: Install Python
uses: actions/setup-python@v2.2.2
with:
python-version: '3.8'
architecture: 'x64'


- name: Setup pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-3.8-${{ hashFiles('package.json') }}
restore-keys: |
pip-3.8-
pip-
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Setup yarn cache
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
- name: Install dependencies
run: python -m pip install -U jupyter_packaging~=0.10.4 jupyterlab~=3.0.16 pip wheel
- name: Install the extension
run: |
set -eux
python -m pip install .
- name: Integration test
run: |
jupyter serverextension list 2>&1 | grep -ie "jupyterlab_latex.*OK"
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/latex.*OK"
6 changes: 5 additions & 1 deletion .gitignore
@@ -1,8 +1,12 @@
.ipynb_checkpoints/
*.bundle.*
*.gz
*.pdf
dist/
jupyterlab_latex.egg-info/
jupyterlab_latex/__pycache__/
jupyterlab_latex/labextension/
lib/
test/build/*
node_modules/
npm-debug.log
test/build/*
6 changes: 4 additions & 2 deletions .prettierignore
@@ -1,2 +1,4 @@
node_modules
**/lib
**/lib/
dist/
jupyterlab_latex/labextension/
node_modules/
41 changes: 33 additions & 8 deletions README.md
@@ -1,6 +1,14 @@
# JupyterLab LaTeX

[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/jupyterlab/jupyterlab-latex/master?urlpath=lab%2Ftree%2Fsample.tex)
| build | stable | latest |
| :---------------: | :------------------------------: | :------------------------------: |
| [![ci-badge]][ci] | [![binder-badge]][binder-stable] | [![binder-badge]][binder-latest] |

[ci-badge]: https://github.com/jupyterlab/jupyterlab-latex/actions/workflows/build.yml/badge.svg
[ci]: https://github.com/jupyterlab/jupyterlab-latex/actions/workflows/build.yml?query=branch/master
[binder-badge]: https://mybinder.org/badge_logo.svg
[binder-stable]: https://mybinder.org/v2/gh/jupyterlab/jupyterlab-latex.git/3.0.0?urlpath=lab/tree/sample.tex
[binder-latest]: https://mybinder.org/v2/gh/jupyterlab/jupyterlab-latex.git/master?urlpath=lab/tree/sample.tex

An extension for JupyterLab which allows for live-editing of LaTeX documents.

Expand All @@ -17,7 +25,8 @@ For more advanced usage documentation, see [here](docs/advanced.md).

## Requirements

- JupyterLab 1.0
- JupyterLab >= 3.0
- older versions are supported in previous releases available on PyPI and npm, check [releases](https://github.com/jupyterlab/jupyterlab-latex/releases)
- Python >= 3.6
- An application that can compile `.tex` files to PDF (e.g., `pdflatex`, `xelatex`; use `pdflatex.exe` on Windows with MiKTeX). This application must be available as a command in the same environment as the notebook server.
- An application that can process `.bib` files for producing bibliographies. As with the LaTeX command, this must be available in the same environment as the notebook server.
Expand All @@ -26,24 +35,40 @@ For more advanced usage documentation, see [here](docs/advanced.md).

This extension includes both a notebook server extension (which interfaces with the LaTeX compiler)
and a lab extension (which provides the UI for the LaTeX preview).
In order to use it, you must enable both of them.
The Python package named `jupyterlab_latex` provides both of them as a prebuilt extension.

To install the server extension, run the following in your terminal:
To install the extension, run the following in your terminal:

```bash
pip install jupyterlab_latex
```

If you are running Notebook 5.2 or earlier, enable the server extension by running
### Check installation

To ensure that extension is properly installed, you could check server and lab extensions:

```bash
jupyter serverextension enable --sys-prefix jupyterlab_latex
jupyter server extension list
```

and see the block like this in the output

```
jupyterlab_latex enabled
- Validating jupyterlab_latex...
jupyterlab_latex 3.1.0 OK
```

To install the lab extension, run
then

```bash
jupyter labextension install @jupyterlab/latex
jupyter labextension list
```

and see the block like this in the output

```
@jupyterlab/latex v3.1.0 enabled OK (python, jupyterlab-latex)
```

## Customization
Expand Down
25 changes: 25 additions & 0 deletions RELEASE.md
@@ -0,0 +1,25 @@
# Making a new release of jupyterlab_latex

The extension can be published to `PyPI` and `npm` using the [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser).

## Automated releases with the Jupyter Releaser

The extension repository should already be compatible with the Jupyter Releaser.

Check out the [workflow documentation](https://github.com/jupyter-server/jupyter_releaser#typical-workflow) for more information.

Here is a summary of the steps to cut a new release:

- Fork the [`jupyter-releaser` repo](https://github.com/jupyter-server/jupyter_releaser)
- Add `ADMIN_GITHUB_TOKEN`, `PYPI_TOKEN` and `NPM_TOKEN` to the Github Secrets in the fork
- Go to the Actions panel
- Run the "Draft Changelog" workflow
- Merge the Changelog PR
- Run the "Draft Release" workflow
- Run the "Publish Release" workflow

## Publishing to `conda-forge`

If the package is not on conda forge yet, check the documentation to learn how to add it: https://conda-forge.org/docs/maintainer/adding_pkgs.html

Otherwise a bot should pick up the new version publish to PyPI, and open a new PR on the feedstock repository automatically.
5 changes: 2 additions & 3 deletions binder/postBuild 100755 → 100644
@@ -1,3 +1,2 @@
#!/bin/bash

jupyter labextension install @jupyterlab/latex@0.6.1
#!/usr/bin/env bash
python -m pip install .
7 changes: 4 additions & 3 deletions binder/requirements.txt
@@ -1,3 +1,4 @@
jupyterlab==0.35
jupyterlab_latex==0.4.1
notebook==6.1.5
jupyter_packaging ~=0.10,<2
jupyterlab ~=3.0
setuptools
nbgitpuller
22 changes: 16 additions & 6 deletions docs/advanced.md
Expand Up @@ -37,18 +37,28 @@ From the `jupyterlab-latex` directory, enter the following into your terminal:
pip install -e .
```

This installs the server extension.
Link your development version of the extension with JupyterLab

If you are running Notebook 5.2 or earlier, enable the server extension by running
```bash
jupyter labextension develop . --overwrite{% if cookiecutter.has_server_extension.lower().startswith('y') %}
```
Server extension must be manually installed in develop mode
```bash
jupyter serverextension enable --sys-prefix jupyterlab_latex
jupyter server extension enable {{ cookiecutter.python_name }}{% endif %}
```
Then, to install the lab extension, run
Rebuild extension Typescript source after making changes
```bash
jlpm install
jlpm run build
jupyter labextension install .
```
You can build a Python wheel for testing the distribution
```bash
python setup.py sdist bdist_wheel
```
The wheel and the source archive will be created in `dist/` directory.
19 changes: 19 additions & 0 deletions docs/changelog.md
@@ -1,5 +1,24 @@
# Changelog for `jupyterlab_latex`

- **3.1.0**:

- Switch to prebuilt (federated) extension model
- Fix bug with icons visibility in the dark theme

- **3.0.0**:

- Update to JupyterLab 3.0
- Add LaTeX file menu
- Add download PDF button

- **v2.0.0**:

- Update to JupyterLab 2.0

- **v1.0.0**:

- Update to JupyterLab 1.0

- **0.6.1**:

- Added a new page component allowing the user to navigate PDFs by page label.
Expand Down
5 changes: 5 additions & 0 deletions install.json
@@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "jupyterlab-latex",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab-latex"
}
7 changes: 7 additions & 0 deletions jupyter-config/server-config/jupyterlab_latex.json
@@ -0,0 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"jupyterlab_latex": true
}
}
}
34 changes: 28 additions & 6 deletions jupyterlab_latex/__init__.py
@@ -1,25 +1,45 @@
""" JupyterLab LaTex : live LaTeX editing for JupyterLab """
from ._version import __version__, __js__

from notebook.utils import url_path_join

from ._version import __version__
from .build import LatexBuildHandler
from .synctex import LatexSynctexHandler
__all__ = [
"__js__",
"__version__",
"_jupyter_labextension_paths",
"_jupyter_server_extension_paths",
"_jupyter_server_extension_points",
"_load_jupyter_server_extension",
"load_jupyter_server_extension",
]

path_regex = r'(?P<path>(?:(?:/[^/]+)+|/?))'

def _jupyter_server_extension_paths():


def _jupyter_labextension_paths():
return [{
"src": "labextension",
"dest": __js__["name"]
}]

def _jupyter_server_extension_points():
return [{
'module': 'jupyterlab_latex'
}]

_jupyter_server_extension_paths = _jupyter_server_extension_points

def load_jupyter_server_extension(nb_server_app):
"""
Called when the extension is loaded.
Args:
nb_server_app (NotebookApp): handle to the Notebook webserver instance.
"""
from notebook.utils import url_path_join

from .build import LatexBuildHandler
from .synctex import LatexSynctexHandler

web_app = nb_server_app.web_app
# Prepend the base_url so that it works in a jupyterhub setting
base_url = web_app.settings['base_url']
Expand All @@ -36,3 +56,5 @@ def load_jupyter_server_extension(nb_server_app):
{"notebook_dir": nb_server_app.notebook_dir}
)]
web_app.add_handlers('.*$', handlers)

_load_jupyter_server_extension = load_jupyter_server_extension
23 changes: 22 additions & 1 deletion jupyterlab_latex/_version.py
@@ -1 +1,22 @@
__version__ = '3.0.0'
import json
from pathlib import Path

__all__ = ["__version__", "__js__"]

def _fetchJS():
settings = Path(__file__).parent.resolve() / "labextension/package.json"

try:
with settings.open() as f:
return json.load(f)
except FileNotFoundError:
pass

raise FileNotFoundError(f"Could not find package.json at {settings!s}")


def _fetchVersion():
return _fetchJS()["version"]

__js__ = _fetchJS()
__version__ = _fetchVersion()

0 comments on commit 6123d51

Please sign in to comment.