Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Move JS directory inside reactpy to fix broken source distributions #1183

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

Closed
Closed
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
1 change: 1 addition & 0 deletions 1 docs/source/about/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Unreleased

- :pull:`1118` - `module_from_template` is broken with a recent release of `requests`
- :pull:`1131` - `module_from_template` did not work when using Flask backend
- :pull:`1183` - Fix broken source distributions due to missing JavaScript client source code

**Added**

Expand Down
6 changes: 3 additions & 3 deletions 6 docs/source/about/contributor-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ This repository is set up to be able to manage many applications and libraries w
in a variety of languages. All projects can be found under the ``src`` directory:

- ``src/py/{project}`` - Python packages
- ``src/js/app`` - ReactPy's built-in JS client
- ``src/js/packages/{project}`` - JS packages
- ``src/py/reactpy/js/app`` - ReactPy's built-in JS client
- ``src/py/reactpy/js/packages/{project}`` - JS packages

At the root of the repository is a ``pyproject.toml`` file that contains scripts and
their respective dependencies for managing all other projects. Most of these global
Expand Down Expand Up @@ -162,7 +162,7 @@ For Javascript, you'd do:

.. code-block:: bash

cd src/js/packages/event-to-object
cd src/py/reactpy/js/packages/event-to-object
npm run check:tests


Expand Down
18 changes: 18 additions & 0 deletions 18 src/py/reactpy/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
.coverage.*

# --- External gitignores ---
# For hatch, this is the only .gitignore that matters!
# Changes to another .gitignore may need to be reflected here
# if it is necessary to exclude them from the source distribution,
# such as build artifacts.
#
# When duplicating patterns, keep in mind that their meaning changes
# between .gitignore locations:
# https://git-scm.com/docs/gitignore#_pattern_format

# /.gitignore
node_modules

# /src/py/reactpy/js/.gitignore
js/**/tsconfig.tsbuildinfo
js/packages/**/package-lock.json
js/**/dist

# --- Build Artifacts ---
reactpy/_static
30 changes: 30 additions & 0 deletions 30 src/py/reactpy/hatch_build_sdist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Custom sdist build hook for reactpy.

As defined in pyproject.toml, this script should automatically be executed
when creating a source (.tar.gz) distribution.

See also: https://hatch.pypa.io/1.9/plugins/build-hook/custom/

"""
import shutil
from pathlib import Path
from typing import Any

from hatchling.builders.hooks.plugin.interface import BuildHookInterface


class CustomBuildHook(BuildHookInterface):
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
# https://github.com/pypa/hatch/issues/1197
# As a workaround, delete js/node_modules/ so hatchling does not
# mistakenly omit js/packages/ from the source distribution.
#
# If only the source distribution is built, i.e. by running one of:
# - `hatch build --target sdist`
# - `python -m build --sdist`
# then node_modules/ will be missing. Developers that later want to run
# `npm run build` will also need to reinstall with `npm ci`.
modules = Path(self.root) / "js" / "node_modules"
if modules.is_dir():
print("Removing", modules)
shutil.rmtree(modules)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 11 additions & 2 deletions 13 src/py/reactpy/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,17 @@ dependencies = [
types = "mypy --strict reactpy"
all = ["types"]

[[tool.hatch.build.hooks.build-scripts.scripts]]
work_dir = "../../js"
[tool.hatch.build.targets.sdist]
only-include = ["js", "reactpy"]

[tool.hatch.build.targets.wheel.force-include]
"reactpy/_static" = "reactpy/_static" # bypass .gitignore

[tool.hatch.build.targets.sdist.hooks.custom]
path = "hatch_build_sdist.py"

[[tool.hatch.build.targets.wheel.hooks.build-scripts.scripts]]
work_dir = "js"
out_dir = "reactpy/_static"
commands = [
"npm ci",
Expand Down
2 changes: 1 addition & 1 deletion 2 tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __call__(
ROOT = Path(__file__).parent
DOCS_DIR = ROOT / "docs"
SRC_DIR = ROOT / "src"
JS_DIR = SRC_DIR / "js"
JS_DIR = SRC_DIR / "py" / "reactpy" / "js"
PY_DIR = SRC_DIR / "py"
PY_PROJECTS = [p for p in PY_DIR.iterdir() if (p / "pyproject.toml").exists()]
TAG_PATTERN = re.compile(
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.