feat: Add packaging and publishing scripts, update dependencies, and enhance .gitignore
This commit is contained in:
parent
f2e5774204
commit
6ba7b0773a
6 changed files with 218 additions and 1 deletions
60
build_dist.py
Normal file
60
build_dist.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
"""Build wheel and source distribution for publishing."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parent
|
||||
DIST_DIR = PROJECT_ROOT / "dist"
|
||||
BUILD_DIR = PROJECT_ROOT / "build"
|
||||
|
||||
|
||||
def run(cmd: list[str]) -> None:
|
||||
print(f"[+] Running: {' '.join(cmd)}")
|
||||
result = subprocess.run(cmd, cwd=PROJECT_ROOT)
|
||||
if result.returncode != 0:
|
||||
raise SystemExit(result.returncode)
|
||||
|
||||
|
||||
def ensure_package(package: str) -> None:
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "pip", "show", package],
|
||||
cwd=PROJECT_ROOT,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
print(f"[+] Installing missing dependency: {package}")
|
||||
run([sys.executable, "-m", "pip", "install", package])
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print()
|
||||
print("=" * 72)
|
||||
print("Booklooker Client - Build Python Distribution")
|
||||
print("=" * 72)
|
||||
print()
|
||||
|
||||
ensure_package("build")
|
||||
|
||||
if DIST_DIR.exists():
|
||||
shutil.rmtree(DIST_DIR)
|
||||
if BUILD_DIR.exists():
|
||||
shutil.rmtree(BUILD_DIR)
|
||||
|
||||
run([sys.executable, "-m", "build"])
|
||||
|
||||
files = sorted(path.name for path in DIST_DIR.glob("*"))
|
||||
print()
|
||||
print("Built artifacts:")
|
||||
for name in files:
|
||||
print(f" - {name}")
|
||||
print()
|
||||
print("Build completed successfully.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue