Skip to content

Commit 362f0c8

Browse files
wip changes
1 parent 885030f commit 362f0c8

File tree

5 files changed

+1428
-20
lines changed

5 files changed

+1428
-20
lines changed

.devcontainer/devcontainer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
// "containerEnv": {
99
// "BUN_INSTALL": "/home/vscode/.bun"
1010
// },
11-
// "remoteEnv": {
12-
// "BUN_INSTALL": "/home/vscode/.bun",
13-
// "PATH": "/home/vscode/.bun/bin:${containerEnv:PATH}"
14-
// },
11+
"remoteEnv": {
12+
"BUN_INSTALL": "/home/vscode/.bun",
13+
"PATH": "/home/vscode/.local/share/reactpy-devcontainer/python/bin:/home/vscode/.bun/bin:${containerEnv:PATH}",
14+
"PYTHONPATH": "/workspaces/reactpy/src:${containerEnv:PYTHONPATH}"
15+
},
1516
"postCreateCommand": "bash .devcontainer/post-create.sh",
1617
"customizations": {
1718
"vscode": {
1819
"settings": {
19-
"python.defaultInterpreterPath": "/usr/local/bin/python",
20+
"python.defaultInterpreterPath": "/home/vscode/.local/share/reactpy-devcontainer/python/bin/python",
2021
"python.terminal.activateEnvironment": false
2122
},
2223
"extensions": [

.devcontainer/post-create.sh

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22

33
set -euo pipefail
44

5-
# Workaround for hatch/virtualenv incompatibility
6-
python3 -m pip install --upgrade "virtualenv==20.25.1"
7-
8-
# Install core ReactPy dependencies
9-
pip install fastjsonschema requests lxml anyio typing-extensions
10-
11-
# Install ASGI dependencies for server functionality
12-
pip install orjson asgiref asgi-tools servestatic uvicorn fastapi
5+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6+
SYSTEM_PYTHON="$(command -v python3)"
7+
USER_BASE_BIN="$("$SYSTEM_PYTHON" -m site --user-base)/bin"
8+
export PATH="$USER_BASE_BIN:$PATH"
139

14-
# Optional: Install additional servers
15-
pip install flask sanic tornado
10+
# Workaround for hatch/virtualenv incompatibility
11+
"$SYSTEM_PYTHON" -m pip install --upgrade "virtualenv==20.25.1"
1612

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

2017
if [[ -f /etc/apt/sources.list.d/yarn.list ]]; then
2118
echo "Refreshing Yarn APT keyring..."
@@ -26,22 +23,32 @@ fi
2623

2724
if ! command -v hatch >/dev/null 2>&1; then
2825
echo "Installing Hatch..."
29-
python3 -m pip install --user hatch
26+
"$SYSTEM_PYTHON" -m pip install --user hatch
3027
fi
3128

29+
HATCH_CMD=("$SYSTEM_PYTHON" -m hatch)
30+
31+
echo "Creating Hatch devcontainer environment..."
32+
"${HATCH_CMD[@]}" env create devcontainer
33+
DEVCONTAINER_ENV_DIR="$("${HATCH_CMD[@]}" env find devcontainer)"
34+
mkdir -p "$(dirname "$DEVCONTAINER_PYTHON_DIR")"
35+
ln -sfn "$DEVCONTAINER_ENV_DIR" "$DEVCONTAINER_PYTHON_DIR"
36+
export PATH="$DEVCONTAINER_PYTHON_DIR/bin:$PATH"
37+
export PYTHONPATH="$REPO_ROOT/src${PYTHONPATH:+:$PYTHONPATH}"
38+
3239
if ! command -v bun >/dev/null 2>&1; then
3340
echo "Installing Bun..."
3441
curl -fsSL https://bun.sh/install | bash
3542
fi
3643

3744
echo "Building JavaScript packages..."
38-
hatch run javascript:build --dev
45+
"${HATCH_CMD[@]}" run javascript:build --dev
3946

4047
echo "Building Python package..."
41-
hatch build --clean
48+
"${HATCH_CMD[@]}" build --clean
4249

4350
echo "Running ReactPy smoke test..."
44-
hatch run python - <<'PY'
51+
"$DEVCONTAINER_PYTHON_DIR/bin/python" - <<'PY'
4552
from reactpy import component, html
4653
4754

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PYTHONPATH=./src

pyproject.toml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ serve = [
162162
################################
163163

164164
[tool.hatch.envs.python]
165+
features = ["all"]
165166
extra-dependencies = [
166-
"reactpy[all]",
167167
"pyright",
168168
"types-toml",
169169
"types-click",
@@ -176,6 +176,44 @@ extra-dependencies = [
176176
[tool.hatch.envs.python.scripts]
177177
type_check = ["pyright src/reactpy"]
178178

179+
[tool.hatch.envs.devcontainer]
180+
skip-install = true
181+
extra-dependencies = [
182+
"fastjsonschema",
183+
"requests",
184+
"lxml",
185+
"anyio",
186+
"asgiref",
187+
"asgi-tools",
188+
"servestatic",
189+
"orjson",
190+
"jinja2-simple-tags",
191+
"jinja2>=3",
192+
"playwright",
193+
"uvicorn[standard]",
194+
"pyright",
195+
"types-toml",
196+
"types-click",
197+
"types-requests",
198+
"types-lxml",
199+
"jsonpointer",
200+
"pytest",
201+
"pytest-sugar",
202+
"pytest-asyncio",
203+
"pytest-timeout",
204+
"responses",
205+
"exceptiongroup",
206+
"starlette",
207+
"typing-extensions",
208+
"fastapi",
209+
"flask",
210+
"sanic",
211+
"tornado",
212+
]
213+
214+
[tool.hatch.envs.devcontainer.scripts]
215+
type_check = ["pyright src/reactpy"]
216+
179217
############################
180218
# >>> Hatch JS Scripts <<< #
181219
############################

0 commit comments

Comments
 (0)