Skip to content
Open
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
12 changes: 12 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.11-bookworm

# Add Yarn GPG key and APT repo securely
RUN curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarn-archive-keyring.gpg > /dev/null

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
gnupg \
&& rm -rf /var/lib/apt/lists/*
32 changes: 32 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "ReactPy",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
// "remoteUser": "vscode",
// "containerEnv": {
// "BUN_INSTALL": "/home/vscode/.bun"
// },
"remoteEnv": {
"BUN_INSTALL": "/home/vscode/.bun",
"PATH": "/home/vscode/.local/share/reactpy-devcontainer/python/bin:/home/vscode/.bun/bin:${containerEnv:PATH}",
"PYTHONPATH": "/workspaces/reactpy/src:${containerEnv:PYTHONPATH}"
},
"postCreateCommand": "bash .devcontainer/post-create.sh",
"customizations": {
"vscode": {
"settings": {
"python.defaultInterpreterPath": "/home/vscode/.local/share/reactpy-devcontainer/python/bin/python",
"python.terminal.activateEnvironment": false
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
"ms-playwright.playwright",
"oven.bun-vscode"
]
}
}
}
68 changes: 68 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash

set -euo pipefail

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SYSTEM_PYTHON="$(command -v python3)"
USER_BASE_BIN="$("$SYSTEM_PYTHON" -m site --user-base)/bin"
export PATH="$USER_BASE_BIN:$PATH"

# Workaround for hatch/virtualenv incompatibility
"$SYSTEM_PYTHON" -m pip install --upgrade "virtualenv==20.25.1"

export BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"
export PATH="$BUN_INSTALL/bin:$PATH"
DEVCONTAINER_PYTHON_DIR="${HOME}/.local/share/reactpy-devcontainer/python"

if [[ -f /etc/apt/sources.list.d/yarn.list ]]; then
echo "Refreshing Yarn APT keyring..."
curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg \
| gpg --dearmor \
| sudo tee /usr/share/keyrings/yarn-archive-keyring.gpg >/dev/null
fi

if ! command -v hatch >/dev/null 2>&1; then
echo "Installing Hatch..."
"$SYSTEM_PYTHON" -m pip install --user hatch
fi

HATCH_CMD=("$SYSTEM_PYTHON" -m hatch)

echo "Creating Hatch devcontainer environment..."
"${HATCH_CMD[@]}" env create devcontainer
DEVCONTAINER_ENV_DIR="$("${HATCH_CMD[@]}" env find devcontainer)"
mkdir -p "$(dirname "$DEVCONTAINER_PYTHON_DIR")"
ln -sfn "$DEVCONTAINER_ENV_DIR" "$DEVCONTAINER_PYTHON_DIR"
export PATH="$DEVCONTAINER_PYTHON_DIR/bin:$PATH"
export PYTHONPATH="$REPO_ROOT/src${PYTHONPATH:+:$PYTHONPATH}"

echo "Installing Playwright browsers..."
"${HATCH_CMD[@]}" run devcontainer:install_playwright

if ! command -v bun >/dev/null 2>&1; then
echo "Installing Bun..."
curl -fsSL https://bun.sh/install | bash
fi

echo "Building JavaScript packages..."
"${HATCH_CMD[@]}" run javascript:build --dev

echo "Building Python package..."
"${HATCH_CMD[@]}" build --clean

echo "Running ReactPy smoke test..."
"$DEVCONTAINER_PYTHON_DIR/bin/python" - <<'PY'
from reactpy import component, html


@component
def test_component():
return html.div([
html.h1("Test"),
html.p("ReactPy is working"),
])


vdom = test_component()
print(type(vdom).__name__)
PY
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PYTHONPATH=./src
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Always reference these instructions first and fallback to search or bash command

**Prerequisites:**

- Install Python 3.9+ from https://www.python.org/downloads/
- Install Python 3.11+ from https://www.python.org/downloads/
- Install Hatch: `pip install hatch`
- Install Bun JavaScript runtime: `curl -fsSL https://bun.sh/install | bash && source ~/.bashrc`
- Install Git
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pip-wheel-metadata

# --- IDE ---
.idea
.vscode
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the .idea folder is intended to be private to a user, this is not the case for .vscode which is intended to be a workspace specific configuration.


# --- JS ---
node_modules
Expand Down
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "0.2.0",
"configurations": [

{
"name": "Python: Uvicorn main:app",
"type": "debugpy",
"request": "launch",
"module": "uvicorn",
"args": [
"main:app",
"--reload"
],
"jinja": true,
"justMyCode": false,
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "./src"
}
}
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
2 changes: 1 addition & 1 deletion docs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["rmorshea <ryan.morshead@gmail.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
python = "^3.11"
furo = "2022.04.07"
reactpy = { path = "..", extras = ["all"], develop = false }
sphinx = "*"
Expand Down
2 changes: 1 addition & 1 deletion docs/source/about/contributor-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Creating a development environment
If you plan to make code changes to this repository, you will need to install the following dependencies first:

- `Git <https://www.python.org/downloads/>`__
- `Python 3.9+ <https://www.python.org/downloads/>`__
- `Python 3.11+ <https://www.python.org/downloads/>`__
- `Hatch <https://hatch.pypa.io/latest/>`__
- `Bun <https://bun.sh/>`__
- `Docker <https://docs.docker.com/get-docker/>`__ (optional)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Below are some ways to update dictionaries without mutating them:

{**d, "key": value}

# Python >= 3.9
# Python >= 3.11
d | {"key": value}

# Equivalent to dict.setdefault()
Expand Down Expand Up @@ -192,7 +192,7 @@ Updating Dictionary Items

{**d, key: value}

# Python >= 3.9
# Python >= 3.11
d | {key: value}

# Equivalent to setdefault()
Expand Down
41 changes: 40 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ serve = [
################################

[tool.hatch.envs.python]
features = ["all"]
extra-dependencies = [
"reactpy[all]",
"pyright",
"types-toml",
"types-click",
Expand All @@ -176,6 +176,45 @@ extra-dependencies = [
[tool.hatch.envs.python.scripts]
type_check = ["pyright src/reactpy"]

[tool.hatch.envs.devcontainer]
skip-install = true
extra-dependencies = [
"fastjsonschema",
"requests",
"lxml",
"anyio",
"asgiref",
"asgi-tools",
"servestatic",
"orjson",
"jinja2-simple-tags",
"jinja2>=3",
"playwright",
"uvicorn[standard]",
"pyright",
"types-toml",
"types-click",
"types-requests",
"types-lxml",
"jsonpointer",
"pytest",
"pytest-sugar",
"pytest-asyncio",
"pytest-timeout",
"responses",
"exceptiongroup",
"starlette",
"typing-extensions",
"fastapi",
"flask",
"sanic",
"tornado",
]

[tool.hatch.envs.devcontainer.scripts]
install_playwright = ['python "src/build_scripts/install_playwright.py"']
type_check = ["pyright src/reactpy"]

############################
# >>> Hatch JS Scripts <<< #
############################
Expand Down
Loading
Loading