Skip to content

Commit

Permalink
add --pyinstaller-build-args to pack cli command (#4187)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndonkoHenri authored Oct 18, 2024
1 parent 5e87936 commit b8c505a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
8 changes: 4 additions & 4 deletions sdk/python/packages/flet-cli/src/flet_cli/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
import toml
import yaml
from flet.version import update_version
from flet_cli.commands.base import BaseCommand
from flet_cli.utils.merge import merge_dict
from flet_core.utils import copy_tree, is_windows, slugify
from flet_core.utils.platform_utils import get_bool_env_var
from packaging import version
from rich import print
from rich.console import Console, Style
from rich.table import Column, Table

from flet_cli.commands.base import BaseCommand
from flet_cli.utils.merge import merge_dict

if is_windows():
from ctypes import windll

Expand Down Expand Up @@ -1316,8 +1317,7 @@ def fallback_image(yaml_path: str, images: list):

if options.flutter_build_args:
for flutter_build_arg_arr in options.flutter_build_args:
for flutter_build_arg in flutter_build_arg_arr:
build_args.append(flutter_build_arg)
build_args.extend(flutter_build_arg_arr)

if self.verbose > 1:
build_args.append("--verbose")
Expand Down
15 changes: 14 additions & 1 deletion sdk/python/packages/flet-cli/src/flet_cli/commands/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import sys
from pathlib import Path

from flet_core.utils import is_macos, is_windows

import flet_cli.__pyinstaller.config as hook_config
from flet_cli.commands.base import BaseCommand
from flet_core.utils import is_macos, is_windows


class Command(BaseCommand):
Expand Down Expand Up @@ -114,6 +115,13 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
action="store_true",
help="Using this option creates a Manifest that will request elevation upon application start.(Windows)",
)
parser.add_argument(
"--pyinstaller-build-args",
dest="pyinstaller_build_args",
action="append",
nargs="*",
help="additional arguments for pyinstaller build command",
)
parser.add_argument(
"-y",
"--yes",
Expand Down Expand Up @@ -165,6 +173,7 @@ def handle(self, options: argparse.Namespace) -> None:

try:
import PyInstaller.__main__

from flet_cli.__pyinstaller.utils import copy_flet_bin

pyi_args = [options.script, "--noconfirm"]
Expand Down Expand Up @@ -205,6 +214,10 @@ def handle(self, options: argparse.Namespace) -> None:
else:
pyi_args.append("--onefile")

if options.pyinstaller_build_args:
for pyinstaller_build_arg_arr in options.pyinstaller_build_args:
pyi_args.extend(pyinstaller_build_arg_arr)

# copy "bin"
hook_config.temp_bin_dir = copy_flet_bin()

Expand Down

0 comments on commit b8c505a

Please sign in to comment.