Skip to main content

Generate standalone python applications.

Project description

License Build Status Python Version Compatibility Version

GravityBee helps you generate standalone applications for Windows, Mac, and Linux from your Python applications.

GravityBee is targeted at Python programs that are already packaged in the standard setuptools way.

These are some benefits of a GravityBee standalone application:

  • You end up with one file that contains everything.
  • Your users do not need Python or any packages installed.
  • You build separate natively executable applications for each of your target platforms.

GravityBee depends on Pyppyn and PyInstaller and is subject to their limitations.

To Build A Standalone Application

Step 1 - Install

You must install the application you wish to build (e.g., yoursuperapp), as well as GravityBee.

$ pip install yoursuperapp gravitybee

The process will also work fine if you’re installing from a local version of your app.

$ cd yoursuperapp
$ ls setup*
$ pip install --editable .
$ pip install gravitybee

Step 2 - Provide (or gather) information

GravityBee will assume all necessary information when run. However, you may wish to override the assumed values. You can provide values either through environment variables or command line flags. If both are provided, command line flags take precedence.


ENV VAR CL Options Desciption
GB_APP_NAME –app-name, -a The name that will appear as part of the final standalone application name. Default: name from and/or setup.cfg.
GB_PKG_NAME –pkg-name, -n The package name for the application you are building. Default: First value in packages from and/or setup.cfg, or if not found, the value from –app-name.
GB_SCRIPT –script, -s The path to the application file installed by pip when you installed your application. Depending on your configuration, this may be determined by options.entry_points.console_scripts from and/or setup.cfg. Default: $VIRTUAL_ENV/bin/app_name
GB_SRC_DIR –src-dir, -d The relative path of the package containing your application. Default: .
GB_PKG_DIR –pkg-dir, -p The relative or absolute path of the package containing your application. This directory must contain a file. Default: .
GB_VERBOSE –verbose, -v Flag for verbose mode.
GB_EXTRA_DATA –extra-data, -e Relative to package directory, any extra directories or files that need to be included, that wouldn’t normally be included as Python code. Can be used multiple times. Default: None
GB_WORK_DIR –work-dir, -w Directory for use by GravityBee to build application. Cannot be an existing directory as it will be deleted if the clean option is used. Default: .gravitybee/build/<uuid>
GB_ONEDIR –onedir Instead of packaging into one file, package in one directory. This option is not compatible with producing a SHA hash since a hash is produced on a single file. This option may be useful for debugging runtimes errors in built applications. Default: Not
GB_CLEAN –clean, -c Flag indicating whether to clean up the work directory after the build. Default: Not
GB_NAME_FORMAT –name-format, -f Format to be used in naming the standalone application. Can include {an}, {v}, {os}, {m} for app name, version, os, and machine type respectively. On Windows, .exe will be added automatidally. Default: {an}-{v}-standalone-{os}-{m}
GB_SHA_FORMAT –sha-format Format to be used in naming the SHA hash file. Can include {an}, {v}, {os}, {m} for app name, version, os, and machine type respectively. Default: {an}-{v}-sha256-{os}-{m}.json
GB_LABEL_FORMAT –label-format Format to be used in labeling the standalone application in gravitybee-files.json. Can include {An}, {an}, {v}, {os}, {m}, and {ft} for capitalized application name, lowercase app name, version, OS, machine, and file type (“Standalone Executable” or “Standalone Executable SHA256 Hash”) respectively. On Windows, .exe will be added automatically. Default: {An} {v} {ft} for {os} [GravityBee Build]
GB_NO_FILE –no-file Flag indicating to not write the output files (see below). If the --sha option is used to write a hash to a file, that file will still be written regardless. Default: Will write files
GB_SHA –sha Option of where to put SHA256 hash for generated file. Valid options are file (create a separate file with hash), or info (only include the hash in the file info output). Default: info
GB_STAGING_DIR –staging-dir Option to indicate where GravityBee should stage build artifacts (standalone executable and hash file). Two subdirectories can be created, one based on version and the other called “latest.” Default: .gravitybee/dist
GB_WITH_LATEST –with-latest Flag to indicate if GravityBee should create a “latest” directory in the staging area with a copy of the artifacts. Default: Not
GB_EXTRA_MODULES –extra-modules Any extra modules to be included with the standalone executable. Default: None
GB_EXTRA_PKGS –extra-pkgs Any extra packages to be included with the standalone executable. Default: None

If you are using environment variables, you could set them up like this.

$ export GB_APP_NAME=coolapp
$ export GB_PKG_NAME=coolapp
$ export GB_SCRIPT=/usr/var/python/etc/coolapp

Step 3 - Generate

Creating the standalone application is easy now.

$ gravitybee

If you are not using environment variables, you can combine steps 2 and 3.

$ gravitybee --app-name coolapp --script /usr/var/python/etc/coolapp --pkg-dir coolapp

Output Files

If the --no-file flag is not used, GravityBee will create output files. These include:

  • gravitybee-files.json: A JSON file that contains information about the standalone application generated by GravityBee including filename, path, mime-type, and label as a list of dicts.
  • gravitybee-info.json: A JSON file that contains information extracted about the application including app_name, app_version, console_script, script_path, pkg_dir, src_dir, name_format, clean, work_dir, gen_file, gen_file_w_path, and extra_data.
  • A shell file that can be sourced on POSIX platforms to create environment variables with GravityBee information. Each is prefixed with GB_ENV_.
  • gravitybee-environs.bat: A batch file that can be used to create environment variables with GravityBee information on Windows. Each environ is prefixed with GB_ENV_.

