Skip to content

Commit

Permalink
Refactor repository structure (#1251)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Archmonger authored Jan 21, 2025
1 parent e09d09c commit 90c25e0
Show file tree
Hide file tree
Showing 151 changed files with 1,741 additions and 9,978 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ max_line_length = 120
[*.md]
indent_size = 4

[*.yml]
indent_size = 4

[*.html]
max_line_length = off

Expand Down
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: [rmorshea]
github: [archmonger, rmorshea]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
Expand Down
31 changes: 12 additions & 19 deletions .github/workflows/.hatch-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@ on:
job-name:
required: true
type: string
hatch-run:
run-cmd:
required: true
type: string
runs-on-array:
runs-on:
required: false
type: string
default: '["ubuntu-latest"]'
python-version-array:
python-version:
required: false
type: string
default: '["3.x"]'
node-registry-url:
required: false
type: string
default: ""
secrets:
node-auth-token:
required: false
Expand All @@ -34,26 +30,23 @@ jobs:
name: ${{ format(inputs.job-name, matrix.python-version, matrix.runs-on) }}
strategy:
matrix:
python-version: ${{ fromJson(inputs.python-version-array) }}
runs-on: ${{ fromJson(inputs.runs-on-array) }}
python-version: ${{ fromJson(inputs.python-version) }}
runs-on: ${{ fromJson(inputs.runs-on) }}
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: oven-sh/setup-bun@v2
with:
node-version: "23.x"
registry-url: ${{ inputs.node-registry-url }}
- name: Pin NPM Version
run: npm install -g [email protected]
bun-version: latest
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: pip install hatch poetry
run: pip install --upgrade pip hatch uv
- name: Run Scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.node-auth-token }}
PYPI_USERNAME: ${{ secrets.pypi-username }}
PYPI_PASSWORD: ${{ secrets.pypi-password }}
run: hatch run ${{ inputs.hatch-run }}
NPM_CONFIG_TOKEN: ${{ secrets.node-auth-token }}
HATCH_INDEX_USER: ${{ secrets.pypi-username }}
HATCH_INDEX_AUTH: ${{ secrets.pypi-password }}
run: ${{ inputs.run-cmd }}
32 changes: 15 additions & 17 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,36 @@ on:
- cron: "0 0 * * 0"

jobs:
test-py-cov:
test-python-coverage:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0}"
hatch-run: "test-py"
lint-py:
run-cmd: "hatch test --cover"
lint-python:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0}"
hatch-run: "lint-py"
test-py-matrix:
run-cmd: "hatch fmt src/reactpy --check && hatch run python:type_check"
test-python:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0} {1}"
hatch-run: "test-py --no-cov"
runs-on-array: '["ubuntu-latest", "macos-latest", "windows-latest"]'
python-version-array: '["3.9", "3.10", "3.11"]'
test-docs:
run-cmd: "hatch test"
runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]'
python-version: '["3.9", "3.10", "3.11"]'
test-documentation:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "python-{0}"
hatch-run: "test-docs"
# as of Dec 2023 lxml does have wheels for 3.12
# https://bugs.launchpad.net/lxml/+bug/2040440
python-version-array: '["3.11"]'
test-js:
run-cmd: "hatch run docs:check"
python-version: '["3.11"]'
test-javascript:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "{1}"
hatch-run: "test-js"
lint-js:
run-cmd: "hatch run javascript:test"
lint-javascript:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "{1}"
hatch-run: "lint-js"
run-cmd: "hatch run javascript:check"
3 changes: 0 additions & 3 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: deploy-docs

on:
Expand Down
30 changes: 22 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
# 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:
publish-reactpy:
if: startsWith(github.event.release.name, 'reactpy ')
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "publish"
hatch-run: "publish"
node-registry-url: "https://registry.npmjs.org"
job-name: "Publish to PyPI"
run-cmd: "hatch build --clean && hatch publish --yes"
secrets:
node-auth-token: ${{ secrets.NODE_AUTH_TOKEN }}
pypi-username: ${{ secrets.PYPI_USERNAME }}
pypi-password: ${{ secrets.PYPI_PASSWORD }}

publish-reactpy-client:
if: startsWith(github.event.release.name, '@reactpy/client ')
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "Publish to NPM"
run-cmd: "hatch run javascript:publish_reactpy_client"
secrets:
node-auth-token: ${{ secrets.NODE_AUTH_TOKEN }}

publish-event-to-object:
if: startsWith(github.event.release.name, 'event-to-object ')
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "Publish to NPM"
run-cmd: "hatch run javascript:publish_event_to_object"
secrets:
node-auth-token: ${{ secrets.NODE_AUTH_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# --- Build Artifacts ---
src/reactpy/static/**/index.js*

# --- Jupyter ---
*.ipynb_checkpoints
*Untitled*.ipynb
Expand Down Expand Up @@ -29,6 +32,7 @@ pip-wheel-metadata
.python-version

# -- Python Tests ---
.coverage.*
*.coverage
*.pytest_cache
*.mypy_cache
Expand Down
12 changes: 0 additions & 12 deletions .vscode/extensions.json

This file was deleted.

20 changes: 4 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
The MIT License (MIT)

Copyright (c) 2019 Ryan S. Morshead
Copyright (c) Reactive Python and affiliates.

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:
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:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.
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.
30 changes: 13 additions & 17 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
FROM python:3.9
FROM python:3.11
WORKDIR /app/

RUN apt-get update

# Install NodeJS
# --------------
RUN curl -SLO https://deb.nodesource.com/nsolid_setup_deb.sh
RUN chmod 500 nsolid_setup_deb.sh
RUN ./nsolid_setup_deb.sh 20
RUN apt-get install nodejs -y

# Install Poetry
# --------------
RUN pip install poetry

# Create/Activate Python Venv
# ---------------------------
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install --upgrade pip

# Install Python Build Dependencies
# ---------------------------------
RUN pip install --upgrade pip poetry hatch uv
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:$PATH"

# Copy Files
# ----------
COPY LICENSE ./
COPY README.md ./
COPY pyproject.toml ./
COPY src ./src
COPY docs ./docs
COPY branding ./branding

# Install and Build Docs
# ----------------------
WORKDIR /app/docs
RUN poetry install
WORKDIR /app/docs/
RUN poetry install -v
RUN sphinx-build -v -W -b html source build

# Define Entrypoint
# -----------------
ENV PORT 5000
ENV PORT=5000
ENV REACTPY_DEBUG_MODE=1
ENV REACTPY_CHECK_VDOM_SPEC=0
CMD python main.py
CMD ["python", "main.py"]
19 changes: 1 addition & 18 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
# ReactPy's Documentation

We provide two main ways to run the docs. Both use
[`nox`](https://pypi.org/project/nox/):

- `nox -s docs` - displays the docs and rebuilds when files are modified.
- `nox -s docs-in-docker` - builds a docker image and runs the docs from there.

If any changes to the core of the documentation are made (i.e. to non-`*.rst` files),
then you should run a manual test of the documentation using the `docs_in_docker`
session.

If you wish to build and run the docs by hand you need to perform two commands, each
being run from the root of the repository:

- `sphinx-build -b html docs/source docs/build`
- `python scripts/run_docs.py`

The first command constructs the static HTML and any Javascript. The latter actually
runs the web server that serves the content.
...
Loading

0 comments on commit 90c25e0

Please sign in to comment.