### Navigation

- index
- next |
- previous |
- Ren'Py Home |
- Ren'Py Documentation

# Building Distributions

Ren'Py includes support for building game distributions. Upon choosing "Build Distributions" in the launcher, Ren'Py will scan itself and the project to determine the files to include in the distribution, will create any archives that are necessary, and will build package and update files.

With no configuration, Ren'Py will build the following four kinds of packages:

All Desktop Platofrms

> A zip file targeting Windows x86, Macintosh x86, Linux x86, and Linux x86_64.

Linux x86/x86_64

> A tar.bz2 file targeting Linux x86 and Linux x86_64.

Macintosh x86

> A zip file containing a Macintosh application targeting Macintosh OS X on Intel processors. Game data will be included inside the application, which appears to the user as a single file.

Windows x86

> A zip file targeting Windows x86.

Warning

The zip and tar.bz2 files that Ren'Py produces contain permissions information that must be present for Ren'Py to run on Linux and Macintosh.

Unpacking and re-packing a zip file on Windows and then running it on Linux or Macintosh is not supported.

## Basic Configuration

The build process can be configured by setting variables and calling function that live in the build namespace. This must be done from inside an init python block.

There are a few basic variables and functions that many games will use.

`build.directory_name` = "..."

  This is used to create the names of directories in the archive files. For example, if this is set to "mygame-1.0", the Linux version of the project will unpack to "mygame-1.0-linux".

  This is also used to determine the name of the directory in which the package files are placed. For example, if you set build.directory_name to mygame-1.0, the archive files will be placed in mygame-1.0-dists in the directory above the base directory.

`build.executable_name` = "..."

  This variable controls the name of the executables that the user clicks on to start the game.

  For example, if this is set to "mygame", the user will be able to run mygame.exe on Windows, mygame.app on Macintosh, and mygame.sh on Linux.

## Special Files

There are two files that can be included in your game's base directory to customize the build.

icon.ico
  The icon that is used on Windows.
icon.icns
  The icon that is used on Macintosh.

These icon files much be in specific formats. You'll need to use a program or web service (such as http://iconverticons.com/ ) to convert them.

## Classifying and Ignoring Files

The build process works by first classifying files in the Ren'Py distribution and your game into file lists. These file lists are then added to package files.

The classification is done by the build.classify function. It takes a patterns and a space-separated list of filenames. Patterns are matched from first to last, with the first match taking precedence (even if a more-specific pattern follows.) Patterns are matched with and without a leading /. Patterns may include the following special characters:

/
  The directory separator.
*
  Matches all characters except for the directory separator.
**
  Matches all characters.

For example:

**.txt
  Matches all txt files.
game/*.txt
  Matches txt files in the game directory.

There are five file lists that files can be classified into by default. (Ren'Py places its own files into the first four of these.)

all
  These files will be included in all packages.
linux
  These files will be included in packages targeting Linux.
mac
  These files will be included in packages targeting Macintosh.
windows
  These files will be included in packages targeting Windows.
archive
  These files will be included in the archive.rpa archive.

Files that are not otherwise classified are placed in the "all" file list.

To exclude files from distribution, classify them as None or the empty string.

For example:

    # Include README.txt
    build.classify("README.txt", "all")

    # But exclude all other txt files.
    build.classify("**.txt", None)

    # Add png and jpg files in the game directory into an archive.
    build.classify("game/**.png", "archive")
    build.classify("game/**.jpg", "archive")

## Documentation

Calling the build.documentation function with patterns marks files matching those patterns as documentation. Documentation files are included twice in a Macintosh application - both inside and outside of the application itself.

For example, to mark all txt and html files in the base directory as documentation, call:

    build.documentation("*.txt")
    build.documentation("*.html")

## Packages

It's also possible to add new types of packages to the Ren'Py build process. This is done by calling the build.package function with a package name, type, and a string containing the file lists to include.

Say we wanted to build a normal version of our game, and one containing bonus material. We could classify the bonus files in to a "bonus" file list, and then declare an all-premium package with:

    build.package("all-premium", "zip", "windows mac linux all bonus")

## Archives

Ren'Py supports combining files into a simple archive format. While not very secure, this protects files from casual copying.

By default, all files classified into the "archive" file list will be placed in an archive.rpa archive, which is included in the all file list.

By calling build.archive, it's possible to declare a new archives and the file lists they will be included in. (It's rare to use anything but the all file list, however.) To use an archive, classify files into a list with its name.

For example, the following code will archive images in images.rpa, and game scripts into scripts.rpa:

    # Declare two archives.
    build.archive("scripts", "all")
    build.archive("images", "all")

    # Put script files into the scripts archive.
    renpy.classify("game/**.rpy", "scripts")
    renpy.classify("game/**.rpyc", "scripts")

    # Put images into the images archive.
    renpy.classify("game/**.jpg", "images")
    renpy.classify("game/**.png", "images")

If an archive file is empty, it will not be built.

Please think twice about archiving your game. Keeping files open will help others run your game on future platforms - platforms that may not exist until after you're gone.

## Build Functions

`build.``archive`(name, file_list='all')

  Declares the existence of an archive. If one or more files are classified with name, name.rpa is build as an archive. The archive is included in the named file lists.

`build.``classify`(pattern, file_list)

  Classifies files that match pattern into file_list.

`build.``clear`()

  Clears the list of patterns used to classify files.

`build.``documentation`(pattern)

  Declares a pattern that matches documentation. In a mac app build, files matching the documentation pattern are stored twice - once inside the app package, and again outside of it.

`build.``executable`(pattern)

  Adds a pattern marking files as executable on platforms that support it. (Linux and Macintosh)

`build.``package`(name, format, file_lists, description=None, update=True, dlc=False)

  Declares a package that can be built by the packaging tool.

  name
    The name of the package.
  format

    The format of the package. A string containing a space separated list of:

    zip
      A zip file.
    app-zip
      A zip file containing a macintosh application.
    tar.bz2
      A tar.bz2 file.

    The empty string will not build any package formats (this makes dlc possible).

  file_lists
    A list containing the file lists that will be contained within the package.
  description
    An optional description of the package to be built.
  update
    If true and updates are being built, an update will be built for this package.
  dlc
    If true, any zip or tar.bz2 file will be built in standalone DLC mode, without an update directory.

## Advanced Configuration

The following variables provide further control of the build process:

`build.exclude_empty_directories` = True

  If true, empty directories (including directories left empty by file archiving) will be removed from generated packages. If false, empty directories will be included.

### Navigation

- index
- next |
- previous |
- Ren'Py Home |
- Ren'Py Documentation