The Test Example

Here is the file/package structure of the included test application.

|-- setup.cfg
>-- src
|   >-- gbtestapp
|       |--
|       |--
|       >-- gbextradata
|           |--
|           |-- data_file.txt

You would build the application as follows. Since the application package is under the src directory, you need to let GravityBee know. Also, since we need to include the data_file.txt file, we’ll use the --extradata option to include the containing directory (gbextradata).

$ cd gbtestapp
$ gravitybee --src-dir src --extra-data gbextradata --verbose --clean

From Python Example

Using GravityBee from a Python script is also possible. Using the sample test app, here’s some example code.

import gravitybee

args = gravitybee.Arguments(
    pkg_dir=os.path.join("tests", "gbtestapp"),

pg = gravitybee.PackageGenerator(args)

# show path (and name) of standalone app
print("The standalone app: ", pg.gen_file_w_path)


The idea for GravityBee’s core functionality comes from Nicholas Chammas and his project flintrock. Huge thanks to Nicholas!


GravityBee is hosted on GitHub and is an open source project that welcomes contributions of all kinds from the community.

For more information about contributing, see the contributor guidelines.


0.1.20 - 2018.08.08

  • [ENHANCEMENT] Add --label-format option so that users can customize the label displayed for their applications in gravitybee-files.json.

0.1.19 - 2018.07.11

  • [ENHANCEMENT] Add --extra-pkgs and --extra-modules options for including additional packages and modules with standalone executables.

0.1.18 - 2018.07.05

  • [ENHANCEMENT] Add --onedir flag for improved debugging.

0.1.17 - 2018.06.27

  • [BUG FIX] Compatibility issues with CentOS 6 resolved.

0.1.16 - 2018.06.21

  • [BUG FIX] Compatibility issues with Windows resolved.

0.1.15 - 2018.06.06

  • [BUG FIX] Losing .exe extension with Windows executables in the latest staging area.

0.1.14 - 2018.06.04

  • [BUG FIX] --with-latest was not working as a CL flag.

0.1.13 - 2018.06.04

  • [ENHANCEMENT] Rearrange files created by GravityBee to all be contained in a .gravitybee subdirectory of the current directory.
  • [ENHANCEMENT] Place the distribution artifacts in the staging directory, with a default value of .gravitybee/dist.
  • [ENHANCEMENT] Add option --staging-dir to specify directory where artifact staging should take place and export another environment variable GB_ENV_STAGING_DIR.
  • [ENHANCEMENT] Add option --with-latest to allow creation of a second artifact staging directory called “latest” containing the artifacts renamed with “latest” in the place of the version.
  • [ENHANCEMENT] Add option --sha-format to allow custom naming of the SHA hash file.

0.1.12 - 2018.05.29

  • [ENHANCEMENT] Add OS and machine type to the SHA256 hash file (to avoid overwriting files if files from different platforms go to the same location).
  • [ENHANCEMENT] Cleanup code with better variable names.

0.1.11 - 2018.05.24

  • [ENHANCEMENT] Create a SHA256 hash for the generated standalone file and include hash with file information and optionally in a separate file (using –sha flag).
  • [ENHANCEMENT] Change names of environment variables produced with output scripts to be prefixed with GB_ENV so that the environs do not collide with environs consumed by GravityBee.
  • [ENHANCEMENT] Provide a convenience cleanup Bash script to remove GravityBee output files (e.g., json and generated executables).
  • [ENHANCEMENT] Cleanup code with more constants.

0.1.10 - 2018.05.21

  • [ENHANCEMENT] Provide two additional output files for importing GravityBee information into the environment on POSIX and Windows platforms.

0.1.9 - 2018.05.14

  • [ENHANCEMENT] Output file with run info in json format for easy consumption by other tools.

0.1.8 - 2018.05.11

  • [ENHANCEMENT] In non-verbose mode, allow for supressing stdout and stderr from pyinstaller, which can be sizeable.
  • [ENHANCEMENT] Change name of gravitybee.file to gravitybee-files.json.

0.1.7 - 2018.05.11

  • [BUG FIX] Fix exit code (was returning True).
  • [ENHANCEMENT] Automatically find console script installed by setuptools on Windows and Linux and variety of places.

0.1.6 - 2018.05.03

  • [ENHANCEMENT] Follow format prescribed by satsuki for output file (potential for multiple files).

0.1.5 - 2018.05.01

  • [ENHANCEMENT] Add mime-type and label to .json formatted file information stored in gravitybee.file.

0.1.3 - 2018.05.01

  • [ENHANCEMENT] Create gravitybee.file with name of standalone application.

0.1.2 - 2018.04.27

  • [ENHANCEMENT] Provide standalone file and path.
  • [BUG FIX] Path bug.

0.1.1 - 2018.04.26

  • [BUG FIX] Many bug fixes.

0.1.0 - 2018.04.20

  • Initial release!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
gravitybee-0.1.20-py2.py3-none-any.whl (14.9 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Aug 8, 2018
gravitybee-0.1.20.tar.gz (30.4 kB) Copy SHA256 hash SHA256 Source None Aug 8, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page