Examples¶
Work in Progress
Section yet to be actually written 😉
📦 Pyaket's configuration is done via environment variables read by rust at compile time, which are processed and passed through to the executable to load at runtime.
from pyaket import PyaketProject
for target in ("windows", "linux", "macos"):
project = PyaketProject()
project.app.name = "MyApp"
project.app.author = "MyName"
project.python.version = "3.11"
project.deps.pypi.append("numpy")
project.deps.wheels.append("./dist/project-0.0.1-py3-none-any.whl")
project.release.target = target
executable = project.compile()
Note: It's recommended to always recreate a PyaketProject class for each build.
Simple to use¶
Compile a cowsay binary for the current platform and run it:
$ pyaket app --name cowsay --pypi "cowsay==6.1" run --module cowsay compile
Compiling libc v0.2.172
Compiling typenum v1.18.0
...
Finished `release` profile [optimized] target(s) in 9.88s
$ ./release/cowsay-linux-amd64-v0.0.0.bin -t "Hello, Pyaket!"
______________
| Hello, Pyaket! |
==============
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||
Blazingly fast¶
after the first installation:
$ hyperfine "./release/cowsay-linux-amd64-v0.0.0.bin -t anyhow"
Time (mean ± σ): 23.3 ms ± 0.3 ms [User: 15.8 ms, System: 7.2 ms]
Range (min … max): 22.9 ms … 24.8 ms 100 runs
$ hyperfine "python -m cowsay -t anyhow"
Time (mean ± σ): 18.5 ms ± 0.1 ms [User: 14.2 ms, System: 4.1 ms]
Range (min … max): 18.2 ms … 19.0 ms 100 runs
Note: The actual benchmark command was nice -20 taskset -c 2 hyperfine -w 50 -r 100 -N (...)
Cross compile¶
to most platforms and architectures easily:
# Windows executables compiled from linux, needs a mingw64 toolchain!
$ pyaket app -n cowsay -p "cowsay==6.1" run -m cowsay release -t windows compile
Finished `release` profile [optimized] target(s) in 8.11s
$ wine ./Release/cowsay-windows-amd64-v0.0.0.exe -t "Hello, Wine!"
____________
| Hello, Wine! |
============
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||
# Intel Macbook @ ./release/cowsay-macos-amd64-v0.0.0.bin
$ pyaket ... release --target macos --arch amd64 compile
# Apple Silicon @ ./release/cowsay-macos-arm64-v0.0.0.bin
$ pyaket ... release --target macos --arch arm64 compile
Bundle wheels¶
and install them at runtime, perfect for monorepos:
$ uv build --all-packages --wheel
Successfully built dist/shared-1.0.0-py3-none-any.whl
Successfully built dist/project_a-1.0.0-py3-none-any.whl
Successfully built dist/project_b-1.0.0-py3-none-any.whl
# Both will share the same virtual environment 🤯
# ./release/{project_a,project_b}-linux-amd64-v0.0.0.bin
$ pyaket app -n project_a -w "dist/*.whl" run -m project_a compile
$ pyaket app -n project_b -w "dist/*.whl" run -m project_b compile
Install pytorch¶
at runtime, with automatic backend detection: