File: build-with-pyinstaller.sh

package info (click to toggle)
jpylyzer 1.18.0-3
  • links: PTS
  • area: main
  • in suites: buster
  • size: 6,628 kB
  • sloc: xml: 106,593; python: 1,723; sh: 137; makefile: 29
file content (31 lines) | stat: -rwxr-xr-x 1,212 bytes parent folder | download | duplicates (3)
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
#!/bin/bash

# Bash script to build jpylyzer using PyInstaller

# Script base name (i.e. script name minus .py extension)
scriptBaseName=jpylyzer

# First check for PyInstaller
command -v pyinstaller >/dev/null 2>&1 || {
    echo >&2 "PyInstaller is required to build the executable.";
    echo >&2 "Please install PyInstaller with:";
    echo >&2 "  (sudo) pip install pyinstaller"
    exit 1;
}

# PyInstaller cannot be run as root
originalUserId=$(id -u);
userId=$originalUserId

if [ $originalUserId == 0 ]
then
    uname=$(getent passwd 1000 | cut -d: -f1)
    sudo -u $uname "pyi-makespec --strip --onefile --paths=$scriptBaseName --name=$scriptBaseName --specpath=pyi-build ./cli.py"
    sudo -u $uname "pyinstaller --strip --clean --paths=$scriptBaseName --distpath=pyi-build/dist --workpath=pyi-build/build ./pyi-build/$scriptBaseName.spec"
else
    # So making stripped binaries for debian packaging
    pyi-makespec --strip --onefile --paths=$scriptBaseName --name=$scriptBaseName --specpath=pyi-build ./cli.py
    pyinstaller --strip --clean --paths=$scriptBaseName --distpath=pyi-build/dist --workpath=pyi-build/build ./pyi-build/$scriptBaseName.spec
fi

./pyi-build/dist/$scriptBaseName --version;