mirror of https://github.com/Chizi123/Arch-autobuild-repo.git

Joel Grunbaum
2 days ago 275460da89e74ac70ce127215753a44e40f17f1a
Add script to build an executable
1 files modified
1 files added
78 ■■■■■ changed files
README.md 25 ●●●● patch | view | raw | blame | history
scripts/build_binary.py 53 ●●●●● patch | view | raw | blame | history
README.md
@@ -16,14 +16,31 @@
## Installation
### From Source
```bash
# From source
pip install -e .
# Clone the repository
git clone https://github.com/joelgrun/archbuild
cd archbuild
# Or with development dependencies
pip install -e ".[dev]"
# Set up virtual environment and install
python -m venv .venv
source .venv/bin/activate
pip install -e .
```
### Native Arch Linux Package
To build and install as a native system package:
```bash
makepkg -si
```
### Standalone Binary
To create a standalone executable that doesn't require Python:
```bash
python scripts/build_binary.py
```
The binary will be available at `dist/archbuild-bin`.
## Quick Start
1. **Create configuration**:
scripts/build_binary.py
New file
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
"""
Script to build a standalone executable for archbuild using PyInstaller.
"""
import subprocess
import sys
import os
from pathlib import Path
def build():
    print("Building standalone executable...")
    # Ensure pyinstaller is installed
    try:
        import PyInstaller
    except ImportError:
        print("PyInstaller not found. Installing...")
        subprocess.run([sys.executable, "-m", "pip", "install", "pyinstaller"], check=True)
    # Path to the source root
    root = Path(__file__).parent.parent
    src = root / "src"
    # Create a temporary entry script
    entry_script = root / "archbuild_entry.py"
    entry_script.write_text("from archbuild.cli import main\nif __name__ == '__main__':\n    main()\n")
    # PyInstaller command
    cmd = [
        "pyinstaller",
        "--onefile",
        "--name", "archbuild-bin",
        "--paths", str(src),
        "--clean",
        "--collect-all", "archbuild",
        str(entry_script)
    ]
    print(f"Running: {' '.join(cmd)}")
    try:
        result = subprocess.run(cmd, cwd=root)
        if result.returncode == 0:
            print("\nSuccessfully built executable: dist/archbuild-bin")
        else:
            print("\nBuild failed!")
            sys.exit(result.returncode)
    finally:
        if entry_script.exists():
            entry_script.unlink()
if __name__ == "__main__":
    build()