Skip to main content

Build cross-platform installers

Project description

a flexible cross-platform package to create installers using Python


TBIP is a package designed to let you build installers with python, easily and be very flexible at the same time.


import io
import os

import tbip.installer as install
from tbip.cli import CLI
import tbip.uiutils as utils

a fake licence.

README = "Howdy. Bye now, this thing does stuff."

def main():
    installer = install.Installer(
            # a readme class
            # a licence class
            utils.Choice('proceed with installation?'),
            # make sure you want to continue
            utils.Readme(io.StringIO('you installed it. good work.'))
            # output message after installation
        # install to home directory/thing
                    or os.environ.get('USERPROFILE'), 'thing'),
        # use the CLI interface

    # run the installer

if __name__ == '__main__':

a very small, but functional example of a script.


okay, say we had that script saved, and ready to use. but what is the point? it’s not going to actually install anything, because you havent even specified where to install!!

that’s where the command line comes in handy. you should be able to run this with python -m tbip <script-name> -d <data-directory>. this will bundle your data in the installer script, as a zip file encoded in base64, to be extracted at runtime and installed from there on.


install from pip install tbip. or, clone the repository, git clone, and run python3 install

Advanced Usage

Getting Priveleges


tbip.get_admin() should restart the program as an administrator. if not, the user probably has insufficient rights.


tbip.get_root() should replace the current program with gksudo, nd run it as root.

if it does not work, install gksudo in the package gksu, and try again.


a note on how items interact with their UI: the UI object you passed to Installer was sent to each of the items you also sent. when an item’s run method is called, it is expected to return 1 of 2 values, which is passed to the UI’s :

  • 0: everything went OK, continue

  • 1: something happened, abort

there is a wider variety of items in tbip.uiutils that can be used during the installation. they include:

  • Readme

  • Licence

  • Caller

  • Choice


displays a readme, and tells the user to press enter to continue.

Readme(file) –> tbip.uiutils.Readme object


displays a licence, preceded by the header “LICENCE:”. aks the user if this is OK and wants to continue.

Licence(file) –> tbip.uiutils.Licence object


calls an external program, with the arguments specified. just a very thin wrapper around

Caller(args) –> tbip.uiutils.Caller object


prompts the user for a string, and acts accordingly. if the string enterd is not valid, prompt again.

Choice(msg="continue?", opts={'y': lambda: 0, 'n': lambda: 1}, ignorecase=True) –> tbip.uiutils.Choice object

Installation progress

there are sevreal ways to watch the installation progress (all accessed in tbip.installer.ProgressUtils)




a progress bar






displaying each file processed



do absolutely nothing



at first, display a message



Command Line options

tbip uses PyInstaller internally to freeze the output scripts.


-h, --help

display help

-v, --version

display version information

-d, --data <dir>

bundle this data with script in a zip file

-o <output>

output filename of script

-f, --freeze

freeze the installer script

PyInstaller specific:

-u, --upx <dir>

directory where UPX is installed (if at all)

-w, --windowed

use no console window (Windows specific)

-i, --icon <icon>

path to icon file (Windows specific)

Deriving classes

only the classes UI and Item should be derived from. find the base classes for:

  • UI: tbip.ui.UI

  • Item: tbip.uiutils.baseitem.Item

User Interfaces

the CLI (Command Line Interface) is a UI. you can see here:

all those methods should be overridden in a new class. (I actually haven’t used getch yet, but i might, so it would be good to)

they all should be self explanitory, but:

echo outputs the message to the screen in CLI it is just a wrapper around print. it should be able to take all of the arguments you see there, and act accordingly.

get_input should be able to read one line. the length parameter acts a bit like quantifiers in a regex. ?: truncate it to one character, or 0 +: will return if the string is one character or more, if it is null, will prompt again. *: any length (including 0)

(of course, any integer will work too)

getch should read a single character. if echo is true, echo the character too.

clear should simply clear the display


Items are easier. here is Caller:

simple, short and sweet. of course, this is a minimal example, you can create any item you want to do anything you want!

it must have run overridden, because if you didn’t, it would do nothing. remember that :code:`run` must always return 1 or 0!


any help is appreciated. if you want to help, please fork this repository, and create a pull request when you want to. also, please note any bugs, and if you have any suggestions, I would be glad to try them! thank you!

In the Future

I plan on making a GUI User interface. this is probably top of my list on things to do. once again, if you have any suggestions, either make an issue, or email me at

Project details

Download files

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

Source Distribution

tbip- (16.4 kB view hashes)

Uploaded source

Built Distribution

tbip- (16.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page