Pyro

A dynamically-typed, garbage-collected scripting language.

Version 0.17.0

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 run 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.

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 or make debug.

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 modules it needs to import. Then run:

$ make app

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

The main.pyro script acts as the application's entry point — executing the binary executes this script.

If the main.pyro script 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 app APPNAME=foobar

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

Note that you can only bake modules written in Pyro into a baked application binary. Compiled extension modules written in C are not supported.