Skip to content

Commit

Permalink
CLI improvements (#41)
Browse files Browse the repository at this point in the history
* Update package_command.dart

* Bump http dep to 1.1.2 and other dependencies

* Added `--mobile` and `--verbose` flags.

More detailed output.
Async everything.

* Bump Flet dep to 0.15.0

* Bump serious_python version to 0.6.0

* Create _posixsubprocess.py

* More mobile junk files: .a, .pdb, .pyd, .exe, .dll

* Delete files with .h extension

* Added to readme about `--mobile` and `--verbose` flags

* Added --web arg to package for pyodide

* FFI things moved to android package

* Added extra packaging args

* Added web platform to flet_example

* Implemented dep-mappings and req-deps arguments

* --find-links and --platform implemented

* Changelogs updated

* Cleanup.

* Fix yaml

* Use "=" in dep mappings

* Fixed flet_example windows project

* Use predefined TCP port on Windows to avoid firewall dialog
  • Loading branch information
FeodorFitsner authored Dec 13, 2023
1 parent 0f7b5cb commit 2702b50
Show file tree
Hide file tree
Showing 46 changed files with 782 additions and 212 deletions.
12 changes: 6 additions & 6 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ for:

test_script:
- cd src/serious_python/example/flet_example
- dart run serious_python:main package app/src --pre
- dart run serious_python:main package app/src --dep-mappings "flet=flet-embed" --req-deps "flet-embed"
- flutter test integration_test -d macos

# ======================================
Expand Down Expand Up @@ -234,7 +234,7 @@ for:

test_script:
- cd src/serious_python/example/flet_example
- dart run serious_python:main package app/src --pre
- dart run serious_python:main package app/src --mobile --dep-mappings "flet=flet-embed" --req-deps "flet-embed"
- flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart

# ======================================
Expand Down Expand Up @@ -276,7 +276,7 @@ for:

test_script:
- cd src/serious_python/example/flet_example
- dart run serious_python:main package app/src --pre
- dart run serious_python:main package app/src --mobile --dep-mappings "flet=flet-embed" --req-deps "flet-embed"
- flutter test integration_test -d emulator-5554


Expand All @@ -298,7 +298,7 @@ for:

test_script:
- cd src/serious_python/example/flet_example
- dart run serious_python:main package app/src --pre
- dart run serious_python:main package app/src --dep-mappings "flet=flet-embed" --req-deps "flet-embed"
- flutter test integration_test -d windows

# ======================================
Expand All @@ -318,7 +318,7 @@ for:

test_script:
- cd src/serious_python/example/flet_example
- dart run serious_python:main package app/src --pre
- dart run serious_python:main package app/src --dep-mappings "flet=flet-embed" --req-deps "flet-embed"
- xvfb-run flutter test integration_test -d linux

# ======================================
Expand All @@ -342,7 +342,7 @@ for:

test_script:
- cd src/serious_python/example/flet_example
- dart run serious_python:main package app/src --pre
- dart run serious_python:main package app/src --dep-mappings "flet=flet-embed" --req-deps "flet-embed"
- xvfb-run flutter test integration_test -d linux

# =========================================
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ To simplify the packaging of your Python app Serious Python provides a CLI which
dart run serious_python:main
```

There is `package` command which takes a directory with Python app as the first argument. The command must be run in Flutter app root directory, where `pubspec.yaml` is located. The path could be either relative or an absolute:
There is `package` command which takes a directory with Python app as the first argument. The command must be run in Flutter app root directory, where `pubspec.yaml` is located. The path could be either relative or an absolute.

To package Python files for a mobile app run:

```
dart run serious_python:main package app/src --mobile
```

To package for a desktop app run:

```
dart run serious_python:main package app/src
Expand Down Expand Up @@ -285,6 +293,16 @@ List libraries and their versions in `requirements.txt` in the root of your Pyth

List libraries and their versions in `requirements.txt` in the root of your Python app directory.

## Troubleshooting

### Detailed logging

Use `--verbose` flag to enabled detailed logging:

```
dart run serious_python:main package app/src --mobile --verbose
```

## Examples

[Python REPL with Flask backend](src/serious_python/example/flask_example).
Expand Down
12 changes: 12 additions & 0 deletions src/serious_python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 0.6.0

* `--verbose` flag - verbose output.
* `--mobile` flag - (removes `.so`) from app dest archive.
* `--web` flag for packaging for pyodide.
* `--find-links` option for installing pip dependencies from alternative sources (indexes).
* `--dep-mappings` for rewriting `flet` dependency to either `flet-embed` or `flet-pyodide`.
* `--req-deps` for adding required dependencies like `flet-embed` or `flet-pyodide`.
* `--platform` option for use with `sitecustomize.py` to tweak pip to pull platform-specific packages.
* More structured regular output.
* Bump deps versions.

## 0.5.1

* Simplified Python initialization on Android.
Expand Down
13 changes: 13 additions & 0 deletions src/serious_python/bin/README.rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pip commands:

```
python -m pip install --upgrade --target 2 --no-index --find-links file:///path/to/index.html micropip --verbose
```

`index.html` example:

```html
<a href="https://cdn.jsdelivr.net/pyodide/v0.24.1/full/micropip-0.5.0-py3-none-any.whl">micropip-0.5.0-py3-none-any.whl</a>
<a href="https://cdn.jsdelivr.net/pyodide/v0.24.1/full/packaging-23.1-py3-none-any.whl">packaging-23.1-py3-none-any.whl</a>
<a href="https://cdn.jsdelivr.net/pyodide/v0.24.1/full/numpy-1.25.2-cp311-cp311-emscripten_3_1_45_wasm32.whl">numpy-1.25.2-cp311-cp311-emscripten_3_1_45_wasm32.whl</a>
```
Loading

0 comments on commit 2702b50

Please sign in to comment.