Skip to content

Commit 0f946b8

Browse files
committed
fix: portable build
Add metadata for readchar. Don't use single file, faster for Windows.
1 parent 40fe93d commit 0f946b8

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

portable.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@
4848
assert len(archives) == 1
4949
shutil.unpack_archive(archives[0], "dist")
5050

51-
# build the one-file executable
51+
# build the portable
5252
assert (
5353
subprocess.run(
5454
[
5555
"pyinstaller",
56-
"--onefile",
5756
"--add-data",
5857
f"dist/smpmgr-{version}:smpmgr",
59-
"--copy-metadata",
60-
"smpmgr",
58+
"--copy-metadat=smpmgr",
59+
"--copy-metadata=readchar",
6160
"--name=smpmgr",
62-
"--collect-submodules",
63-
"shellingham",
61+
"--collect-submodules=shellingham",
62+
"--collect-submodules=readchar",
63+
"--hidden-import=readchar",
6464
"smpmgr/__main__.py",
6565
]
6666
).returncode
@@ -70,7 +70,7 @@
7070
# run the executable and check the version
7171
assert (
7272
f"Version {version}"
73-
in subprocess.run(["dist/smpmgr", "--help"], capture_output=True).stdout.decode()
73+
in subprocess.run(["dist/smpmgr/smpmgr", "--help"], capture_output=True).stdout.decode()
7474
)
7575

7676
# create the folder
@@ -80,7 +80,7 @@
8080
os.makedirs(dist_path, exist_ok=True)
8181

8282
# copy the executable to the folder
83-
shutil.copy(Path("dist", exe_name), Path(dist_path, exe_name))
83+
shutil.copytree(Path("dist", "smpmgr"), Path(dist_path), dirs_exist_ok=True)
8484

8585
# create a VERSION.txt stamp
8686
with open(Path(dist_path, "VERSION.txt"), "w") as f:

smpmgr/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
logger = logging.getLogger(__name__)
3232

3333
HELP_LINES: Final = (
34-
f"Simple Management Protocol (SMP) Manager Version {get_version(__package__)}\n",
34+
f"Simple Management Protocol (SMP) Manager Version {get_version('smpmgr')}\n",
3535
"Copyright (c) 2023-2024 Intercreate, Inc. and Contributors\n",
3636
)
3737

@@ -64,7 +64,7 @@ def options(
6464
version: Annotated[bool, typer.Option("--version", help="Show the version and exit.")] = False,
6565
) -> None:
6666
if version:
67-
print(get_version(__package__))
67+
print(get_version('smpmgr'))
6868
raise typer.Exit()
6969

7070
setup_logging(loglevel, logfile)

0 commit comments

Comments
 (0)