Skip to content

fix dev env var + add publish workflow #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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