From 5a9b2ca9e6379bfa7d795decbe0fc7c7990fda3d Mon Sep 17 00:00:00 2001 From: Feodor Fitsner Date: Thu, 9 Feb 2023 12:45:30 -0800 Subject: [PATCH 1/2] Add `--distpath` option to `flet pack` command --- sdk/python/packages/flet/src/flet/cli/commands/pack.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdk/python/packages/flet/src/flet/cli/commands/pack.py b/sdk/python/packages/flet/src/flet/cli/commands/pack.py index e3c8a7afa..f86e17533 100644 --- a/sdk/python/packages/flet/src/flet/cli/commands/pack.py +++ b/sdk/python/packages/flet/src/flet/cli/commands/pack.py @@ -35,6 +35,11 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None: default=False, help="create a one-folder bundle containing an executable (Windows)", ) + parser.add_argument( + "--distpath", + dest="distpath", + help="where to put the bundled app (default: ./dist)", + ) parser.add_argument( "--add-data", dest="add_data", @@ -99,7 +104,6 @@ def handle(self, options: argparse.Namespace) -> None: try: import PyInstaller.__main__ - from flet.__pyinstaller.utils import copy_flet_bin pyi_args = [options.script, "--noconsole", "--noconfirm"] @@ -107,6 +111,8 @@ def handle(self, options: argparse.Namespace) -> None: pyi_args.extend(["--icon", options.icon]) if options.name: pyi_args.extend(["--name", options.name]) + if options.distpath: + pyi_args.extend(["--distpath", options.distpath]) if options.add_data: for add_data_arr in options.add_data: for add_data_item in add_data_arr: From 521ab15709a2c287ee9378c9f6b6b7eb0d46dee5 Mon Sep 17 00:00:00 2001 From: Feodor Fitsner Date: Thu, 9 Feb 2023 13:00:47 -0800 Subject: [PATCH 2/2] Add `--distpath` option to `flet publish` command --- .../flet/src/flet/cli/commands/publish.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sdk/python/packages/flet/src/flet/cli/commands/publish.py b/sdk/python/packages/flet/src/flet/cli/commands/publish.py index 3cfdd52f6..c61f00636 100644 --- a/sdk/python/packages/flet/src/flet/cli/commands/publish.py +++ b/sdk/python/packages/flet/src/flet/cli/commands/publish.py @@ -35,6 +35,11 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None: default=None, help="path to an assets directory", ) + parser.add_argument( + "--distpath", + dest="distpath", + help="where to put the published app (default: ./dist)", + ) parser.add_argument( "--app-name", dest="app_name", @@ -82,14 +87,13 @@ def handle(self, options: argparse.Namespace) -> None: # constants dist_name = "dist" - flet_web_filename = "flet-web.tar.gz" app_tar_gz_filename = "app.tar.gz" reqs_filename = "requirements.txt" # script path script_path = options.script - if not os.path.isabs(options.script): - script_path = str(Path(os.getcwd()).joinpath(options.script).resolve()) + if not os.path.isabs(script_path): + script_path = str(Path(os.getcwd()).joinpath(script_path).resolve()) if not Path(script_path).exists(): print(f"File not found: {script_path}") @@ -98,7 +102,13 @@ def handle(self, options: argparse.Namespace) -> None: script_dir = os.path.dirname(script_path) # delete "dist" directory - dist_dir = os.path.join(script_dir, dist_name) + dist_dir = options.distpath + if dist_dir: + if not os.path.isabs(dist_dir): + dist_dir = str(Path(os.getcwd()).joinpath(dist_dir).resolve()) + else: + dist_dir = os.path.join(script_dir, dist_name) + print(f"Cleaning up {dist_dir}...") if os.path.exists(dist_dir): shutil.rmtree(dist_dir, ignore_errors=True)