-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pyproject.toml: add post-build hooks to relocate binaries
- Loading branch information
1 parent
7d568fa
commit 14b0faf
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import shutil | ||
from pathlib import Path | ||
|
||
|
||
def post_build(interface) -> None: | ||
"""Pyinstaller post build hook. Relocate binary to root of dist directory.""" | ||
|
||
interface.write_line(" - <b>Relocating binaries</b>") | ||
for script in interface.pyproject_data["tool"]["poetry-pyinstaller-plugin"]["scripts"]: | ||
source = Path("dist", "pyinstaller", interface.platform, script) | ||
destination = Path("dist", f"{script}") | ||
|
||
if destination.exists(): | ||
shutil.rmtree(destination) # remove existing | ||
|
||
shutil.move(f"{source}", f"{destination}") | ||
interface.write_line( | ||
f" - Updated " | ||
f"<success>{source}</success> -> " | ||
f"<success>{destination}</success>" | ||
) | ||
|
||
interface.write_line(" - <b>Cleaning</b>") | ||
shutil.rmtree(Path("build")) | ||
interface.write_line(" - Removed build directory") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters