reactpy_django 3.8.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. reactpy_django-3.8.1/LICENSE.md +9 -0
  2. reactpy_django-3.8.1/MANIFEST.in +3 -0
  3. reactpy_django-3.8.1/PKG-INFO +152 -0
  4. reactpy_django-3.8.1/README.md +116 -0
  5. reactpy_django-3.8.1/pyproject.toml +21 -0
  6. reactpy_django-3.8.1/setup.cfg +7 -0
  7. reactpy_django-3.8.1/setup.py +141 -0
  8. reactpy_django-3.8.1/src/reactpy_django/__init__.py +28 -0
  9. reactpy_django-3.8.1/src/reactpy_django/apps.py +11 -0
  10. reactpy_django-3.8.1/src/reactpy_django/checks.py +542 -0
  11. reactpy_django-3.8.1/src/reactpy_django/clean.py +141 -0
  12. reactpy_django-3.8.1/src/reactpy_django/components.py +286 -0
  13. reactpy_django-3.8.1/src/reactpy_django/config.py +135 -0
  14. reactpy_django-3.8.1/src/reactpy_django/database.py +31 -0
  15. reactpy_django-3.8.1/src/reactpy_django/decorators.py +101 -0
  16. reactpy_django-3.8.1/src/reactpy_django/exceptions.py +34 -0
  17. reactpy_django-3.8.1/src/reactpy_django/hooks.py +496 -0
  18. reactpy_django-3.8.1/src/reactpy_django/http/__init__.py +0 -0
  19. reactpy_django-3.8.1/src/reactpy_django/http/urls.py +18 -0
  20. reactpy_django-3.8.1/src/reactpy_django/http/views.py +62 -0
  21. reactpy_django-3.8.1/src/reactpy_django/management/__init__.py +0 -0
  22. reactpy_django-3.8.1/src/reactpy_django/management/commands/__init__.py +0 -0
  23. reactpy_django-3.8.1/src/reactpy_django/management/commands/clean_reactpy.py +37 -0
  24. reactpy_django-3.8.1/src/reactpy_django/migrations/0001_initial.py +25 -0
  25. reactpy_django-3.8.1/src/reactpy_django/migrations/0002_rename_created_at_componentparams_last_accessed.py +17 -0
  26. reactpy_django-3.8.1/src/reactpy_django/migrations/0003_componentsession_delete_componentparams.py +28 -0
  27. reactpy_django-3.8.1/src/reactpy_django/migrations/0004_config.py +27 -0
  28. reactpy_django-3.8.1/src/reactpy_django/migrations/0005_alter_componentsession_last_accessed.py +17 -0
  29. reactpy_django-3.8.1/src/reactpy_django/migrations/0006_userdatamodel.py +28 -0
  30. reactpy_django-3.8.1/src/reactpy_django/migrations/__init__.py +0 -0
  31. reactpy_django-3.8.1/src/reactpy_django/models.py +48 -0
  32. reactpy_django-3.8.1/src/reactpy_django/py.typed +1 -0
  33. reactpy_django-3.8.1/src/reactpy_django/router/__init__.py +5 -0
  34. reactpy_django-3.8.1/src/reactpy_django/router/converters.py +7 -0
  35. reactpy_django-3.8.1/src/reactpy_django/router/resolvers.py +58 -0
  36. reactpy_django-3.8.1/src/reactpy_django/static/reactpy_django/client.js +1630 -0
  37. reactpy_django-3.8.1/src/reactpy_django/templates/reactpy/component.html +27 -0
  38. reactpy_django-3.8.1/src/reactpy_django/templatetags/__init__.py +0 -0
  39. reactpy_django-3.8.1/src/reactpy_django/templatetags/reactpy.py +221 -0
  40. reactpy_django-3.8.1/src/reactpy_django/types.py +121 -0
  41. reactpy_django-3.8.1/src/reactpy_django/utils.py +384 -0
  42. reactpy_django-3.8.1/src/reactpy_django/websocket/__init__.py +0 -0
  43. reactpy_django-3.8.1/src/reactpy_django/websocket/consumer.py +218 -0
  44. reactpy_django-3.8.1/src/reactpy_django/websocket/paths.py +17 -0
  45. reactpy_django-3.8.1/src/reactpy_django.egg-info/PKG-INFO +152 -0
  46. reactpy_django-3.8.1/src/reactpy_django.egg-info/SOURCES.txt +49 -0
  47. reactpy_django-3.8.1/src/reactpy_django.egg-info/dependency_links.txt +1 -0
  48. reactpy_django-3.8.1/src/reactpy_django.egg-info/not-zip-safe +1 -0
  49. reactpy_django-3.8.1/src/reactpy_django.egg-info/requires.txt +9 -0
  50. reactpy_django-3.8.1/src/reactpy_django.egg-info/top_level.txt +2 -0
