Skip to content

Commit 90c25e0

Browse files
authored
Refactor repository structure (#1251)
- Refactor repo away from monorepo structure into something more standard/maintainable - Project dependencies have been simplified to [`python > 3.9`](https://www.python.org/downloads/), [`hatch`](https://hatch.pypa.io/latest/install/#pip), and [`bun`](https://bun.sh/). - All tool chain commands are now funneled through `hatch` with commands being [near identical to our other repos](https://reactive-python.github.io/reactpy-router/latest/about/contributing/). - Documentation commands have an optional dependency of [`docker`](https://www.docker.com/pricing/), which is primarily used for deployment. - Replace `react` usage with `preact/compat` within `@reactpy/client`. - This was previously being done via build-time name substitutions, but realistically ReactPy is the only user of `@reactpy/client`, so we may as well "clean up" the build path for ourselves. - Remove tests for `module_from_template` due to unfixable failures
1 parent e09d09c commit 90c25e0

File tree

151 files changed

+1741
-9978
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+1741
-9978
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ max_line_length = 120
1717
[*.md]
1818
indent_size = 4
1919

20+
[*.yml]
21+
indent_size = 4
22+
2023
[*.html]
2124
max_line_length = off
2225

.github/FUNDING.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# These are supported funding model platforms
22

3-
github: [rmorshea]
3+
github: [archmonger, rmorshea]
44
patreon: # Replace with a single Patreon username
55
open_collective: # Replace with a single Open Collective username
66
ko_fi: # Replace with a single Ko-fi username

.github/workflows/.hatch-run.yml

+12-19
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,17 @@ on:
66
job-name:
77
required: true
88
type: string
9-
hatch-run:
9+
run-cmd:
1010
required: true
1111
type: string
12-
runs-on-array:
12+
runs-on:
1313
required: false
1414
type: string
1515
default: '["ubuntu-latest"]'
16-
python-version-array:
16+
python-version:
1717
required: false
1818
type: string
1919
default: '["3.x"]'
20-
node-registry-url:
21-
required: false
22-
type: string
23-
default: ""
2420
secrets:
2521
node-auth-token:
2622
required: false
@@ -34,26 +30,23 @@ jobs:
3430
name: ${{ format(inputs.job-name, matrix.python-version, matrix.runs-on) }}
3531
strategy:
3632
matrix:
37-
python-version: ${{ fromJson(inputs.python-version-array) }}
38-
runs-on: ${{ fromJson(inputs.runs-on-array) }}
33+
python-version: ${{ fromJson(inputs.python-version) }}
34+
runs-on: ${{ fromJson(inputs.runs-on) }}
3935
runs-on: ${{ matrix.runs-on }}
4036
steps:
4137
- uses: actions/checkout@v4
42-
- uses: actions/setup-node@v4
38+
- uses: oven-sh/setup-bun@v2
4339
with:
44-
node-version: "23.x"
45-
registry-url: ${{ inputs.node-registry-url }}
46-
- name: Pin NPM Version
47-
run: npm install -g [email protected]
40+
bun-version: latest
4841
- name: Use Python ${{ matrix.python-version }}
4942
uses: actions/setup-python@v5
5043
with:
5144
python-version: ${{ matrix.python-version }}
5245
- name: Install Python Dependencies
53-
run: pip install hatch poetry
46+
run: pip install --upgrade pip hatch uv
5447
- name: Run Scripts
5548
env:
56-
NODE_AUTH_TOKEN: ${{ secrets.node-auth-token }}
57-
PYPI_USERNAME: ${{ secrets.pypi-username }}
58-
PYPI_PASSWORD: ${{ secrets.pypi-password }}
59-
run: hatch run ${{ inputs.hatch-run }}
49+
NPM_CONFIG_TOKEN: ${{ secrets.node-auth-token }}
50+
HATCH_INDEX_USER: ${{ secrets.pypi-username }}
51+
HATCH_INDEX_AUTH: ${{ secrets.pypi-password }}
52+
run: ${{ inputs.run-cmd }}

.github/workflows/check.yml

+15-17
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,36 @@ on:
1111
- cron: "0 0 * * 0"
1212

1313
jobs:
14-
test-py-cov:
14+
test-python-coverage:
1515
uses: ./.github/workflows/.hatch-run.yml
1616
with:
1717
job-name: "python-{0}"
18-
hatch-run: "test-py"
19-
lint-py:
18+
run-cmd: "hatch test --cover"
19+
lint-python:
2020
uses: ./.github/workflows/.hatch-run.yml
2121
with:
2222
job-name: "python-{0}"
23-
hatch-run: "lint-py"
24-
test-py-matrix:
23+
run-cmd: "hatch fmt src/reactpy --check && hatch run python:type_check"
24+
test-python:
2525
uses: ./.github/workflows/.hatch-run.yml
2626
with:
2727
job-name: "python-{0} {1}"
28-
hatch-run: "test-py --no-cov"
29-
runs-on-array: '["ubuntu-latest", "macos-latest", "windows-latest"]'
30-
python-version-array: '["3.9", "3.10", "3.11"]'
31-
test-docs:
28+
run-cmd: "hatch test"
29+
runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]'
30+
python-version: '["3.9", "3.10", "3.11"]'
31+
test-documentation:
3232
uses: ./.github/workflows/.hatch-run.yml
3333
with:
3434
job-name: "python-{0}"
35-
hatch-run: "test-docs"
36-
# as of Dec 2023 lxml does have wheels for 3.12
37-
# https://bugs.launchpad.net/lxml/+bug/2040440
38-
python-version-array: '["3.11"]'
39-
test-js:
35+
run-cmd: "hatch run docs:check"
36+
python-version: '["3.11"]'
37+
test-javascript:
4038
uses: ./.github/workflows/.hatch-run.yml
4139
with:
4240
job-name: "{1}"
43-
hatch-run: "test-js"
44-
lint-js:
41+
run-cmd: "hatch run javascript:test"
42+
lint-javascript:
4543
uses: ./.github/workflows/.hatch-run.yml
4644
with:
4745
job-name: "{1}"
48-
hatch-run: "lint-js"
46+
run-cmd: "hatch run javascript:check"

.github/workflows/deploy-docs.yml

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflows will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
41
name: deploy-docs
52

63
on:

.github/workflows/publish.yml

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
1-
# This workflows will upload a Javscript Package using NPM to npmjs.org when a release is created
2-
# For more information see: https://docs.github.com/en/actions/guides/publishing-nodejs-packages
3-
41
name: publish
52

63
on:
74
release:
85
types: [published]
96

107
jobs:
11-
publish:
8+
publish-reactpy:
9+
if: startsWith(github.event.release.name, 'reactpy ')
1210
uses: ./.github/workflows/.hatch-run.yml
1311
with:
14-
job-name: "publish"
15-
hatch-run: "publish"
16-
node-registry-url: "https://registry.npmjs.org"
12+
job-name: "Publish to PyPI"
13+
run-cmd: "hatch build --clean && hatch publish --yes"
1714
secrets:
18-
node-auth-token: ${{ secrets.NODE_AUTH_TOKEN }}
1915
pypi-username: ${{ secrets.PYPI_USERNAME }}
2016
pypi-password: ${{ secrets.PYPI_PASSWORD }}
17+
18+
publish-reactpy-client:
19+
if: startsWith(github.event.release.name, '@reactpy/client ')
20+
uses: ./.github/workflows/.hatch-run.yml
21+
with:
22+
job-name: "Publish to NPM"
23+
run-cmd: "hatch run javascript:publish_reactpy_client"
24+
secrets:
25+
node-auth-token: ${{ secrets.NODE_AUTH_TOKEN }}
26+
27+
publish-event-to-object:
28+
if: startsWith(github.event.release.name, 'event-to-object ')
29+
uses: ./.github/workflows/.hatch-run.yml
30+
with:
31+
job-name: "Publish to NPM"
32+
run-cmd: "hatch run javascript:publish_event_to_object"
33+
secrets:
34+
node-auth-token: ${{ secrets.NODE_AUTH_TOKEN }}

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# --- Build Artifacts ---
2+
src/reactpy/static/**/index.js*
3+
14
# --- Jupyter ---
25
*.ipynb_checkpoints
36
*Untitled*.ipynb
@@ -29,6 +32,7 @@ pip-wheel-metadata
2932
.python-version
3033

3134
# -- Python Tests ---
35+
.coverage.*
3236
*.coverage
3337
*.pytest_cache
3438
*.mypy_cache

.vscode/extensions.json

-12
This file was deleted.

LICENSE

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019 Ryan S. Morshead
3+
Copyright (c) Reactive Python and affiliates.
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
116

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
148

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

docs/Dockerfile

+13-17
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,38 @@
1-
FROM python:3.9
1+
FROM python:3.11
22
WORKDIR /app/
33

44
RUN apt-get update
55

6-
# Install NodeJS
7-
# --------------
8-
RUN curl -SLO https://deb.nodesource.com/nsolid_setup_deb.sh
9-
RUN chmod 500 nsolid_setup_deb.sh
10-
RUN ./nsolid_setup_deb.sh 20
11-
RUN apt-get install nodejs -y
12-
13-
# Install Poetry
14-
# --------------
15-
RUN pip install poetry
16-
176
# Create/Activate Python Venv
187
# ---------------------------
198
ENV VIRTUAL_ENV=/opt/venv
209
RUN python3 -m venv $VIRTUAL_ENV
2110
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
22-
RUN pip install --upgrade pip
11+
12+
# Install Python Build Dependencies
13+
# ---------------------------------
14+
RUN pip install --upgrade pip poetry hatch uv
15+
RUN curl -fsSL https://bun.sh/install | bash
16+
ENV PATH="/root/.bun/bin:$PATH"
2317

2418
# Copy Files
2519
# ----------
2620
COPY LICENSE ./
21+
COPY README.md ./
22+
COPY pyproject.toml ./
2723
COPY src ./src
2824
COPY docs ./docs
2925
COPY branding ./branding
3026

3127
# Install and Build Docs
3228
# ----------------------
33-
WORKDIR /app/docs
34-
RUN poetry install
29+
WORKDIR /app/docs/
30+
RUN poetry install -v
3531
RUN sphinx-build -v -W -b html source build
3632

3733
# Define Entrypoint
3834
# -----------------
39-
ENV PORT 5000
35+
ENV PORT=5000
4036
ENV REACTPY_DEBUG_MODE=1
4137
ENV REACTPY_CHECK_VDOM_SPEC=0
42-
CMD python main.py
38+
CMD ["python", "main.py"]

docs/README.md

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
11
# ReactPy's Documentation
22

3-
We provide two main ways to run the docs. Both use
4-
[`nox`](https://pypi.org/project/nox/):
5-
6-
- `nox -s docs` - displays the docs and rebuilds when files are modified.
7-
- `nox -s docs-in-docker` - builds a docker image and runs the docs from there.
8-
9-
If any changes to the core of the documentation are made (i.e. to non-`*.rst` files),
10-
then you should run a manual test of the documentation using the `docs_in_docker`
11-
session.
12-
13-
If you wish to build and run the docs by hand you need to perform two commands, each
14-
being run from the root of the repository:
15-
16-
- `sphinx-build -b html docs/source docs/build`
17-
- `python scripts/run_docs.py`
18-
19-
The first command constructs the static HTML and any Javascript. The latter actually
20-
runs the web server that serves the content.
3+
...

0 commit comments

Comments
 (0)