Skip to content

Commit

Permalink
fix dev env var + add publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorshea committed Apr 15, 2023
1 parent fe25c44 commit 7ee9118
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/publish.yml
@@ -0,0 +1,25 @@
# This workflows will upload a Javscript Package using NPM to npmjs.org when a release is created
# For more information see: https://docs.github.com/en/actions/guides/publishing-nodejs-packages

name: publish

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: actions/setup-python@v2
with:
python-version: "3.x"
- run: pip install noxopt
- run: nox -s publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
17 changes: 8 additions & 9 deletions README.md
Expand Up @@ -91,16 +91,15 @@ For a development installation (requires [Node.js](https://nodejs.org) and [Yarn
$ git clone https://github.com/reactive-python/reactpy-jupyter.git
$ cd reactpy-jupyter
$ pip install -e .
$ jupyter nbextension install --py --symlink --overwrite --sys-prefix reactpy_jupyter
$ jupyter nbextension enable --py --sys-prefix reactpy_jupyter

When actively developing your extension for JupyterLab, run the command:
To automatically re-build and refresh Jupyter when making changes start a Vite dev server:

$ jupyter labextension develop --overwrite reactpy_jupyter
$ npx vite

Then you need to rebuild the JS when you make a code change:
Then, before importing `reactpy_jupyter` set the following environment variable:

$ cd js
$ yarn run build

You then need to refresh the JupyterLab page when your javascript changes.
```python
import os
os.environ["REACTPY_JUPYTER_DEV"] = "1"
import reactpy_jupyter
```
7 changes: 7 additions & 0 deletions noxfile.py
Expand Up @@ -20,3 +20,10 @@ def check_python(session: Session) -> None:
def check_javascript(session: Session) -> None:
session.run("npm", "ci", external=True)
session.run("npm", "run", "lint", external=True)


@group.session
def publish(session: Session) -> None:
session.install("twine", "build", "wheel")
session.run("python", "-m", "build", "--sdist", "--wheel", "--outdir", "dist/")
session.run("twine", "upload", "dist/*")
2 changes: 1 addition & 1 deletion reactpy_jupyter/__init__.py
Expand Up @@ -9,7 +9,7 @@
from .ipython_extension import load_ipython_extension, unload_ipython_extension
from .widget import LayoutWidget, run, set_import_source_base_url, widgetize

__version__ = "0.8.0" # DO NOT MODIFY
__version__ = "0.8.1" # DO NOT MODIFY

__all__ = [
"LayoutWidget",
Expand Down
6 changes: 4 additions & 2 deletions reactpy_jupyter/widget.py
@@ -1,6 +1,7 @@
from __future__ import annotations

import asyncio
import os
from functools import wraps
from pathlib import Path
from queue import Queue as SyncQueue
Expand All @@ -11,13 +12,14 @@
from IPython.display import DisplayHandle
from IPython.display import display as ipython_display
from jsonpointer import set_pointer
from reactpy.config import REACTPY_DEBUG_MODE
from reactpy.core.layout import Layout
from reactpy.core.types import ComponentType
from traitlets import Unicode
from typing_extensions import ParamSpec

if REACTPY_DEBUG_MODE.current:
DEV = bool(int(os.environ.get("REACTPY_JUPYTER_DEV", "0")))

if DEV:
# from `npx vite`
ESM = "http://localhost:5173/src/index.js?anywidget"
else:
Expand Down

0 comments on commit 7ee9118

Please sign in to comment.