Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sdk/python/packages/flet/src/flet/cli/commands/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -99,14 +104,15 @@ 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"]
if options.icon:
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:
Expand Down
18 changes: 14 additions & 4 deletions sdk/python/packages/flet/src/flet/cli/commands/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}")
Expand All @@ -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)
Expand Down