diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py index 0d20a35..af94155 100644 --- a/scripts/bootstrap.py +++ b/scripts/bootstrap.py @@ -876,15 +876,6 @@ def main() -> int: if hydrus_script.exists(): try: subprocess.check_call([sys.executable, str(hydrus_script)]) - - # New: Prompt for location as requested - print("\n" + "="*40) - print(" HYDRUS CONFIGURATION") - print("="*40) - location = input("\nEnter the absolute path to your Hydrus git clone\n(to link it with Medios-Macina config): ").strip() - if location: - if _update_config_value(repo_root, "gitclone", location): - print(f"✅ Updated config.conf with gitclone=\"{location}\"") except subprocess.CalledProcessError: print("\nHydrusNetwork setup exited with an error.") except Exception as e: diff --git a/scripts/hydrusnetwork.py b/scripts/hydrusnetwork.py index fc3b5f2..8e58761 100644 --- a/scripts/hydrusnetwork.py +++ b/scripts/hydrusnetwork.py @@ -29,6 +29,7 @@ import tempfile import urllib.request import zipfile import shlex +import re from pathlib import Path from typing import Optional, Tuple @@ -143,6 +144,45 @@ def run_git_pull(git: str, dest: Path) -> None: subprocess.run([git, "-C", str(dest), "pull"], check=True) +def update_medios_config(hydrus_path: Path) -> bool: + """Attempt to update config.conf in the Medios-Macina root with the hydrus path. + + This helps link the newly installed Hydrus instance with the main project. + """ + # Scripts is in /scripts, so parent is root. + script_dir = Path(__file__).resolve().parent + root = script_dir.parent + config_path = root / "config.conf" + + if not config_path.exists(): + logging.debug("MM config.conf not found at %s; skipping auto-link.", config_path) + return False + + try: + content = config_path.read_text(encoding="utf-8") + key = "gitclone" + value = str(hydrus_path.resolve()) + + # Pattern to replace existing gitclone in the hydrusnetwork section + pattern = rf'^(\s*{re.escape(key)}\s*=\s*)(.*)$' + if re.search(pattern, content, flags=re.MULTILINE): + new_content = re.sub(pattern, rf'\1"{value}"', content, flags=re.MULTILINE) + else: + section_pattern = r'\[store=hydrusnetwork\]' + if re.search(section_pattern, content): + new_content = re.sub(section_pattern, f'[store=hydrusnetwork]\n{key}="{value}"', content, count=1) + else: + new_content = content + f'\n\n[store=hydrusnetwork]\nname="hydrus"\n{key}="{value}"' + + if new_content != content: + config_path.write_text(new_content, encoding="utf-8") + logging.info("✅ Linked Hydrus installation in Medios-Macina config (gitclone=\"%s\")", value) + return True + except Exception as e: + logging.debug("Failed to update MM config: %s", e) + return False + + def download_and_extract_zip( repo_url: str, dest: Path, @@ -690,12 +730,20 @@ def main(argv: Optional[list[str]] = None) -> int: action="store_true", help="Perform a full clone (no --depth passed to git clone)" ) - parser.add_argument( + group_obtain = parser.add_mutually_exclusive_group() + group_obtain.add_argument( "--git", + dest="git", action="store_true", - help= - "Use git clone instead of fetching repository ZIP (opt-in). Default: fetch ZIP (smaller).", + help="Use git clone (shallow by default) to allow updates. This is the default.", ) + group_obtain.add_argument( + "--no-git", + dest="git", + action="store_false", + help="Use ZIP download instead of git clone (no git pull support).", + ) + parser.set_defaults(git=True) parser.add_argument( "--no-fallback", action="store_true", @@ -857,6 +905,7 @@ def main(argv: Optional[list[str]] = None) -> int: try: run_git_pull(git, dest) logging.info("Updated repository in %s", dest) + update_medios_config(dest) return 0 except subprocess.CalledProcessError as e: logging.error("git pull failed: %s", e) @@ -975,14 +1024,14 @@ def main(argv: Optional[list[str]] = None) -> int: "python-dateutil": "dateutil", "beautifulsoup4": "bs4", "pillow-heif": "pillow_heif", - "pillow-jxl-plugin": "pillow_jxl_plugin", + "pillow-jxl-plugin": "pillow_jxl", "pyopenssl": "OpenSSL", "pysocks": "socks", "service-identity": "service_identity", - "show-in-file-manager": "show_in_file_manager", "opencv-python-headless": "cv2", - "mpv": "mpv", - "pyside6": "PySide6", + "pyyside6": "PySide6", + "pyside6-essentials": "PySide6", + "pyside6-addons": "PySide6", } for pkg in pkgs: mod = import_map.get(pkg, pkg) @@ -1176,6 +1225,10 @@ def main(argv: Optional[list[str]] = None) -> int: logging.error("Failed to obtain repository (ZIP): %s", exc) return 7 + # Auto-link to Medios-Macina if possible + if obtained: + update_medios_config(dest) + # Post-obtain setup: create repository-local venv (unless disabled) if not getattr(args, "no_venv", False): try: