Search code examples
pythonlinuxpackagingpyinstaller

Convert a Python package into a standalone application


I have already many docs on Pyinstaller and others but all I have found is ways to convert a single .py module into a executable.

I have a python application structures as:

bbdatasync/
    __init__.py
    __main__.py
    bootstrap.py
    config/
        default.conf
    definitions/
        __init__.py
        ftp.py
        acetools.py
        configuration.py
        database.py
        sendemail.py

When I execute the package as python bbdatasync, __main__.py is run which uses all the other files and the takes configuration settings from default.conf file.

I need to package this package into a standalone application with external default.conf file which can be changed to configure the application.

I have already read several documents on packaging but none of them tell me how to package something that is a set of modules and not just one. I even tried using pyinstaller but I couldn't get it accept the whole package.

The application is supposed to run on linux only.

I have also read about freeze and it will be great if I can use that as it'll pack all the dependencies including the interpreter (is it so?) but again I can't get it to freeze the entire package!


Solution

  • Solved!

    I simply added a path to my package in site-package directory of python, then wrote the main script that uses this package to get my task done. I then used pyinstaller to make a binary of this main script and it automatically included and complied all the dependencies that includes this very package i created.

    I essentially copied the __main__.py as that had all the code that was doing the final task. Working like a charm :)

    If anyone has any suggestions or a better way, please suggest!