--- autoconf.py.orig 2026-08-08 21:56:03.604885112 +0000 +++ autoconf.py 2026-08-08 21:56:22.498353654 +0000 @@ -32,6 +32,13 @@ return shutil.which("perl") def get_latest_semver_tag(): + """Return the version, honoring MLDONKEY_VERSION when set. + + Distributors build from a tarball, where no git repository (and + possibly no git at all) is available.""" + override = os.environ.get("MLDONKEY_VERSION") + if override: + return override try: latest_tag = subprocess.check_output( ["git", "describe", "--tags", "--abbrev=0"], @@ -39,10 +46,13 @@ ).strip() match = re.search(r'(\d+\.\d+\.\d+)', latest_tag) return match.group(1) if match else None - except subprocess.CalledProcessError: + except (subprocess.CalledProcessError, FileNotFoundError): return None def get_git_version_description(): + override = os.environ.get("MLDONKEY_SCM_VERSION") + if override: + return override try: result = subprocess.run( ["git", "describe", "--tags", "--long"], @@ -52,8 +62,8 @@ check=True ) return result.stdout.strip() - except subprocess.CalledProcessError as e: - print(f"Error running git describe: {e.stderr.strip()}") + except (subprocess.CalledProcessError, FileNotFoundError) as e: + print(f"Error running git describe: {e}") return None def extract_semver(s): @@ -95,13 +105,15 @@ return f"{system} {machine} {kernel}" def is_commit_tagged(): + if os.environ.get("MLDONKEY_VERSION"): + return True try: tags = subprocess.check_output( ["git", "tag", "--points-at", "HEAD"], text=True ).strip() return bool(tags) - except subprocess.CalledProcessError: + except (subprocess.CalledProcessError, FileNotFoundError): return False perl_path = get_perl_path()