Skip to content

Commit

Permalink
Add how-to page (#63)
Browse files Browse the repository at this point in the history
* Add how-to page

* Update index.md
  • Loading branch information
ofek authored Dec 31, 2023
1 parent 9a6568e commit 8dec9d6
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
76 changes: 76 additions & 0 deletions docs/how-to.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# How-to

-----

What follows is a short example showing the end-to-end experience from building an application to running the application as a user.

## Install Rust

Follow [the instructions](https://www.rust-lang.org/tools/install) to install Rust and make sure the package manager Cargo is on your PATH.

## Get PyApp

In order to [build](build.md) applications with PyApp, you must first download the source code. Here we will download the latest release.

=== "Linux/macOS"
1. `curl https://github.com/ofek/pyapp/releases/latest/download/source.tar.gz -Lo pyapp-source.tar.gz`
2. `tar -xzf pyapp-source.tar.gz`
3. `mv pyapp-v* pyapp-latest`
4. `cd pyapp-latest`

=== "Windows"
1. `Invoke-WebRequest https://github.com/ofek/pyapp/releases/latest/download/source.zip -OutFile pyapp-source.zip`
2. `7z x pyapp-source.zip`
3. `mv pyapp-v* pyapp-latest`
4. `cd pyapp-latest`

## Configuration

You must [configure](config.md) the binaries PyApp produces with environment variables. There are [many ways](examples.md) to configure applications but here we will define a single package to install from PyPI at a specific version:

| Option | Value |
| --- | --- |
| `PYAPP_PROJECT_NAME` | `cowsay` |
| `PYAPP_PROJECT_VERSION` | `6.0` |

## Building

Run:

```
cargo build --release
```

The executable will be located at `target/release/pyapp.exe` if on Windows or `target/release/pyapp` otherwise.

## Distribution

Be sure to rename the binary to the name of the application (and make it executable on non-Windows systems):

=== "Linux/macOS"
```
mv target/release/pyapp cowsay && chmod +x cowsay
```

=== "Windows"
```
mv target\release\pyapp.exe cowsay
```

## Runtime

After you have distributed the binary to the user, they can execute it directly:

```
$ ./cowsay -t 'Hello, World!'
_____________
| Hello, World! |
=============
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||
```
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ PyApp is a wrapper for Python applications that bootstrap themselves at runtime.

![PyApp example workflow](assets/images/example.gif){ loading=lazy role="img" }

See the [how-to](how-to.md) for a detailed example walkthrough.

## Features

- Easily build standalone binaries for every platform
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ theme:

nav:
- About: index.md
- How-to: how-to.md
- Building: build.md
- Configuration: config.md
- Runtime behavior: runtime.md
Expand Down

0 comments on commit 8dec9d6

Please sign in to comment.