@@ -0,0 +1,9 @@
1
+ ## The MIT License (MIT)
2
+
3
+ #### Copyright (c) Reactive Python and affiliates.
4
+
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:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
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.
@@ -0,0 +1,3 @@
1
+ include src/reactpy_django/py.typed
2
+ recursive-include src/reactpy_django/static *
3
+ recursive-include src/reactpy_django/templates *.html
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.1
2
+ Name: reactpy_django
3
+ Version: 3.8.1
4
+ Summary: It's React, but in Python. Now with Django integration.
5
+ Home-page: https://github.com/reactive-python/reactpy-django
6
+ Author: Mark Bakhit
7
+ Author-email: archiethemonger@gmail.com
8
+ License: MIT
9
+ Keywords: interactive,reactive,widgets,DOM,React,ReactJS,ReactPy
10
+ Platform: Linux
11
+ Platform: Mac OS X
12
+ Platform: Windows
13
+ Classifier: Framework :: Django
14
+ Classifier: Framework :: Django :: 4.0
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Intended Audience :: Developers
21
+ Classifier: Intended Audience :: Science/Research
22
+ Classifier: Topic :: Multimedia :: Graphics
23
+ Classifier: Environment :: Web Environment
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE.md
27
+ Requires-Dist: channels>=4.0.0
28
+ Requires-Dist: django>=4.2.0
29
+ Requires-Dist: reactpy<1.1.0,>=1.0.2
30
+ Requires-Dist: reactpy-router<1.0.0,>=0.1.1
31
+ Requires-Dist: aiofile>=3.0
32
+ Requires-Dist: dill>=0.3.5
33
+ Requires-Dist: orjson>=3.6.0
34
+ Requires-Dist: nest_asyncio>=1.5.0
35
+ Requires-Dist: typing_extensions
36
+
37
+ # <img src="https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg" align="left" height="45"/> ReactPy Django
38
+
39
+ <p>
40
+ <a href="https://github.com/reactive-python/reactpy-django/actions?query=workflow%3ATest">
41
+ <img src="https://github.com/reactive-python/reactpy-django/workflows/Test/badge.svg?event=push">
42
+ </a>
43
+ <a href="https://pypi.python.org/pypi/reactpy-django">
44
+ <img src="https://img.shields.io/pypi/v/reactpy-django.svg?label=PyPI">
45
+ </a>
46
+ <a href="https://github.com/reactive-python/reactpy-django/blob/main/LICENSE.md">
47
+ <img src="https://img.shields.io/badge/License-MIT-purple.svg">
48
+ </a>
49
+ <a href="https://reactive-python.github.io/reactpy-django/">
50
+ <img src="https://img.shields.io/website?down_message=offline&label=Docs&logo=read%20the%20docs&logoColor=white&up_message=online&url=https%3A%2F%2Freactive-python.github.io%2Freactpy-django%2F">
51
+ </a>
52
+ <a href="https://discord.gg/uNb5P4hA9X">
53
+ <img src="https://img.shields.io/discord/1111078259854168116?label=Discord&logo=discord">
54
+ </a>
55
+ </p>
56
+
57
+ [ReactPy-Django](https://github.com/reactive-python/reactpy-django) is used to add [ReactPy](https://reactpy.dev/) support to an existing **Django project**. This package also turbocharges ReactPy with features such as...
58
+
59
+ - [SEO compatible rendering](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#reactpy_prerender)
60
+ - [Single page application (SPA) capabilities](https://reactive-python.github.io/reactpy-django/latest/reference/router/#django-router)
61
+ - [Distributed computing](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#reactpy_default_hosts)
62
+ - [Performance enhancements](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#performance-settings)
63
+ - [Customizable reconnection behavior](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#stability-settings)
64
+ - [Customizable disconnection behavior](https://reactive-python.github.io/reactpy-django/latest/reference/template-tag)
65
+ - [Multiple root components](https://reactive-python.github.io/reactpy-django/latest/reference/template-tag/)
66
+ - [Cross-process communication/signaling (Channel Layers)](https://reactive-python.github.io/reactpy-django/latest/reference/hooks/#use-channel-layer)
67
+ - [Django view to ReactPy component conversion](https://reactive-python.github.io/reactpy-django/latest/reference/components/#view-to-component)
68
+ - [Django static file access](https://reactive-python.github.io/reactpy-django/latest/reference/components/#django-css)
69
+ - [Django database access](https://reactive-python.github.io/reactpy-django/latest/reference/hooks/#use-query)
70
+
71
+ ## What is ReactPy?
72
+
73
+ [ReactPy](https://reactpy.dev/) is a library for building user interfaces in Python without Javascript. ReactPy interfaces are made from components that look and behave similar to those found in [ReactJS](https://reactjs.org/). Designed with simplicity in mind, ReactPy can be used by those without web development experience while also being powerful enough to grow with your ambitions.
74
+
75
+ <table align="center">
76
+ <thead>
77
+ <tr>
78
+ <th colspan="2" style="text-align: center">Supported Backends</th>
79
+ <tr>
80
+ <th style="text-align: center">Built-in</th>
81
+ <th style="text-align: center">External</th>
82
+ </tr>
83
+ </thead>
84
+ <tbody>
85
+ <tr>
86
+ <td>
87
+ <a href="https://reactpy.dev/docs/guides/getting-started/installing-reactpy.html#officially-supported-servers">
88
+ Flask, FastAPI, Sanic, Tornado
89
+ </a>
90
+ </td>
91
+ <td>
92
+ <a href="https://github.com/reactive-python/reactpy-django">Django</a>,
93
+ <a href="https://github.com/reactive-python/reactpy-jupyter">Jupyter</a>,
94
+ <a href="https://github.com/idom-team/idom-dash">Plotly-Dash</a>
95
+ </td>
96
+ </tr>
97
+ </tbody>
98
+ </table>
99
+
100
+ # At a Glance
101
+
102
+ ## `my_app/components.py`
103
+
104
+ <!--py-header-start-->
105
+
106
+ You will need a file to define your [ReactPy](https://github.com/reactive-python/reactpy) components. We recommend creating a `components.py` file within your chosen **Django app** to start out. Within this file, we will create a simple `hello_world` component.
107
+
108
+ <!--py-header-end-->
109
+ <!--py-code-start-->
110
+
111
+ ```python
112
+ from reactpy import component, html
113
+
114
+ @component
115
+ def hello_world(recipient: str):
116
+ return html.h1(f"Hello {recipient}!")
117
+ ```
118
+
119
+ <!--py-code-end-->
120
+
121
+ ## [`my_app/templates/my-template.html`](https://docs.djangoproject.com/en/dev/topics/templates/)
122
+
123
+ <!--html-header-start-->
124
+
125
+ In your **Django app**'s HTML template, you can now embed your ReactPy component using the `component` template tag. Within this tag, you will need to type in the dotted path to the component.
126
+
127
+ Additionally, you can pass in `args` and `kwargs` into your component function. After reading the code below, pay attention to how the function definition for `hello_world` (_from the previous example_) accepts a `recipient` argument.
128
+
129
+ <!--html-code-start-->
130
+
131
+ ```jinja
132
+ {% load reactpy %}
133
+ <!DOCTYPE html>
134
+ <html>
135
+ <body>
136
+ {% component "example_project.my_app.components.hello_world" recipient="World" %}
137
+ </body>
138
+ </html>
139
+ ```
140
+
141
+ <!--html-code-end-->
142
+
143
+ # Resources
144
+
145
+ Follow the links below to find out more about this project.
146
+
147
+ - [Try ReactPy (Jupyter Notebook)](https://mybinder.org/v2/gh/reactive-python/reactpy-jupyter/main?urlpath=lab/tree/notebooks/introduction.ipynb)
148
+ - [Documentation](https://reactive-python.github.io/reactpy-django)
149
+ - [GitHub Discussions](https://github.com/reactive-python/reactpy-django/discussions)
150
+ - [Discord](https://discord.gg/uNb5P4hA9X)
151
+ - [Contributor Guide](https://reactive-python.github.io/reactpy-django/latest/about/code/)
152
+ - [Code of Conduct](https://github.com/reactive-python/reactpy-django/blob/main/CODE_OF_CONDUCT.md)
@@ -0,0 +1,116 @@
1
+ # <img src="https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg" align="left" height="45"/> ReactPy Django
2
+
3
+ <p>
4
+ <a href="https://github.com/reactive-python/reactpy-django/actions?query=workflow%3ATest">
5
+ <img src="https://github.com/reactive-python/reactpy-django/workflows/Test/badge.svg?event=push">
6
+ </a>
7
+ <a href="https://pypi.python.org/pypi/reactpy-django">
8
+ <img src="https://img.shields.io/pypi/v/reactpy-django.svg?label=PyPI">
9
+ </a>
10
+ <a href="https://github.com/reactive-python/reactpy-django/blob/main/LICENSE.md">
11
+ <img src="https://img.shields.io/badge/License-MIT-purple.svg">
12
+ </a>
13
+ <a href="https://reactive-python.github.io/reactpy-django/">
14
+ <img src="https://img.shields.io/website?down_message=offline&label=Docs&logo=read%20the%20docs&logoColor=white&up_message=online&url=https%3A%2F%2Freactive-python.github.io%2Freactpy-django%2F">
15
+ </a>
16
+ <a href="https://discord.gg/uNb5P4hA9X">
17
+ <img src="https://img.shields.io/discord/1111078259854168116?label=Discord&logo=discord">
18
+ </a>
19
+ </p>
20
+
21
+ [ReactPy-Django](https://github.com/reactive-python/reactpy-django) is used to add [ReactPy](https://reactpy.dev/) support to an existing **Django project**. This package also turbocharges ReactPy with features such as...
22
+
23
+ - [SEO compatible rendering](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#reactpy_prerender)
24
+ - [Single page application (SPA) capabilities](https://reactive-python.github.io/reactpy-django/latest/reference/router/#django-router)
25
+ - [Distributed computing](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#reactpy_default_hosts)
26
+ - [Performance enhancements](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#performance-settings)
27
+ - [Customizable reconnection behavior](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#stability-settings)
28
+ - [Customizable disconnection behavior](https://reactive-python.github.io/reactpy-django/latest/reference/template-tag)
29
+ - [Multiple root components](https://reactive-python.github.io/reactpy-django/latest/reference/template-tag/)
30
+ - [Cross-process communication/signaling (Channel Layers)](https://reactive-python.github.io/reactpy-django/latest/reference/hooks/#use-channel-layer)
31
+ - [Django view to ReactPy component conversion](https://reactive-python.github.io/reactpy-django/latest/reference/components/#view-to-component)
32
+ - [Django static file access](https://reactive-python.github.io/reactpy-django/latest/reference/components/#django-css)
33
+ - [Django database access](https://reactive-python.github.io/reactpy-django/latest/reference/hooks/#use-query)
34
+
35
+ ## What is ReactPy?
36
+
37
+ [ReactPy](https://reactpy.dev/) is a library for building user interfaces in Python without Javascript. ReactPy interfaces are made from components that look and behave similar to those found in [ReactJS](https://reactjs.org/). Designed with simplicity in mind, ReactPy can be used by those without web development experience while also being powerful enough to grow with your ambitions.
38
+
39
+ <table align="center">
40
+ <thead>
41
+ <tr>
42
+ <th colspan="2" style="text-align: center">Supported Backends</th>
43
+ <tr>
44
+ <th style="text-align: center">Built-in</th>
45
+ <th style="text-align: center">External</th>
46
+ </tr>
47
+ </thead>
48
+ <tbody>
49
+ <tr>
50
+ <td>
51
+ <a href="https://reactpy.dev/docs/guides/getting-started/installing-reactpy.html#officially-supported-servers">
52
+ Flask, FastAPI, Sanic, Tornado
53
+ </a>
54
+ </td>
55
+ <td>
56
+ <a href="https://github.com/reactive-python/reactpy-django">Django</a>,
57
+ <a href="https://github.com/reactive-python/reactpy-jupyter">Jupyter</a>,
58
+ <a href="https://github.com/idom-team/idom-dash">Plotly-Dash</a>
59
+ </td>
60
+ </tr>
61
+ </tbody>
62
+ </table>
63
+
64
+ # At a Glance
65
+
66
+ ## `my_app/components.py`
67
+
68
+ <!--py-header-start-->
69
+
70
+ You will need a file to define your [ReactPy](https://github.com/reactive-python/reactpy) components. We recommend creating a `components.py` file within your chosen **Django app** to start out. Within this file, we will create a simple `hello_world` component.
71
+
72
+ <!--py-header-end-->
73
+ <!--py-code-start-->
74
+
75
+ ```python
76
+ from reactpy import component, html
77
+
78
+ @component
79
+ def hello_world(recipient: str):
80
+ return html.h1(f"Hello {recipient}!")
81
+ ```
82
+
83
+ <!--py-code-end-->
84
+
85
+ ## [`my_app/templates/my-template.html`](https://docs.djangoproject.com/en/dev/topics/templates/)
86
+
87
+ <!--html-header-start-->
88
+
89
+ In your **Django app**'s HTML template, you can now embed your ReactPy component using the `component` template tag. Within this tag, you will need to type in the dotted path to the component.
90
+
91
+ Additionally, you can pass in `args` and `kwargs` into your component function. After reading the code below, pay attention to how the function definition for `hello_world` (_from the previous example_) accepts a `recipient` argument.
92
+
93
+ <!--html-code-start-->
94
+
95
+ ```jinja
96
+ {% load reactpy %}
97
+ <!DOCTYPE html>
98
+ <html>
99
+ <body>
100
+ {% component "example_project.my_app.components.hello_world" recipient="World" %}
101
+ </body>
102
+ </html>
103
+ ```
104
+
105
+ <!--html-code-end-->
106
+
107
+ # Resources
108
+
109
+ Follow the links below to find out more about this project.
110
+
111
+ - [Try ReactPy (Jupyter Notebook)](https://mybinder.org/v2/gh/reactive-python/reactpy-jupyter/main?urlpath=lab/tree/notebooks/introduction.ipynb)
112
+ - [Documentation](https://reactive-python.github.io/reactpy-django)
113
+ - [GitHub Discussions](https://github.com/reactive-python/reactpy-django/discussions)
114
+ - [Discord](https://discord.gg/uNb5P4hA9X)
115
+ - [Contributor Guide](https://reactive-python.github.io/reactpy-django/latest/about/code/)
116
+ - [Code of Conduct](https://github.com/reactive-python/reactpy-django/blob/main/CODE_OF_CONDUCT.md)
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel", "nodejs-bin==18.4.0a4"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.mypy]
6
+ exclude = ['migrations/.*']
7
+ ignore_missing_imports = true
8
+ warn_unused_configs = true
9
+ warn_redundant_casts = true
10
+ warn_unused_ignores = true
11
+ check_untyped_defs = true
12
+
13
+ [tool.ruff.lint.isort]
14
+ known-first-party = ["src", "tests"]
15
+
16
+ [tool.ruff.lint]
17
+ ignore = ["E501"]
18
+
19
+ [tool.ruff]
20
+ extend-exclude = ["*/migrations/*", ".venv/*", ".eggs/*", ".nox/*", "build/*"]
21
+ line-length = 120
@@ -0,0 +1,7 @@
1
+ [bdist_wheel]
2
+ universal = 1
3
+
4
+ [egg_info]
5
+ tag_build =
6
+ tag_date = 0
7
+
@@ -0,0 +1,141 @@
1
+ from __future__ import annotations, print_function
2
+
3
+ import sys
4
+ import traceback
5
+ from distutils import log
6
+ from pathlib import Path
7
+
8
+ from nodejs import npm
9
+ from setuptools import find_namespace_packages, setup
10
+ from setuptools.command.develop import develop
11
+ from setuptools.command.sdist import sdist
12
+
13
+ # -----------------------------------------------------------------------------
14
+ # Basic Constants
15
+ # -----------------------------------------------------------------------------
16
+ name = "reactpy_django"
17
+ root_dir = Path(__file__).parent
18
+ src_dir = root_dir / "src"
19
+ package_dir = src_dir / name
20
+
21
+
22
+ # -----------------------------------------------------------------------------
23
+ # Package Definition
24
+ # -----------------------------------------------------------------------------
25
+ package = {
26
+ "name": name,
27
+ "python_requires": ">=3.9",
28
+ "packages": find_namespace_packages(src_dir),
29
+ "package_dir": {"": "src"},
30
+ "description": "It's React, but in Python. Now with Django integration.",
31
+ "author": "Mark Bakhit",
32
+ "author_email": "archiethemonger@gmail.com",
33
+ "url": "https://github.com/reactive-python/reactpy-django",
34
+ "license": "MIT",
35
+ "platforms": "Linux, Mac OS X, Windows",
36
+ "keywords": [
37
+ "interactive",
38
+ "reactive",
39
+ "widgets",
40
+ "DOM",
41
+ "React",
42
+ "ReactJS",
43
+ "ReactPy",
44
+ ],
45
+ "include_package_data": True,
46
+ "zip_safe": False,
47
+ "classifiers": [
48
+ "Framework :: Django",
49
+ "Framework :: Django :: 4.0",
50
+ "Programming Language :: Python :: 3.9",
51
+ "Programming Language :: Python :: 3.10",
52
+ "Programming Language :: Python :: 3.11",
53
+ "Programming Language :: Python :: 3.12",
54
+ "Operating System :: OS Independent",
55
+ "Intended Audience :: Developers",
56
+ "Intended Audience :: Science/Research",
57
+ "Topic :: Multimedia :: Graphics",
58
+ "Environment :: Web Environment",
59
+ ],
60
+ }
61
+
62
+
63
+ # -----------------------------------------------------------------------------
64
+ # Library Version
65
+ # -----------------------------------------------------------------------------
66
+ for line in (package_dir / "__init__.py").read_text().split("\n"):
67
+ if line.startswith("__version__ = "):
68
+ package["version"] = eval(line.split("=", 1)[1])
69
+ break
70
+ else:
71
+ print(f"No version found in {package_dir}/__init__.py")
72
+ sys.exit(1)
73
+
74
+
75
+ # -----------------------------------------------------------------------------
76
+ # Requirements
77
+ # -----------------------------------------------------------------------------
78
+ requirements: list[str] = []
79
+ with (root_dir / "requirements" / "pkg-deps.txt").open() as f:
80
+ requirements.extend(line for line in map(str.strip, f) if not line.startswith("#"))
81
+ package["install_requires"] = requirements
82
+
83
+
84
+ # -----------------------------------------------------------------------------
85
+ # Library Description
86
+ # -----------------------------------------------------------------------------
87
+ with (root_dir / "README.md").open() as f:
88
+ long_description = f.read()
89
+
90
+ package["long_description"] = long_description
91
+ package["long_description_content_type"] = "text/markdown"
92
+
93
+
94
+ # ----------------------------------------------------------------------------
95
+ # Build Javascript
96
+ # ----------------------------------------------------------------------------
97
+ def build_javascript_first(build_cls: type):
98
+ class Command(build_cls):
99
+ def run(self):
100
+ js_dir = str(src_dir / "js")
101
+
102
+ log.info("Installing Javascript...")
103
+ result = npm.call(["install"], cwd=js_dir)
104
+ if result != 0:
105
+ log.error(traceback.format_exc())
106
+ log.error("Failed to install Javascript")
107
+ raise RuntimeError("Failed to install Javascript")
108
+
109
+ log.info("Building Javascript...")
110
+ result = npm.call(["run", "build"], cwd=js_dir)
111
+ if result != 0:
112
+ log.error(traceback.format_exc())
113
+ log.error("Failed to build Javascript")
114
+ raise RuntimeError("Failed to build Javascript")
115
+
116
+ log.info("Successfully built Javascript")
117
+ super().run()
118
+
119
+ return Command
120
+
121
+
122
+ package["cmdclass"] = {
123
+ "sdist": build_javascript_first(sdist),
124
+ "develop": build_javascript_first(develop),
125
+ }
126
+
127
+ if sys.version_info < (3, 10, 6):
128
+ from distutils.command.build import build
129
+
130
+ package["cmdclass"]["build"] = build_javascript_first(build)
131
+ else:
132
+ from setuptools.command.build_py import build_py
133
+
134
+ package["cmdclass"]["build_py"] = build_javascript_first(build_py)
135
+
136
+
137
+ # -----------------------------------------------------------------------------
138
+ # Installation
139
+ # -----------------------------------------------------------------------------
140
+ if __name__ == "__main__":
141
+ setup(**package)
@@ -0,0 +1,28 @@
1
+ import contextlib
2
+
3
+ import nest_asyncio
4
+
5
+ from reactpy_django import checks, components, decorators, hooks, router, types, utils
6
+ from reactpy_django.websocket.paths import (
7
+ REACTPY_WEBSOCKET_PATH,
8
+ REACTPY_WEBSOCKET_ROUTE,
9
+ )
10
+
11
+ __version__ = "3.8.1"
12
+ __all__ = [
13
+ "REACTPY_WEBSOCKET_PATH",
14
+ "REACTPY_WEBSOCKET_ROUTE",
15
+ "hooks",
16
+ "components",
17
+ "decorators",
18
+ "types",
19
+ "utils",
20
+ "checks",
21
+ "router",
22
+ ]
23
+
24
+ # Fixes bugs with REACTPY_BACKHAUL_THREAD + built-in asyncio event loops.
25
+ # Previously, Uvicorn could generate `assert f is self._write_fut` exceptions, and Daphne
26
+ # had jittery rendering behaviors. Demonstrated using our "Renders Per Second" test page.
27
+ with contextlib.suppress(ValueError):
28
+ nest_asyncio.apply()
@@ -0,0 +1,11 @@
1
+ from django.apps import AppConfig
2
+
3
+ from reactpy_django.utils import RootComponentFinder
4
+
5
+
6
+ class ReactPyConfig(AppConfig):
7
+ name = "reactpy_django"
8
+
9
+ def ready(self):
10
+ # Populate the ReactPy component registry when Django is ready
11
+ RootComponentFinder().run()