Commit 51680da9 authored by Dom31's avatar Dom31
Browse files

compliant with cx_freeze (__file__ pb)

parent f038516e
Loading
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
@@ -62,7 +62,11 @@ git clone https://gitlab.com/Dom31/python-package-template/python-package-templa

## Build

```no build instructions```
For a deployment on PCs under windows:
```
$ python setup.py install --prefix=C:\Users\pc\deploy  # all the windows binaries under \Users\pc\deploy
$ python setup.py bdist_msi  # people_gui-0.1-amd64 under ./dist
```

## Tests

@@ -99,13 +103,25 @@ root:
  level: DEBUG
```

Python code: 
Python code to read local data file (and compliant with cx_freeze for Windows deployment)
```python

def find_data_file(filename):
    if getattr(sys, 'frozen', False):
        # The application is frozen
        datadir = os.path.dirname(sys.executable)
    else:
        # The application is not frozen
        # Change this bit to match where you store your data files:
        datadir = os.path.dirname(__file__)

    return os.path.join(datadir, filename)
```

Usage:
```python
    log_cfg = safe_load(resource_stream('people', logging_gui.yaml))
    logging.config.dictConfig(log_cfg)
    # create (root) logger
    # TODO: use loggers in yaml file as define them oas root logger (used in multiple python sub modules)
    logger = logging.getLogger()
        menu_file = find_data_file("menu.ui")
        builder.add_from_file(menu_file)
```

More in