Skip to content

Commit

Permalink
fix: deploy cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
leocov-dev committed Oct 12, 2024
1 parent 6ccf4f3 commit 42d1176
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
26 changes: 9 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Custom style, widgets, and utilities for cross-platform PySide6 applications.

> 🚧 🚧 🚧 NOTICE 🚧 🚧 🚧
> [!WARNING]
>
> This project should be considered experimental and subject to breaking changes
> AT ANY TIME until a v1.0.0 release.
Expand Down Expand Up @@ -35,10 +35,15 @@ hatch env create

### Run example application

You must run the examples from the repository root directory.
An example project/application is included

```shell
hatch run examples:toolbar_app
# switch to the example project dir
cd examples/toolbar-app-project
# build the project
hatch build -t pyside-app --clean
# list the build artifacts
ls dist
```

### Run tests
Expand All @@ -49,20 +54,7 @@ Hatch can run tests across multiple versions of python.
hatch test -a -p
```

### Generate resources files

Resource files MUST be generated at least once in the project using this library
for icons to function.

When installed this library provides a cli tool `pyside-app-compile-rcc`
that aids in generating a `resources.rcc` file.

```shell
# from repo with this lib installed
pyside-app-compile-rcc a/target/directory
```

### Hatch Build Plugin

This library exposes a `hatch` build plugin that will generate Qt resources and
package a standalone executable.
package a standalone executable. See the example project for details.
5 changes: 1 addition & 4 deletions examples/toolbar-app-project/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
```shell
hatch run
$ python -m examples.simple-app
```
# Example Project
1 change: 1 addition & 0 deletions src/pyside_app_build/_pysidedeploy_spec_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def build_deploy_spec(
"--assume-yes-for-downloads",
"--noinclude-qt-translations",
"--static-libpython=no",
"--report=compilation-report.xml",
*[f"--include-package-data={d}" for d in extra_package_data],
*[f"--include-data-dir={d}" for d in extra_data_dirs]
]
Expand Down
14 changes: 14 additions & 0 deletions src/pyside_app_build/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def _build_standard(self, _: str, **__: Any) -> str:

shutil.move(bundle_tmp, app_build_bundle)
shutil.move(self.config.spec_root / "deployment", self.config.build_dir / "deployment")
shutil.move(self.config.spec_root / "compilation-report.xml", self.config.build_dir / "compilation-report.xml")

self.app.display_debug("Packaging App Executable...")
match plat := platform.system():
Expand Down Expand Up @@ -90,21 +91,34 @@ def _gen_icon(self) -> None:


def _pyside_deploy(self, spec_file: Path) -> Path:
match plat := platform.system():
case "Darwin":
mode = "standalone"
case "Linux":
mode = "onefile"
case "Windows":
mode = "onefile"
case _:
raise Exception(f"Unsupported platform: {plat}")

out = subprocess.run(
[
"pyside6-deploy",
"--force",
"--mode", mode,
"--keep-deployment-files",
"--c",
str(spec_file),
],
text=True,
cwd=str(spec_file.parent),
capture_output=True,
check=True,
)

if self.app.verbosity >= 1:
print(out.stdout)
print(out.stderr)

if out.returncode != 0:
raise Exception(f"PySide Deploy failed: {out.stderr}")
Expand Down

0 comments on commit 42d1176

Please sign in to comment.