Skip to content

Commit 518471b

Browse files
authored
Merge pull request pyscript#32 from anaconda/toga-pyenv
Switch to using pyenv rather than manually invoking micropip
2 parents cdc1cc4 + 6458422 commit 518471b

14 files changed

+29
-27283
lines changed

pyscriptjs/examples/toga/README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,32 @@ This is a demo Toga app implementing a Fahrenheit to Celsius converter.
1515

1616
### Development details
1717

18-
This demo bakes a pre-compiled version of pyscript into the `server/pyscript`
19-
directory.
18+
This demo symbolically links the pyscript build generated by the npm server
19+
(`../build`) into the `./static/pyscript` directory. This symbolic link should
20+
be restored automatically by git. This also means you'll need to run the main
21+
pyscript demos at least once before running the server-rendered version of the
22+
app. If you experience problems loading pyscript, check whether this link
23+
exists, and the `build/pyscript.js` file has been compiled.
2024

21-
It also includes an experimental version of toga-core, toga-web and toga-flask,
22-
packaged as wheels in the `server/wheels` directory.
23-
24-
If any changes are made to the Toga sources or to PyScript, these vendored
25-
resources will need to be updated.
25+
It also includes an vendored experimental version of toga-core, toga-web and
26+
toga-flask, packaged as wheels in the `./static/wheels` directory. If any changes
27+
are made to the Toga sources, these vendored resources will need to be updated.
2628

2729
## Web app
2830

29-
The web app is a demo Flask server, serving a web app version of Toga at the
30-
root URL. To run the web demo server:
31+
This app can be viewed as a Single Page App (SPA); this version of the app is
32+
linked from the main PyScript demo pages.
33+
34+
It can also be viewed as a server-rendered app. This version of the app is
35+
delivered by a demo Flask server, serving a version of app at the root URL. To
36+
run the web demo server:
3137

3238
$ cd server
3339
$ PYTHONPATH=../freedom/src python -m demo
3440

3541
then point your browser at http://localhost:8081/
3642

37-
Enter a value in the "farenheit" input, and click the "calculate" button.
43+
Enter a value in the "Farenheit" input, and click the "calculate" button.
3844

3945
It may take a few seconds for this button to become live; look for the
4046
"Collecting nodes..." entry in the console log.

pyscriptjs/examples/toga/freedom.html

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,17 @@
3333
crossorigin="anonymous">
3434
</script>
3535
</body>
36+
<py-env>
37+
- './static/wheels/travertino-0.1.3-py3-none-any.whl'
38+
- './static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl'
39+
- './static/wheels/toga_web-0.3.0.dev33-py3-none-any.whl'
40+
- './static/wheels/freedom-0.0.1-py3-none-any.whl'
41+
</py-env>
3642
<py-script>
37-
import asyncio
38-
import micropip
39-
40-
await micropip.install([
41-
'./static/wheels/travertino-0.1.3-py3-none-any.whl',
42-
'./static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl',
43-
'./static/wheels/toga_web-0.3.0.dev33-py3-none-any.whl',
44-
'./static/wheels/freedom-0.0.1-py3-none-any.whl',
45-
])
46-
4743
from toga_web.dom import handle as dom_handle
4844

4945
from freedom.__main__ import main
5046

5147
app = main().main_loop(spa=True)
52-
5348
</py-script>
5449
</html>

pyscriptjs/examples/toga/freedom/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ formal_name = "Freedom Units"
1515
description = "A testing app"
1616
sources = ['src/freedom']
1717
requires = [
18-
'../server/static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl',
19-
'../server/static/wheels/travertino-0.1.3-py3-none-any.whl',
18+
'../static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl',
2019
]
2120

2221

pyscriptjs/examples/toga/freedom/src/freedom/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def startup(self):
5454

5555

5656
def main():
57-
return FreedomApp('Freedom Units', 'org.beeware.freedom')
57+
return FreedomApp('Freedom Units', 'org.beeware.freedom', version='0.0.1')
5858

5959

6060
if __name__ == '__main__':

pyscriptjs/examples/toga/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ wheel
33
check-manifest
44
briefcase
55
flask==2.1.1
6-
server/static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl
7-
server/static/wheels/toga_flask-0.3.0.dev33-py3-none-any.whl
8-
server/static/wheels/toga_web-0.3.0.dev33-py3-none-any.whl
9-
server/static/wheels/travertino-0.1.3-py3-none-any.whl
6+
static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl
7+
static/wheels/toga_flask-0.3.0.dev33-py3-none-any.whl
8+
static/wheels/toga_web-0.3.0.dev33-py3-none-any.whl
9+
static/wheels/travertino-0.1.3-py3-none-any.whl
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../build

pyscriptjs/examples/toga/static/pyscript/pyscript.css

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)