Skip to content

Commit

Permalink
build(pyinstaller): refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhd1701 committed Oct 19, 2021
1 parent 8f159bb commit 7f4103a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
24 changes: 24 additions & 0 deletions scripts/init_app_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ copy_with_app_vars() {
replace_app_vars "$DEST_FILE"
}

init_venv() {
VENV_DIR="$1"

if [ ! -d "$VENV_DIR" ]; then
python -m venv "$VENV_DIR"

activate_venv "$VENV_DIR"

python -m pip install --upgrade pip
else
activate_venv "$VENV_DIR"
fi
}

activate_venv() {
VENV_DIR="$1"

if [ -f "$VENV_DIR/Scripts/activate" ]; then
. "$VENV_DIR/Scripts/activate"
else
. "$VENV_DIR/bin/activate"
fi
}

#ROOT_DIR="$(realpath $(dirname $( cd "$( dirname $0 )" && pwd ))/..)"
export ROOT_DIR="$(realpath $(pwd))"

Expand Down
17 changes: 7 additions & 10 deletions scripts/pyinstaller/build_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ PYINSTALLER_VERSION="4.5.1"

mkdir -p "$BUILD_DIR"

if [ ! -d "$BUILD_DIR/venv" ]; then
python -m venv "$BUILD_DIR/venv"
. "$BUILD_DIR/venv/bin/activate"
python -m pip install --upgrade pip

pip install --no-binary pydantic -r "$BUILD_DIR/requirements.txt"
pip install pyinstaller=="$PYINSTALLER_VERSION"
else
. "$BUILD_DIR/venv/bin/activate"
fi
init_venv "$BUILD_DIR/venv-pyinstaller"

# Reduce size by installing src version of pydantic
export PIP_NO_BINARY="pydantic"

pip install -r "$BUILD_DIR/requirements.txt"
pip install pyinstaller=="$PYINSTALLER_VERSION"

# Copy icons to build dir
cp "$RESOURCES_DIR/icons/main/sys/macos.icns" "$BUILD_DIR/main.icns"
Expand Down
17 changes: 7 additions & 10 deletions scripts/pyinstaller/build_win.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ PYINSTALLER_VERSION="4.5.1"

mkdir -p "$BUILD_DIR"

if [ ! -d "$BUILD_DIR/venv" ]; then
python -m venv "$BUILD_DIR/venv"
. "$BUILD_DIR/venv/Scripts/activate"
python -m pip install --upgrade pip

pip install --no-binary pydantic -r "$BUILD_DIR/requirements.txt"
pip install pyinstaller=="$PYINSTALLER_VERSION"
else
. "$BUILD_DIR/venv/Scripts/activate"
fi
init_venv "$BUILD_DIR/venv-pyinstaller"

# Reduce size by installing src version of pydantic
export PIP_NO_BINARY="pydantic"

pip install -r "$BUILD_DIR/requirements.txt"
pip install pyinstaller=="$PYINSTALLER_VERSION"

# Copy icons to build dir
cp "$RESOURCES_DIR/icons/main/sys/windows.ico" "$BUILD_DIR/main.ico"
Expand Down

0 comments on commit 7f4103a

Please sign in to comment.