Skip to content
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

Switch to using pyenv rather than manually invoking micropip #32

Merged
merged 2 commits into from Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 16 additions & 10 deletions pyscriptjs/examples/toga/README.md
Expand Up @@ -15,26 +15,32 @@ This is a demo Toga app implementing a Fahrenheit to Celsius converter.

### Development details

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

It also includes an experimental version of toga-core, toga-web and toga-flask,
packaged as wheels in the `server/wheels` directory.

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

## Web app

The web app is a demo Flask server, serving a web app version of Toga at the
root URL. To run the web demo server:
This app can be viewed as a Single Page App (SPA); this version of the app is
linked from the main PyScript demo pages.

It can also be viewed as a server-rendered app. This version of the app is
delivered by a demo Flask server, serving a version of app at the root URL. To
run the web demo server:

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

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

Enter a value in the "farenheit" input, and click the "calculate" button.
Enter a value in the "Farenheit" input, and click the "calculate" button.

It may take a few seconds for this button to become live; look for the
"Collecting nodes..." entry in the console log.
Expand Down
17 changes: 6 additions & 11 deletions pyscriptjs/examples/toga/freedom.html
Expand Up @@ -33,22 +33,17 @@
crossorigin="anonymous">
</script>
</body>
<py-env>
- './static/wheels/travertino-0.1.3-py3-none-any.whl'
- './static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl'
- './static/wheels/toga_web-0.3.0.dev33-py3-none-any.whl'
- './static/wheels/freedom-0.0.1-py3-none-any.whl'
</py-env>
<py-script>
import asyncio
import micropip

await micropip.install([
'./static/wheels/travertino-0.1.3-py3-none-any.whl',
'./static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl',
'./static/wheels/toga_web-0.3.0.dev33-py3-none-any.whl',
'./static/wheels/freedom-0.0.1-py3-none-any.whl',
])

from toga_web.dom import handle as dom_handle

from freedom.__main__ import main

app = main().main_loop(spa=True)

</py-script>
</html>
3 changes: 1 addition & 2 deletions pyscriptjs/examples/toga/freedom/pyproject.toml
Expand Up @@ -15,8 +15,7 @@ formal_name = "Freedom Units"
description = "A testing app"
sources = ['src/freedom']
requires = [
'../server/static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl',
'../server/static/wheels/travertino-0.1.3-py3-none-any.whl',
'../static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl',
]


Expand Down
2 changes: 1 addition & 1 deletion pyscriptjs/examples/toga/freedom/src/freedom/app.py
Expand Up @@ -54,7 +54,7 @@ def startup(self):


def main():
return FreedomApp('Freedom Units', 'org.beeware.freedom')
return FreedomApp('Freedom Units', 'org.beeware.freedom', version='0.0.1')


if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions pyscriptjs/examples/toga/requirements.txt
Expand Up @@ -3,7 +3,7 @@ wheel
check-manifest
briefcase
flask==2.1.1
server/static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl
server/static/wheels/toga_flask-0.3.0.dev33-py3-none-any.whl
server/static/wheels/toga_web-0.3.0.dev33-py3-none-any.whl
server/static/wheels/travertino-0.1.3-py3-none-any.whl
static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl
static/wheels/toga_flask-0.3.0.dev33-py3-none-any.whl
static/wheels/toga_web-0.3.0.dev33-py3-none-any.whl
static/wheels/travertino-0.1.3-py3-none-any.whl
1 change: 1 addition & 0 deletions pyscriptjs/examples/toga/static/pyscript
14 changes: 0 additions & 14 deletions pyscriptjs/examples/toga/static/pyscript/pyscript.css

This file was deleted.