Pyro

A scripting language for people who enjoy the simpler things in life.

Version 0.9.35

Building & Installing Pyro


Building & Installing

You'll need a C compiler and a POSIX compatible operating system (Mac, Linux, BSD, etc.) to build Pyro from source.

First, download the Pyro repository from Github and cd into the pyro directory:

$ git clone https://github.com/dmulholl/pyro.git
$ cd pyro

To build the release binary run:

$ make release

The release binary will be created in a new build/release directory as build/release/pyro.

To install the release binary run:

$ make install

This copies the pyro binary to the /usr/local/bin/ directory. (Depending on your operating system, you may need to run sudo make install to provide the proper permissions.)

You can now run Pyro like any other installed binary:

$ pyro

Running Pyro without a script argument launches the REPL — an interactive environment where you can try running Pyro commands directly, e.g.

>>> 1 + 2;
3

Pyro statements normally end with a semicolon, ;, but you can omit the semicolon after typing a single statement in the REPL, e.g.

>>> 1 + 2
3

Hit Ctrl-D or type exit and hit return to end the REPL session.

To run a Pyro script, supply its filename to the binary:

$ pyro path/to/script.pyro

Executable Scripts

To make a Pyro script executable, add a shebang line to the top of the file, e.g.

#!/usr/bin/env pyro
echo "hello world";

Then make the script file itself executable — e.g. for a file called script.pyro:

$ chmod +x ./script.pyro

You can now run the script directly as an executable, e.g.

$ ./script.pyro
hello world

Note that the .pyro suffix is purely a convention — Pyro scripts don't require any special suffix or naming convention.

Test Suite

If you'd like to try hacking on Pyro's source code, you'll want to run the test suite after every change.

To build a new release binary and run the test suite run:

$ make check-release

To build a new debug binary and run the test suite run:

$ make check-debug

The debug binary is (much) slower than the release binary. It enables assert statements and stresses the garbage collector by running the garbage collection routine before executing each bytecode instruction.

If you'd like to try hacking on Pyro's source code, you should run the test suite with the debug binary after every change. You can do this by running the shortcut command:

$ make check

You can also run Pyro's test suite directly using the test command, e.g.

$ pyro test ./tests/*.pyro

You can learn more about the test command here.

Embedding Modules

You can embed modules written in Pyro directly into a custom build of the Pyro binary. Simply place the modules in the embed directory and run make release.

You can import the embedded modules in the usual way — the embed directory functions as a virtual import root.

Baked Application Binaries

You can compile a Pyro script and a collection of modules into a single-file binary.

To compile a baked binary, place a script file named main.pyro in the embed directory, along with any required modules. Then run:

$ make baked-app

The application will be compiled as build/release/app.

The main.pyro script acts as the application's entry point. If this file contains a $main() function, it will be called automatically.

You can specify a custom name for the binary by setting the APPNAME variable, e.g.

$ make baked-app APPNAME=foobar