Skip to content

Commit

Permalink
fix: portable build
Browse files Browse the repository at this point in the history
Add metadata for readchar.
Don't use single file, faster for Windows.
  • Loading branch information
JPHutchins committed Oct 13, 2024
1 parent 40fe93d commit 0f946b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions portable.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@
assert len(archives) == 1
shutil.unpack_archive(archives[0], "dist")

# build the one-file executable
# build the portable
assert (
subprocess.run(
[
"pyinstaller",
"--onefile",
"--add-data",
f"dist/smpmgr-{version}:smpmgr",
"--copy-metadata",
"smpmgr",
"--copy-metadat=smpmgr",
"--copy-metadata=readchar",
"--name=smpmgr",
"--collect-submodules",
"shellingham",
"--collect-submodules=shellingham",
"--collect-submodules=readchar",
"--hidden-import=readchar",
"smpmgr/__main__.py",
]
).returncode
Expand All @@ -70,7 +70,7 @@
# run the executable and check the version
assert (
f"Version {version}"
in subprocess.run(["dist/smpmgr", "--help"], capture_output=True).stdout.decode()
in subprocess.run(["dist/smpmgr/smpmgr", "--help"], capture_output=True).stdout.decode()
)

# create the folder
Expand All @@ -80,7 +80,7 @@
os.makedirs(dist_path, exist_ok=True)

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

# create a VERSION.txt stamp
with open(Path(dist_path, "VERSION.txt"), "w") as f:
Expand Down
4 changes: 2 additions & 2 deletions smpmgr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
logger = logging.getLogger(__name__)

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

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

setup_logging(loglevel, logfile)
Expand Down

0 comments on commit 0f946b8

Please # to comment.