f
This commit is contained in:
@@ -81,6 +81,9 @@ def run(cmd: list[str], quiet: bool = False, debug: bool = False, cwd: Optional[
|
||||
subprocess.check_call(cmd, cwd=str(cwd) if cwd else None)
|
||||
|
||||
|
||||
REPO_URL = "https://code.glowers.club/goyimnose/Medios-Macina.git"
|
||||
|
||||
|
||||
class ProgressBar:
|
||||
def __init__(self, total: int, quiet: bool = False):
|
||||
self.total = total
|
||||
@@ -475,9 +478,87 @@ def main() -> int:
|
||||
|
||||
# Ensure repo_root is always the project root, not the current working directory
|
||||
# This prevents issues when bootstrap.py is run from different directories
|
||||
script_dir = Path(__file__).resolve().parent
|
||||
repo_root = script_dir.parent
|
||||
try:
|
||||
script_path = Path(__file__).resolve()
|
||||
script_dir = script_path.parent
|
||||
repo_root = script_dir.parent
|
||||
except NameError:
|
||||
# Running via pipe/eval, __file__ is not defined
|
||||
script_path = None
|
||||
script_dir = Path.cwd()
|
||||
repo_root = Path.cwd()
|
||||
|
||||
# DETECT REPOSITORY
|
||||
# Check if we are already inside a valid Medios-Macina repo
|
||||
def _is_valid_mm_repo(p: Path) -> bool:
|
||||
return (p / "CLI.py").exists() and (p / "scripts").exists()
|
||||
|
||||
is_in_repo = _is_valid_mm_repo(repo_root)
|
||||
|
||||
# If not in the parent of the script, check the current working directory
|
||||
if not is_in_repo and _is_valid_mm_repo(Path.cwd()):
|
||||
repo_root = Path.cwd()
|
||||
script_dir = repo_root / "scripts"
|
||||
is_in_repo = True
|
||||
|
||||
# STANDALONE INSTALLER MODE
|
||||
# If the script is run from a location that doesn't look like a Medios-Macina repo,
|
||||
# or if we're in a completely empty directory, offer to clone the repo.
|
||||
if not is_in_repo:
|
||||
if not args.quiet:
|
||||
print("\n" + "=" * 60)
|
||||
print(" MEDEOS-MACINA STANDALONE INSTALLER")
|
||||
print("=" * 60)
|
||||
print("No existing Medeos-Macina repository found at this location.")
|
||||
if script_path:
|
||||
print(f"Current script location: {script_path}")
|
||||
|
||||
# Check for git
|
||||
if not shutil.which("git"):
|
||||
print("\nError: 'git' was not found on your PATH.", file=sys.stderr)
|
||||
print("Please install Git (https://git-scm.com/) and try again.", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
try:
|
||||
# Ask for installation folder
|
||||
default_install = Path.cwd() / "Medios-Macina"
|
||||
print(f"\nWhere would you like to install Medeos-Macina?")
|
||||
install_dir_raw = input(f"Installation directory [{default_install}]: ").strip()
|
||||
if not install_dir_raw:
|
||||
install_path = default_install
|
||||
else:
|
||||
install_path = Path(install_dir_raw).resolve()
|
||||
except EOFError:
|
||||
print("Non-interactive session: cannot proceed with clone.", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
if not install_path.exists():
|
||||
print(f"Creating directory: {install_path}")
|
||||
install_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Check if it already has a repo (user might have chosen an existing folder)
|
||||
if _is_valid_mm_repo(install_path):
|
||||
print(f"Found existing repository in {install_path}.")
|
||||
repo_root = install_path
|
||||
else:
|
||||
print(f"Cloning Medeos-Macina into {install_path}...")
|
||||
print(f"Source: {REPO_URL}")
|
||||
try:
|
||||
subprocess.check_call(["git", "clone", REPO_URL, str(install_path)])
|
||||
repo_root = install_path
|
||||
except Exception as e:
|
||||
print(f"Error: Failed to clone repository: {e}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
# Change directory to the newly established repo root
|
||||
os.chdir(str(repo_root))
|
||||
print(f"\nSuccessfully set up repository at {repo_root}")
|
||||
print("Resuming bootstrap...\n")
|
||||
|
||||
# Re-initialize script_dir for the rest of the script
|
||||
# as if we started inside the repo scripts folder.
|
||||
script_dir = repo_root / "scripts"
|
||||
|
||||
if not args.quiet:
|
||||
print(f"Bootstrap script location: {script_dir}")
|
||||
print(f"Detected project root: {repo_root}")
|
||||
|
||||
Reference in New Issue
Block a user