~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
"""Exercise release tool installation with real pip and offline wheel fixtures."""
# allow: no-sut-import — executes the actual release workflow shell blocks.
from __future__ import annotations
import base64
import hashlib
import os
import subprocess
import sys
import zipfile
from pathlib import Path
import pytest
import yaml
ROOT = Path(__file__).resolve().parents[2]
WORKFLOW = ROOT / ".github/workflows/release.yml"
JOBS = ("create-release", "cleanup-changelog")
def _wheel(directory, name, version, *, requires=(), content="reviewed"):
"""Make valid wheels locally so the tests cannot contact a package index."""
module = name.replace("-", "_")
metadata = f"{module}-{version}.dist-info"
files = {
f"{module}/__init__.py": f"VALUE = {content!r}\n",
f"{metadata}/METADATA": (
f"Metadata-Version: 2.1\nName: {name}\nVersion: {version}\n"
+ "".join(
f"Requires-Dist: {dependency}\n" for dependency in requires
)
),
f"{metadata}/WHEEL": (
"Wheel-Version: 1.0\nRoot-Is-Purelib: true\nTag: py3-none-any\n"
),
}
records = []
for path, text in files.items():
data = text.encode()
digest = base64.urlsafe_b64encode(hashlib.sha256(data).digest())
records.append(
f"{path},sha256={digest.decode().rstrip('=')},{len(data)}"
)
files[f"{metadata}/RECORD"] = "\n".join(
[*records, f"{metadata}/RECORD,,", ""]
)
path = directory / f"{module}-{version}-py3-none-any.whl"
with zipfile.ZipFile(path, "w") as archive:
for filename, text in files.items():
archive.writestr(filename, text)
return path
def _install(tmp_path, job_name, failure=None):
steps = yaml.safe_load(WORKFLOW.read_text())["jobs"][job_name]["steps"]
install = next(
step for step in steps if step["name"] == "Install towncrier"
)
wheelhouse = tmp_path / "wheels"
wheelhouse.mkdir()
dependency = _wheel(wheelhouse, "release-tool-dependency", "1.0.0")
tool = _wheel(
wheelhouse,
"towncrier",
"24.8.0",
requires=("release-tool-dependency==1.0.0",),
)
pins = [
f"{name}=={version} --hash=sha256:{hashlib.sha256(path.read_bytes()).hexdigest()}"
for name, version, path in (
("towncrier", "24.8.0", tool),
("release-tool-dependency", "1.0.0", dependency),
)
]
if failure == "changed-wheel":
_wheel(
wheelhouse,
"towncrier",
"24.8.0",
requires=("release-tool-dependency==1.0.0",),
content="changed after review",
)
elif failure == "unlocked-dependency":
pins.pop()
requirements = tmp_path / "requirements"
requirements.mkdir()
(requirements / "towncrier.txt").write_text("\n".join(pins) + "\n")
# Even an unsafe installer mutation can write only to this disposable
# bootstrap environment, never the interpreter running pytest.
bootstrap = tmp_path / "bootstrap"
subprocess.run(
[sys.executable, "-m", "venv", str(bootstrap)],
check=True,
capture_output=True,
timeout=30,
)
runner_temp = tmp_path / "runner temporary files"
runner_temp.mkdir()
env = {
**os.environ,
"PATH": f"{bootstrap / 'bin'}{os.pathsep}{os.environ['PATH']}",
"RUNNER_TEMP": str(runner_temp),
"PIP_CONFIG_FILE": os.devnull,
"PIP_NO_INDEX": "1",
"PIP_FIND_LINKS": wheelhouse.as_uri(),
"PIP_NO_CACHE_DIR": "1",
"PIP_DISABLE_PIP_VERSION_CHECK": "1",
}
result = subprocess.run(
["bash", "-euo", "pipefail", "-c", install["run"]],
cwd=tmp_path,
env=env,
capture_output=True,
text=True,
timeout=60,
)
return result, runner_temp, bootstrap
@pytest.mark.parametrize("job_name", JOBS)
def test_release_tool_installs_complete_verified_tree_in_isolation(
tmp_path, job_name
):
result, runner_temp, bootstrap = _install(tmp_path, job_name)
assert result.returncode == 0, result.stdout + result.stderr
environments = list(runner_temp.glob("*/pyvenv.cfg"))
assert len(environments) == 1
python = environments[0].parent / "bin/python"
subprocess.run([str(python), "-m", "pip", "check"], check=True, timeout=15)
subprocess.run(
[str(python), "-c", "import towncrier, release_tool_dependency"],
check=True,
timeout=15,
)
probe = subprocess.run(
[str(bootstrap / "bin/python"), "-c", "import towncrier"],
capture_output=True,
timeout=15,
)
assert probe.returncode != 0, "Tool dependencies leaked into the bootstrap"
@pytest.mark.parametrize("job_name", JOBS)
@pytest.mark.parametrize(
("failure", "diagnostic"),
(
("changed-wheel", "DO NOT MATCH THE HASHES"),
("unlocked-dependency", "Hashes are required"),
),
)
def test_release_tool_refuses_changed_or_unlocked_dependencies(
tmp_path, job_name, failure, diagnostic
):
result, _, _ = _install(tmp_path, job_name, failure)
assert result.returncode != 0, result.stdout + result.stderr
assert diagnostic in result.stdout + result.stderr