aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/doc/deployment-fbs.rst
blob: 6375da61eb79f530a98e0d27ada59022d97caf10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
===============
|project| & fbs
===============

`fbs <https://build-system.fman.io>`_ provides a powerful environment for packaging,
creating installers, and signing your application. It also lets you manage updates to
your application. As it is based on PyInstaller, it supports Linux, macOS, and Windows.

You can read the `official tutorial <https://github.com/mherrmann/fbs-tutorial>`_ for more
details on how to use `fbs`, or check the
`documentation <https://build-system.fman.io/manual/>`_ for a complete set of features and
options.

Preparation
===========

Installing `fbs` (>= 0.7.6) can be done via **pip**::

    pip install fbs

If you are using a virtual environment, remember to activate it before
installing it.

After the installation, you will be able to use the `fbs` executable.

Starting a new project
======================

`fbs` provides nice features that lets you create a base
project structure by executing the following command::

    fbs startproject

This command prompts you to answer a few questions to configure the details
of your project, like:

 * Application name
 * Author name
 * Qt bindings (PySide2 or PyQt5)
 * Bundle indentified (for macOS)

After it finishes, you will have a `src/` directory that
contains the following structure::

    └── src
        ├── build
        │   └── settings
        └── main
            ├── icons
            │   ├── base
            │   ├── linux
            │   └── mac
            └── python

Inside the `settings` directory, you will find a couple of `json` files
that can be edited to include more information about your project.

The `main` file will be under the `python` directory, and its content
by default is::

    from fbs_runtime.application_context import ApplicationContext
    from PySide2.QtWidgets import QMainWindow

    import sys

    if __name__ == '__main__':
        appctxt = ApplicationContext()       # 1. Instantiate ApplicationContext
        window = QMainWindow()
        window.resize(250, 150)
        window.show()
        exit_code = appctxt.app.exec_()      # 2. Invoke appctxt.app.exec_()
        sys.exit(exit_code)

This example shows an empty `QMainWindow`. You can run it using the
following command::

    fbs run

Freezing the application
========================

Once you verify that the application is properly working,
you can continue with the freezing process using the following
command::

    fbs freeze

After the process finishes, you will get a message stating the location
of your executable. For example::

    Done. You can now run `target/MyApp/MyApp`. If that doesn't work, see
    https://build-system.fman.io/troubleshooting.


You can now try running the application, which will result in the same
window that you saw with the `fbs run` command::

    cd target/MyApp/
    ./MyApp

.. note:: This is the case for Linux. For other platforms like macOS,
   you need to enter the directory: `target/MyApp.app/Contents/macOS`,
   and for Windows find the `MyApp.exe` executable.