diff --git a/.dockerignore b/.dockerignore
index 93615d2..265b636 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -8,3 +8,4 @@ __pycache__
.pytest_cache
.ruff_cache
*.egg-info
+dist
diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index f58f7bc..0000000
--- a/.gitattributes
+++ /dev/null
@@ -1,2 +0,0 @@
-# Unified diffs use a single space to represent an empty context line.
-*.patch whitespace=-blank-at-eol
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 80129e4..c51e193 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -2,7 +2,7 @@ name: Wheels
on:
push:
- branches: [master]
+ branches: [main]
pull_request:
workflow_dispatch:
inputs:
@@ -29,16 +29,18 @@ jobs:
include:
- target: linux-amd64
runner: ubuntu-24.04
- identifier: cp313-manylinux_x86_64
+ architecture: x86_64
+ image: quay.io/pypa/manylinux_2_28_x86_64@sha256:e0adf18521ad35192df733a6c62d35df7801957d24e0470238aacecfab2188a3
- target: linux-arm64
runner: ubuntu-24.04-arm
- identifier: cp313-manylinux_aarch64
+ architecture: aarch64
+ image: quay.io/pypa/manylinux_2_28_aarch64@sha256:a3e02308c822fb6ce0d12248b0c941817ba5e1a1bc9e7bb5929f29c50eaa40a9
- target: macos-amd64
runner: macos-15-intel
- identifier: cp313-macosx_x86_64
+ architecture: x86_64
- target: macos-arm64
runner: macos-15
- identifier: cp313-macosx_arm64
+ architecture: arm64
runs-on: ${{ matrix.runner }}
timeout-minutes: 35
steps:
@@ -54,12 +56,35 @@ jobs:
if: runner.os == 'macOS'
run: |
brew list cmake >/dev/null || brew install cmake
- rustup toolchain install 1.99.1 --profile minimal
- - name: Build and exercise installed wheel
+ - name: Build and exercise Linux wheel
+ if: runner.os == 'Linux'
env:
- WHEEL_IDENTIFIER: ${{ matrix.identifier }}
- CIBW_TEST_COMMAND: uv run --no-project python {project}/bin/test_wheel.py --install-ca
- run: uvx --from cibuildwheel==4.3.5 cibuildwheel --only "$WHEEL_IDENTIFIER" --output-dir dist
+ MANYLINUX_IMAGE: ${{ matrix.image }}
+ WHEEL_ARCHITECTURE: ${{ matrix.architecture }}
+ run: |
+ docker run --rm -v "$PWD:/project" -w /project \
+ -e WHEEL_ARCHITECTURE -e CARGO_TARGET_DIR=/tmp/target \
+ "$MANYLINUX_IMAGE" bash -euo pipefail -c '
+ dnf install -y clang clang-devel cmake git
+ curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none --profile minimal
+ export PATH="/root/.cargo/bin:$PATH"
+ uv run --no-project --python /opt/python/cp313-cp313/bin/python python bin/build_wheel.py --out-dir /tmp/native-wheel
+ uvx --from auditwheel==6.8.2 auditwheel repair --plat "manylinux_2_28_$WHEEL_ARCHITECTURE" --wheel-dir dist /tmp/native-wheel/*.whl
+ uv venv --python /opt/python/cp313-cp313/bin/python /tmp/wheel-test
+ uv pip install --python /tmp/wheel-test/bin/python dist/*.whl
+ VIRTUAL_ENV=/tmp/wheel-test PATH="/tmp/wheel-test/bin:$PATH" uv run --no-project python bin/test_wheel.py --install-ca
+ '
+ - name: Build and exercise macOS wheel
+ if: runner.os == 'macOS'
+ env:
+ WHEEL_ARCHITECTURE: ${{ matrix.architecture }}
+ MACOSX_DEPLOYMENT_TARGET: "11.0"
+ run: |
+ uv run --no-project python bin/build_wheel.py --out-dir "$RUNNER_TEMP/native-wheel"
+ uvx --from delocate==0.13.0 delocate-wheel --require-archs "$WHEEL_ARCHITECTURE" --wheel-dir dist "$RUNNER_TEMP/native-wheel"/*.whl
+ uv venv --python 3.13 "$RUNNER_TEMP/wheel-test"
+ uv pip install --python "$RUNNER_TEMP/wheel-test/bin/python" dist/*.whl
+ VIRTUAL_ENV="$RUNNER_TEMP/wheel-test" PATH="$RUNNER_TEMP/wheel-test/bin:$PATH" uv run --no-project python bin/test_wheel.py --install-ca
- name: Check package metadata
run: |
uvx --from twine==7.0.0 twine check --strict dist/*.whl
@@ -71,7 +96,7 @@ jobs:
if-no-files-found: error
publish:
- if: github.event_name == 'workflow_dispatch' && inputs.publish && github.ref == 'refs/heads/master'
+ if: github.event_name == 'workflow_dispatch' && inputs.publish && github.ref == 'refs/heads/main'
needs: wheels
runs-on: ubuntu-24.04
environment: pypi
@@ -112,8 +137,10 @@ jobs:
for wheel in wheels:
assert wheel.name.startswith(f'archivebox_proxy-{version}-py3-none-'), wheel
with zipfile.ZipFile(wheel) as archive:
- engine = archive.getinfo('archivebox_proxy/bin/archivebox-proxy-engine')
+ engine = archive.getinfo('archivebox_proxy/engine/archivebox-proxy-engine')
assert engine.external_attr >> 16 & 0o111, wheel
+ metadata = archive.read(next(name for name in archive.namelist() if name.endswith('/WHEEL'))).decode()
+ assert 'Root-Is-Purelib: false' in metadata, wheel
PY
# Only wheels are published: installation never needs a compiler or a
# first-run binary download, and unsupported platforms fail at resolution.
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index d38c685..b50aeba 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -2,7 +2,7 @@ name: Tests
on:
push:
- branches: [master]
+ branches: [main]
pull_request:
workflow_dispatch:
@@ -34,7 +34,7 @@ jobs:
sudo apt-get install -y clang cmake libclang-dev pkg-config
- name: Build pinned Proxelar engine
run: |
- cargo fmt --check
+ uv run python bin/build_engine.py --fmt
uv run python bin/build_engine.py --locked
uv run python bin/build_engine.py --locked --clippy
- name: Install and check controller
@@ -46,88 +46,57 @@ jobs:
container:
runs-on: ubuntu-24.04
timeout-minutes: 25
+ env:
+ COMPOSE_PROJECT_NAME: archivebox-proxy-ci
+ ARCHIVEBOX_DATA: /tmp/archivebox-proxy-ci-data
+ ARCHIVEBOX_PORT: "18800"
+ PROXY_PORT: "18880"
+ PROXY_WORKER_PORT: "18882"
+ PLUGINS: screenshot,title,headers
+ PROXY_PERSONA: Default
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false
- - name: Validate deployment configuration
- env:
- ARCHIVEBOX_DATA: /tmp/archivebox
+ - name: Validate and start the complete deployment
run: |
docker compose config --quiet
- docker compose -f docker-compose.yml -f docker-compose.archive.yml config --quiet
- docker compose -f docker-compose.yml -f docker-compose.capture.yml config --quiet
- - name: Build proxy image
- run: docker build --target runtime -t archivebox-proxy:ci .
- - name: Exercise HTTPS cache in the container
+ docker compose up -d --build --wait --wait-timeout 120
+ curl --fail --silent --show-error http://localhost:18800/health/ | grep -qx OK
+ docker compose exec -T proxy archivebox-proxy --export-ca > /tmp/proxy-ca.pem
+ - name: Exercise HTTPS caching and automatic ArchiveBox capture
shell: bash
run: |
set -euo pipefail
- docker run -d --name proxy -p 127.0.0.1:18880:8080 -p 127.0.0.1:18882:8082 archivebox-proxy:ci
- trap 'docker logs proxy; docker rm -f -v proxy' EXIT
+ curl --compressed --noproxy '' --fail --silent --show-error --max-time 30 --cacert /tmp/proxy-ca.pem --proxy socks5h://127.0.0.1:18880 -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Dest: document' https://news.ycombinator.com/ask -o /tmp/first.html
+ # Observe the asynchronous store before the one warm-cache request.
for _ in {1..100}; do
- if docker cp proxy:/cache/trust.pem /tmp/proxy-ca.pem 2>/dev/null; then
+ if docker compose exec -T proxy sh -c "grep -q 'STORED visitor .* 200 GET https://news.ycombinator.com/ask' /cache/proxy/proxy.log"; then
break
fi
- test "$(docker inspect --format '{{.State.Running}}' proxy)" = true
sleep 0.1
done
- test -s /tmp/proxy-ca.pem
- curl --noproxy '' --fail --silent --show-error --max-time 30 --cacert /tmp/proxy-ca.pem --proxy http://127.0.0.1:18880 https://news.ycombinator.com/ -o /tmp/first.html
- # Streaming completion precedes the controller's asynchronous store.
- # Observe persistence before making the one warm-cache request.
- for _ in {1..100}; do
- if docker exec proxy sh -c "grep -q 'STORED visitor .* 200 GET https://news.ycombinator.com/' /cache/proxy.log"; then
- break
- fi
- test "$(docker inspect --format '{{.State.Running}}' proxy)" = true
- sleep 0.1
- done
- docker exec proxy sh -c "grep -q 'STORED visitor .* 200 GET https://news.ycombinator.com/' /cache/proxy.log"
- curl --noproxy '' --fail --silent --show-error --max-time 30 --cacert /tmp/proxy-ca.pem --proxy http://127.0.0.1:18882 https://news.ycombinator.com/ -D /tmp/second.headers -o /tmp/second.html
+ docker compose exec -T proxy sh -c "grep -q 'STORED visitor .* 200 GET https://news.ycombinator.com/ask' /cache/proxy/proxy.log"
+ curl --compressed --noproxy '' --fail --silent --show-error --max-time 30 --cacert /tmp/proxy-ca.pem --proxy http://127.0.0.1:18882 -H 'Accept-Encoding: gzip, deflate, br, zstd' https://news.ycombinator.com/ask -D /tmp/second.headers -o /tmp/second.html
cmp /tmp/first.html /tmp/second.html
grep -qi '^x-archivebox-proxy-cache: HIT' /tmp/second.headers
grep -q 'Hacker News' /tmp/second.html
- - name: Build optional ArchiveBox CLI image
- run: |
- docker build --target with-archivebox -t archivebox-proxy:with-archivebox .
- docker run --rm --entrypoint archivebox archivebox-proxy:with-archivebox version
- - name: Exercise automatic ArchiveBox capture
- shell: bash
- run: |
- set -euo pipefail
- capture_evidence=$(mktemp -d)
- capture_collection=$(docker volume create)
- trap 'docker logs archivebox-capture || true; docker exec archivebox-capture cat /cache/hooks.log || true; docker rm -f -v archivebox-capture || true; docker volume rm "$capture_collection"' EXIT
- docker run --rm --mount "type=volume,source=$capture_collection,target=/data" --entrypoint archivebox archivebox-proxy:with-archivebox init
- docker run -d --name archivebox-capture --mount "type=volume,source=$capture_collection,target=/data" --mount "type=volume,source=$capture_collection,target=/archivebox,readonly" -e PLUGINS=screenshot,title,headers -p 127.0.0.1:18880:8080 archivebox-proxy:with-archivebox --bind 0.0.0.0 --archivebox-dir /data --archive /archivebox
- for _ in {1..100}; do
- if docker cp archivebox-capture:/cache/trust.pem "$capture_evidence/ca.pem" 2>/dev/null; then
- break
- fi
- test "$(docker inspect --format '{{.State.Running}}' archivebox-capture)" = true
- sleep 0.1
- done
- test -s "$capture_evidence/ca.pem"
- curl --noproxy '' --fail --silent --show-error --max-time 30 --cacert "$capture_evidence/ca.pem" --proxy http://127.0.0.1:18880 -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Dest: document' https://news.ycombinator.com/ask -o /dev/null
for _ in {1..180}; do
- if docker cp archivebox-capture:/cache/hooks.jsonl "$capture_evidence/hooks.jsonl" 2>/dev/null; then
- if jq -e 'select(.event == "finish" and .returncode == 0)' "$capture_evidence/hooks.jsonl" >/dev/null; then
+ if docker compose cp proxy:/cache/proxy/hooks.jsonl /tmp/hooks.jsonl 2>/dev/null; then
+ if jq -e 'select(.event == "finish" and .returncode == 0)' /tmp/hooks.jsonl >/dev/null; then
break
fi
- if jq -e 'select(.event == "error" or (.event == "finish" and .returncode != 0))' "$capture_evidence/hooks.jsonl" >/dev/null; then
+ if jq -e 'select(.event == "error" or (.event == "finish" and .returncode != 0))' /tmp/hooks.jsonl >/dev/null; then
exit 1
fi
fi
- test "$(docker inspect --format '{{.State.Running}}' archivebox-capture)" = true
sleep 1
done
- jq -e 'select(.event == "finish" and .returncode == 0)' "$capture_evidence/hooks.jsonl" >/dev/null
- docker exec -i archivebox-capture uv run --no-project python - <<'PY'
+ jq -e 'select(.event == "finish" and .returncode == 0)' /tmp/hooks.jsonl >/dev/null
+ docker compose exec -T proxy uv run --no-project python - <<'PYCODE'
import json
from pathlib import Path
- root = Path('/data/archive')
- screenshots = list(root.rglob('screenshot/screenshot.png'))
+ screenshots = list(Path('/data/archive').rglob('screenshot/screenshot.png'))
assert len(screenshots) == 1, screenshots
assert screenshots[0].read_bytes().startswith(b'\x89PNG\r\n\x1a\n')
assert screenshots[0].stat().st_size > 10000
@@ -136,7 +105,13 @@ jobs:
response = json.loads((snapshot / 'headers/headers.json').read_text())
assert response['status'] == 200
assert response['response_headers']['x-archivebox-proxy-cache'] == 'HIT'
- assert (Path('/archivebox') / screenshots[0].relative_to('/data')).is_file()
- assert len(Path('/cache/navigations.jsonl').read_text().splitlines()) == 1
+ assert len(Path('/cache/proxy/navigations.jsonl').read_text().splitlines()) == 1
print('Automatic ArchiveBox capture saved screenshot, title, and cache HIT headers.')
- PY
+ PYCODE
+ curl --fail --silent --show-error http://localhost:18800/health/ | grep -qx OK
+ - name: Show logs and stop the deployment
+ if: always()
+ run: |
+ docker compose logs
+ docker compose exec -T proxy cat /cache/proxy/hooks.log || true
+ docker compose down --volumes
diff --git a/.gitignore b/.gitignore
index 779c56a..827d143 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
-y-forums
-w-github
/target/
+/dist/
+/src/archivebox_proxy/engine/archivebox-proxy-engine
/.venv/
/data/
__pycache__/
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 04414a4..0000000
--- a/Dockerfile
+++ /dev/null
@@ -1,73 +0,0 @@
-# syntax=docker/dockerfile:1
-ARG ARCHIVEBOX_IMAGE=archivebox/archivebox:dev
-FROM ghcr.io/astral-sh/uv:0.11.29 AS uv
-FROM rust:1.99.1-bookworm AS engine
-COPY --from=uv /uv /usr/local/bin/uv
-RUN apt-get update && apt-get install -y --no-install-recommends \
- clang cmake libclang-dev pkg-config && rm -rf /var/lib/apt/lists/*
-WORKDIR /build
-COPY Cargo.toml Cargo.lock rust-toolchain.toml ./
-COPY src ./src
-COPY bin ./bin
-COPY patches ./patches
-# Cargo.lock and the manifest pin the Proxelar revision, including its QUIC stack.
-RUN uv run --no-project --python 3.13 python bin/build_engine.py --locked --release
-COPY pyproject.toml uv.lock hatch_build.py LICENSE README.md ./
-COPY archivebox_proxy ./archivebox_proxy
-# Install the same self-contained platform wheel used by native installations.
-# Reuse this stage's compiled engine rather than building it a second time.
-# Constraints retain the tested lockfile versions when installing that wheel.
-RUN PROXY_ENGINE=/build/target/release/archivebox-proxy-engine uv build --wheel --out-dir /wheels && \
- uv export --locked --no-dev --no-emit-project --output-file /wheels/constraints.txt
-
-FROM python:3.13-slim-bookworm AS proxy
-COPY --from=uv /uv /usr/local/bin/uv
-RUN apt-get update && apt-get install -y --no-install-recommends \
- ca-certificates dumb-init libstdc++6 && rm -rf /var/lib/apt/lists/*
-RUN groupadd --gid 911 archivebox && \
- useradd --system --uid 911 --gid 911 --create-home --home-dir /home/archivebox archivebox && \
- mkdir /cache && chown archivebox:archivebox /cache
-WORKDIR /app
-RUN --mount=type=bind,from=engine,source=/wheels,target=/wheels \
- uv pip install --system --no-cache --constraints /wheels/constraints.txt /wheels/*.whl
-COPY LICENSE patches/Proxelar.LICENSE-MIT /usr/share/licenses/archivebox-proxy/
-ENV HOME=/home/archivebox \
- PYTHONUNBUFFERED=1 \
- PROXY_DATA=/cache
-EXPOSE 8080/tcp 8080/udp 8082/tcp
-VOLUME ["/cache"]
-STOPSIGNAL SIGTERM
-# Match the official ArchiveBox image's owner so capture hooks can read the
-# private CA and trust bundle without opening the cache to other users.
-USER 911:911
-ENTRYPOINT ["dumb-init", "--", "archivebox-proxy"]
-CMD ["--bind", "0.0.0.0", "--port", "8080", "--worker-bind", "0.0.0.0", "--worker-port", "8082"]
-
-# Reuse ArchiveBox's tested browser/plugin runtime instead of maintaining a
-# second list of capture binaries here. Its CLI alone writes /data; replay
-# reads the separately mounted read-only /archivebox view of that collection.
-FROM ${ARCHIVEBOX_IMAGE} AS with-archivebox
-USER root
-WORKDIR /opt/archivebox-proxy
-# Keep root's build cache separate from the upstream image's runtime uv cache,
-# which ArchiveBox needs to write as UID 911 when capture hooks run.
-# Expose the installed CLI for compose exec without changing ArchiveBox's Python PATH.
-RUN --mount=type=bind,from=engine,source=/wheels,target=/wheels \
- env -u VIRTUAL_ENV UV_CACHE_DIR=/tmp/proxy-uv-cache uv venv --python /venv/bin/python3 /opt/archivebox-proxy/venv && \
- UV_CACHE_DIR=/tmp/proxy-uv-cache uv pip install --python /opt/archivebox-proxy/venv/bin/python --no-cache --constraints /wheels/constraints.txt /wheels/*.whl && \
- rm -rf /tmp/proxy-uv-cache && \
- ln -s /opt/archivebox-proxy/venv/bin/archivebox-proxy /usr/local/bin/archivebox-proxy && \
- install -d -o 911 -g 911 /cache
-COPY LICENSE patches/Proxelar.LICENSE-MIT /usr/share/licenses/archivebox-proxy/
-WORKDIR /data
-ENV PROXY_DATA=/cache
-EXPOSE 8080/tcp 8080/udp 8082/tcp
-VOLUME ["/cache"]
-HEALTHCHECK NONE
-STOPSIGNAL SIGTERM
-USER 911:911
-ENTRYPOINT ["dumb-init", "--", "archivebox-proxy"]
-CMD ["--bind", "0.0.0.0", "--port", "8080", "--worker-bind", "0.0.0.0", "--worker-port", "8082"]
-
-# Keep the default image independent of the optional ArchiveBox installation.
-FROM proxy AS runtime
diff --git a/README.md b/README.md
index 3de96ce..fcddbac 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-

+

# ArchiveBox Proxy
@@ -12,12 +12,12 @@
CLI & configuration
-[](https://github.com/ArchiveBox/archivebox-proxy/actions/workflows/test.yml)
-[](https://github.com/ArchiveBox/archivebox-proxy/blob/master/LICENSE)
+[](https://github.com/ArchiveBox/archivebox-proxy/actions/workflows/test.yml)
+[](https://github.com/ArchiveBox/archivebox-proxy/blob/main/LICENSE)
-
+
## Installation
@@ -46,7 +46,7 @@ For authenticated pages, add `--persona NAME` to use the same saved session as y
Docker Compose
-[Download this repository](https://github.com/ArchiveBox/archivebox-proxy/archive/refs/heads/master.zip) and run `docker compose up -d --build`. Look for **ArchiveBox Proxy is ready** in `docker compose logs`.
+[Download this repository](https://github.com/ArchiveBox/archivebox-proxy/archive/refs/heads/main.zip) and run `docker compose up -d --build`. Look for **ArchiveBox Proxy is ready** in `docker compose logs`.
Export its certificate and trust it on your computer:
@@ -55,7 +55,7 @@ docker compose exec -T proxy archivebox-proxy --export-ca > proxelar-ca.pem
archivebox-proxy --install-ca proxelar-ca.pem
```
-To include ArchiveBox, set `ARCHIVEBOX_DATA` to your initialized collection and use the [capture configuration](https://github.com/ArchiveBox/archivebox-proxy/blob/master/docker-compose.capture.yml). It uses **`archivebox/archivebox:dev`**. The [archive configuration](https://github.com/ArchiveBox/archivebox-proxy/blob/master/docker-compose.archive.yml) mounts an existing collection for replay.
+The included `docker-compose.yml` starts both **ArchiveBox Proxy** and **`archivebox/archivebox:dev`**. Open **[archivebox.localhost:8000](http://archivebox.localhost:8000)** to browse your snapshots. Your collection is saved in **`~/archivebox/data`**; set `ARCHIVEBOX_DATA` to use another location.
@@ -63,7 +63,7 @@ To include ArchiveBox, set `ARCHIVEBOX_DATA` to your initialized collection and
On macOS, open **System Settings → Wi-Fi → Details → Proxies**. Enable **SOCKS proxy**, enter **127.0.0.1**, port **8080**, and click **OK**. Chrome uses these settings automatically.
-
+
Browse normally. With `--archivebox`, your visits also become ArchiveBox snapshots.
@@ -125,4 +125,4 @@ Use `--hook` to run your own command when you visit a page. See `archivebox-prox
-[MIT](https://github.com/ArchiveBox/archivebox-proxy/blob/master/LICENSE). Powered by [Proxelar](https://github.com/emanuele-em/proxelar) and [ArchiveBox](https://github.com/ArchiveBox/ArchiveBox).
+[MIT](https://github.com/ArchiveBox/archivebox-proxy/blob/main/LICENSE). Powered by [Proxelar](https://github.com/emanuele-em/proxelar) and [ArchiveBox](https://github.com/ArchiveBox/ArchiveBox).
diff --git a/archivebox-proxy.service b/archivebox-proxy.service
deleted file mode 100644
index b0fc09c..0000000
--- a/archivebox-proxy.service
+++ /dev/null
@@ -1,20 +0,0 @@
-[Unit]
-Description=ArchiveBox caching proxy
-After=network-online.target
-Wants=network-online.target
-
-[Service]
-Type=simple
-DynamicUser=yes
-StateDirectory=archivebox-proxy
-StateDirectoryMode=0700
-WorkingDirectory=/var/lib/archivebox-proxy
-# Listener addresses default to loopback; remote access needs an explicit PROXY_BIND.
-ExecStart=/opt/archivebox-proxy/.venv/bin/archivebox-proxy --data /var/lib/archivebox-proxy
-Restart=on-failure
-RestartSec=5s
-KillSignal=SIGTERM
-TimeoutStopSec=30s
-
-[Install]
-WantedBy=multi-user.target
diff --git a/bin/build_engine.py b/bin/build_engine.py
index 13ffaf9..c904795 100755
--- a/bin/build_engine.py
+++ b/bin/build_engine.py
@@ -12,12 +12,14 @@
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
+ENGINE = ROOT / "src/archivebox_proxy/engine"
+TOOLCHAIN = "1.99.1"
REVISION = "91bf33d21c6ff6daa984979310e9b54795f70e4c"
REPOSITORY = "https://github.com/emanuele-em/proxelar"
def source():
- patches = sorted((ROOT / "patches").glob("*.patch"))
+ patches = sorted((ENGINE / "patches").glob("*.patch"))
digest = hashlib.sha256(b"".join(p.read_bytes() for p in patches)).hexdigest()[:16]
cache = Path(os.environ.get("XDG_CACHE_HOME", Path.home() / ".cache"))
cache = cache / "archivebox-proxy" / "proxelar"
@@ -57,17 +59,53 @@ def main():
parser.add_argument("--release", action="store_true")
parser.add_argument("--locked", action="store_true")
parser.add_argument("--clippy", action="store_true")
+ parser.add_argument(
+ "--fmt", action="store_true", help="Check native source formatting"
+ )
args = parser.parse_args()
- directory = source()
- # Honor rust-toolchain.toml even on hosts exporting an unrelated RUSTC.
+ # Pin native build tools here, without a root toolchain file affecting
+ # ordinary Python development or the rest of a shared workspace.
+ installed = subprocess.run(
+ ["rustup", "which", "--toolchain", TOOLCHAIN, "cargo"],
+ check=False,
+ capture_output=True,
+ text=True,
+ )
+ if installed.returncode:
+ subprocess.run(
+ ["rustup", "toolchain", "install", TOOLCHAIN, "--profile", "minimal"],
+ check=True,
+ )
+ if args.fmt or args.clippy:
+ subprocess.run(
+ [
+ "rustup",
+ "component",
+ "add",
+ "--toolchain",
+ TOOLCHAIN,
+ "rustfmt" if args.fmt else "clippy",
+ ],
+ check=True,
+ )
env = os.environ.copy()
+ env["RUSTUP_TOOLCHAIN"] = TOOLCHAIN
+ # Cargo runs inside the nested crate. Preserve a caller's relative target
+ # directory instead of accidentally creating build files in package source.
+ env["CARGO_TARGET_DIR"] = str(
+ Path(env.get("CARGO_TARGET_DIR", ROOT / "target")).expanduser().resolve()
+ )
env["RUSTC"] = subprocess.check_output(
- ["rustup", "which", "rustc"], cwd=ROOT, text=True
+ ["rustup", "which", "--toolchain", TOOLCHAIN, "rustc"], text=True
).strip()
cargo = subprocess.check_output(
- ["rustup", "which", "cargo"], cwd=ROOT, text=True
+ ["rustup", "which", "--toolchain", TOOLCHAIN, "cargo"], text=True
).strip()
env["PATH"] = str(Path(cargo).parent) + os.pathsep + env.get("PATH", "")
+ if args.fmt:
+ subprocess.run([cargo, "fmt", "--check"], cwd=ENGINE, env=env, check=True)
+ return
+ directory = source()
command = [cargo, "clippy" if args.clippy else "build"]
for package in ("proxyapi", "proxyapi_models", "proxelar-proto"):
command += [
@@ -80,7 +118,7 @@ def main():
command.append("--release")
if args.clippy:
command += ["--all-targets", "--", "-D", "warnings"]
- subprocess.run(command, cwd=ROOT, env=env, check=True)
+ subprocess.run(command, cwd=ENGINE, env=env, check=True)
if __name__ == "__main__":
diff --git a/bin/build_wheel.py b/bin/build_wheel.py
new file mode 100644
index 0000000..9a0586b
--- /dev/null
+++ b/bin/build_wheel.py
@@ -0,0 +1,114 @@
+"""Prepare the native executable, build with uv, and pack a platform wheel."""
+
+import argparse
+import os
+import platform
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[1]
+
+
+def platform_tag(engine):
+ machine = platform.machine().lower()
+ if sys.platform == "linux" and machine in ("aarch64", "x86_64"):
+ return f"linux_{machine}"
+ if sys.platform == "darwin" and machine in ("arm64", "x86_64"):
+ # Read the binary's minimum OS, not the builder's newer macOS version.
+ metadata = subprocess.check_output(["otool", "-l", str(engine)], text=True)
+ versions = re.findall(r"\bminos\s+(\d+)\.(\d+)", metadata)
+ versions += re.findall(
+ r"cmd LC_VERSION_MIN_MACOSX\s+cmdsize \d+\s+version (\d+)\.(\d+)", metadata
+ )
+ if not versions:
+ raise RuntimeError("Cannot determine the bundled engine's macOS minimum")
+ major, minor = max((int(a), int(b)) for a, b in versions)
+ return f"macosx_{major}_{minor}_{machine}"
+ raise RuntimeError(f"Unsupported wheel build platform: {sys.platform}/{machine}")
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument(
+ "--engine", type=Path, help="Use an already built native executable"
+ )
+ parser.add_argument("--out-dir", type=Path, default=ROOT / "dist")
+ args = parser.parse_args()
+ if args.engine:
+ engine = args.engine.expanduser().resolve()
+ else:
+ env = os.environ.copy()
+ env.setdefault("MACOSX_DEPLOYMENT_TARGET", "11.0")
+ target = Path(env.get("CARGO_TARGET_DIR", ROOT / "target/wheel")).resolve()
+ env["CARGO_TARGET_DIR"] = str(target)
+ subprocess.run(
+ [
+ sys.executable,
+ str(ROOT / "bin/build_engine.py"),
+ "--locked",
+ "--release",
+ ],
+ env=env,
+ check=True,
+ )
+ engine = target / "release/archivebox-proxy-engine"
+ if not engine.is_file() or not os.access(engine, os.X_OK):
+ raise RuntimeError(f"Native engine is missing or not executable: {engine}")
+ subprocess.run([str(engine), "--help"], check=True, capture_output=True)
+ tag = f"py3-none-{platform_tag(engine)}"
+ destination = args.out_dir.resolve()
+ destination.mkdir(parents=True, exist_ok=True)
+
+ # uv_build deliberately has no native compilation hooks or platform tags.
+ # Stage the executable without modifying the source checkout, then use the
+ # standard wheel tools to write platlib metadata and regenerate RECORD.
+ # The intermediate any wheel stays temporary and is never distributed.
+ with tempfile.TemporaryDirectory(
+ prefix="archivebox-proxy-wheel-build-"
+ ) as temporary:
+ stage = Path(temporary) / "source"
+ stage.mkdir()
+ for name in ("pyproject.toml", "README.md", "LICENSE"):
+ shutil.copy2(ROOT / name, stage / name)
+ package = stage / "src/archivebox_proxy"
+ shutil.copytree(
+ ROOT / "src/archivebox_proxy",
+ package,
+ ignore=shutil.ignore_patterns("__pycache__", "*.pyc"),
+ )
+ shutil.copy2(engine, package / "engine/archivebox-proxy-engine")
+ intermediate = Path(temporary) / "built"
+ subprocess.run(
+ ["uv", "build", "--wheel", "--out-dir", str(intermediate), str(stage)],
+ check=True,
+ )
+ wheel = next(intermediate.glob("*.whl"))
+ unpacked = Path(temporary) / "unpacked"
+ wheel_command = ["uvx", "--from", "wheel==0.48.0", "wheel"]
+ subprocess.run(
+ [*wheel_command, "unpack", str(wheel), "--dest", str(unpacked)], check=True
+ )
+ directory = next(unpacked.iterdir())
+ metadata = next(directory.glob("*.dist-info/WHEEL"))
+ text = metadata.read_text()
+ if "Root-Is-Purelib: true" not in text or "Tag: py3-none-any" not in text:
+ raise RuntimeError(
+ "Unexpected uv wheel metadata; refusing to mislabel the binary"
+ )
+ metadata.write_text(
+ text.replace("Root-Is-Purelib: true", "Root-Is-Purelib: false").replace(
+ "Tag: py3-none-any", "Tag: " + tag
+ )
+ )
+ subprocess.run(
+ [*wheel_command, "pack", str(directory), "--dest-dir", str(destination)],
+ check=True,
+ )
+
+
+if __name__ == "__main__":
+ main()
diff --git a/bin/test_wheel.py b/bin/test_wheel.py
index d26ba9c..b18ea7b 100644
--- a/bin/test_wheel.py
+++ b/bin/test_wheel.py
@@ -36,7 +36,7 @@ def main():
parser.add_argument("--install-ca", action="store_true")
options = parser.parse_args()
package = Path(archivebox_proxy.__file__).resolve().parent
- engine = package / "bin/archivebox-proxy-engine"
+ engine = package / "engine/archivebox-proxy-engine"
assert engine.is_file() and os.access(engine, os.X_OK), engine
subprocess.run([str(engine), "--help"], check=True, capture_output=True)
cli = shutil.which("archivebox-proxy")
diff --git a/docker-compose.archive.yml b/docker-compose.archive.yml
deleted file mode 100644
index 131ef30..0000000
--- a/docker-compose.archive.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-# docker compose -f docker-compose.yml -f docker-compose.archive.yml up --build
-# The archive is an optional read-only fallback, independent of proxy-cache.
-services:
- proxy:
- environment:
- PROXY_ARCHIVE: /archivebox
- volumes:
- - type: bind
- source: ${ARCHIVEBOX_DATA:?Set ARCHIVEBOX_DATA to the existing ArchiveBox collection}
- target: /archivebox
- read_only: true
- bind:
- create_host_path: false
diff --git a/docker-compose.capture.yml b/docker-compose.capture.yml
deleted file mode 100644
index 806d963..0000000
--- a/docker-compose.capture.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-# docker compose -f docker-compose.yml -f docker-compose.capture.yml up --build
-services:
- proxy:
- build:
- target: with-archivebox
- args:
- ARCHIVEBOX_IMAGE: ${ARCHIVEBOX_IMAGE:-archivebox/archivebox:dev}
- image: archivebox-proxy:with-archivebox
- environment:
- ARCHIVEBOX_DATA: /data
- PROXY_ARCHIVE: /archivebox
- PROXY_PERSONA: "${PROXY_PERSONA:-}"
- volumes:
- # The normal CLI writes /data and replay reads /archivebox. Both processes
- # share this container and UID, so these paths are not a security boundary.
- - type: bind
- source: ${ARCHIVEBOX_DATA:?Set ARCHIVEBOX_DATA to the initialized ArchiveBox collection}
- target: /data
- bind:
- create_host_path: false
- - type: bind
- source: ${ARCHIVEBOX_DATA:?Set ARCHIVEBOX_DATA to the initialized ArchiveBox collection}
- target: /archivebox
- read_only: true
- bind:
- create_host_path: false
diff --git a/docker-compose.yml b/docker-compose.yml
index d937392..45c0074 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,25 +1,77 @@
+# Both services use the same ArchiveBox runtime and packaged proxy executable.
+x-archivebox: &archivebox
+ image: archivebox-proxy:local
+ build:
+ context: .
+ dockerfile_inline: |
+ # syntax=docker/dockerfile:1
+ ARG ARCHIVEBOX_IMAGE=archivebox/archivebox:dev
+ FROM ghcr.io/astral-sh/uv:0.11.29 AS uv
+ FROM rust:bookworm AS build
+ COPY --from=uv /uv /uvx /usr/local/bin/
+ RUN apt-get update && apt-get install -y --no-install-recommends clang cmake libclang-dev pkg-config && rm -rf /var/lib/apt/lists/*
+ WORKDIR /build
+ COPY src ./src
+ COPY bin ./bin
+ COPY pyproject.toml uv.lock LICENSE README.md ./
+ # Reuse compiled dependencies across Python edits, and install the exact
+ # runtime dependency versions tested by the repository lockfile.
+ RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/usr/local/cargo/registry --mount=type=cache,target=/root/.cache \
+ uv run --no-project --python 3.13 python bin/build_engine.py --locked --release && \
+ uv run --no-project --python 3.13 python bin/build_wheel.py --engine /build/target/release/archivebox-proxy-engine --out-dir /wheels && \
+ uv export --locked --no-dev --no-emit-project --output-file /wheels/constraints.txt
+ FROM $${ARCHIVEBOX_IMAGE}
+ USER root
+ WORKDIR /opt/archivebox-proxy
+ RUN --mount=type=bind,from=build,source=/wheels,target=/wheels \
+ env -u VIRTUAL_ENV UV_CACHE_DIR=/tmp/proxy-uv-cache uv venv --python /venv/bin/python3 /opt/archivebox-proxy/venv && \
+ UV_CACHE_DIR=/tmp/proxy-uv-cache uv pip install --python /opt/archivebox-proxy/venv/bin/python --no-cache --constraints /wheels/constraints.txt /wheels/*.whl && \
+ rm -rf /tmp/proxy-uv-cache && \
+ ln -s /opt/archivebox-proxy/venv/bin/archivebox-proxy /usr/local/bin/archivebox-proxy && \
+ install -d -m 1777 /cache
+ COPY LICENSE src/archivebox_proxy/engine/patches/Proxelar.LICENSE-MIT /usr/share/licenses/archivebox-proxy/
+ # The official entrypoint matches the collection's owner. A sticky volume
+ # parent lets that user create its private cache without forcing UID 911.
+ ENV PROXY_DATA=/cache/proxy
+ WORKDIR /data
+ restart: unless-stopped
+ shm_size: 1gb
+ volumes:
+ - ${ARCHIVEBOX_DATA:-${HOME}/archivebox/data}:/data
+ - proxy-cache:/cache
+ - tmp:/tmp/archivebox
+ environment: &environment
+ # Optional ArchiveBox settings apply to both the web server's workers and
+ # the proxy's normal archivebox add subprocesses.
+ PUID:
+ PGID:
+ PLUGINS:
+ CHROME_ARGS_EXTRA:
+ ARCHIVEDOTORG_ENABLED:
+ ADMIN_USERNAME:
+ ADMIN_PASSWORD:
+ PUBLIC_INDEX:
+ PUBLIC_SNAPSHOTS:
+ PUBLIC_ADD_VIEW:
+ BASE_URL: "${BASE_URL:-http://archivebox.localhost:${ARCHIVEBOX_PORT:-8000}}"
+ SERVER_SECURITY_MODE:
+ stop_grace_period: 30s
+
services:
proxy:
- build:
- context: .
- target: runtime
- image: archivebox-proxy:local
- restart: unless-stopped
- # Published host addresses are separate from these container listeners.
+ <<: *archivebox
command:
- - --bind
- - 0.0.0.0
- - --port
- - "8080"
- - --worker-bind
- - 0.0.0.0
- - --worker-port
- - "8082"
+ - /bin/sh
+ - -ec
+ - |
+ if [ ! -f /data/index.sqlite3 ]; then archivebox init; fi
+ exec archivebox-proxy --bind 0.0.0.0 --port 8080 --worker-bind 0.0.0.0 --worker-port 8082 --worker-proxy http://proxy:8082 --archivebox /data
environment:
+ <<: *environment
PROXY_RECORD: "${PROXY_RECORD:-true}"
PROXY_CACHE: "${PROXY_CACHE:-true}"
PROXY_REPLAY: "${PROXY_REPLAY:-true}"
- PROXY_MODE: "${PROXY_MODE:-forward}"
+ PROXY_MODE: "${PROXY_MODE:-socks5}"
PROXY_TARGET: "${PROXY_TARGET:-}"
PROXY_WIREGUARD_ENDPOINT: "${PROXY_WIREGUARD_ENDPOINT:-${WIREGUARD_ENDPOINT:-}}"
PROXY_DNS_UPSTREAM: "${PROXY_DNS_UPSTREAM:-1.1.1.1:53}"
@@ -27,13 +79,44 @@ services:
PROXY_CACHE_GB: "${PROXY_CACHE_GB:-50}"
PROXY_BODY_LIMIT: "${PROXY_BODY_LIMIT:-67108864}"
PROXY_HOOK: "${PROXY_HOOK:-}"
+ PROXY_PERSONA: "${PROXY_PERSONA:-}"
ports:
- "${PROXY_BIND:-127.0.0.1}:${PROXY_PORT:-8080}:8080/tcp"
- "${PROXY_BIND:-127.0.0.1}:${PROXY_PORT:-8080}:8080/udp"
- "127.0.0.1:${PROXY_WORKER_PORT:-8082}:8082/tcp"
- volumes:
- - proxy-cache:/cache
- stop_grace_period: 30s
+ healthcheck:
+ # The server starts only after initialization, CA creation and the actual
+ # HTTP capture listener is ready; an old certificate alone does not prove readiness.
+ test: ["CMD", "/opt/archivebox-proxy/venv/bin/python", "-c", "import socket; from pathlib import Path; assert Path('/cache/proxy/trust.pem').is_file(); socket.create_connection(('127.0.0.1', 8082), 2).close()"]
+ interval: 10s
+ timeout: 5s
+ start_period: 60s
+ start_interval: 1s
+ retries: 3
+
+ archivebox:
+ <<: *archivebox
+ depends_on:
+ proxy:
+ condition: service_healthy
+ # The web server can also schedule captures. Reuse the same environment
+ # builder as proxy hooks so every worker receives identical CA/proxy trust.
+ command:
+ - /opt/archivebox-proxy/venv/bin/python
+ - -c
+ - |
+ import asyncio, os
+ from pathlib import Path
+ from archivebox_proxy.cli import hook_environment, chrome_environment
+ directory = Path(os.environ['PROXY_DATA'])
+ ca = directory / 'ca'
+ proxy = 'http://proxy:8082'
+ env = hook_environment(directory, ca, proxy)
+ asyncio.run(chrome_environment(env, ca, proxy))
+ os.execvpe('archivebox', ['archivebox', 'server', '--init', '0.0.0.0:5797'], env)
+ ports:
+ - "127.0.0.1:${ARCHIVEBOX_PORT:-8000}:5797"
volumes:
proxy-cache:
+ tmp:
diff --git a/docs/images/archive.png b/docs/images/archive.png
deleted file mode 100644
index 898abdd..0000000
Binary files a/docs/images/archive.png and /dev/null differ
diff --git a/docs/images/archivebox-likes.png b/docs/images/archivebox-likes.png
deleted file mode 100644
index 020be28..0000000
Binary files a/docs/images/archivebox-likes.png and /dev/null differ
diff --git a/docs/images/cli.jpg b/docs/images/cli.jpg
deleted file mode 100644
index 0372d5d..0000000
Binary files a/docs/images/cli.jpg and /dev/null differ
diff --git a/docs/images/macos-socks-proxy.jpg b/docs/images/macos-socks-proxy.jpg
deleted file mode 100644
index 0ccc317..0000000
Binary files a/docs/images/macos-socks-proxy.jpg and /dev/null differ
diff --git a/docs/images/overview.svg b/docs/images/overview.svg
deleted file mode 100644
index 34a19ff..0000000
--- a/docs/images/overview.svg
+++ /dev/null
@@ -1,64 +0,0 @@
-
\ No newline at end of file
diff --git a/docs/images/proxy-logs.png b/docs/images/proxy-logs.png
deleted file mode 100644
index 23df99a..0000000
Binary files a/docs/images/proxy-logs.png and /dev/null differ
diff --git a/docs/images/visitor-likes.png b/docs/images/visitor-likes.png
deleted file mode 100644
index 55ee9a2..0000000
Binary files a/docs/images/visitor-likes.png and /dev/null differ
diff --git a/hatch_build.py b/hatch_build.py
deleted file mode 100644
index 260d55a..0000000
--- a/hatch_build.py
+++ /dev/null
@@ -1,82 +0,0 @@
-"""Include the native transport in platform wheels; installation only unpacks it."""
-
-import os
-import platform
-import re
-import subprocess
-import sys
-from pathlib import Path
-
-from hatchling.builders.hooks.plugin.interface import BuildHookInterface
-
-
-class CustomBuildHook(BuildHookInterface):
- def initialize(self, version, build_data):
- if version == "editable":
- return
- machine = platform.machine().lower()
- if sys.platform == "darwin" and machine in ("arm64", "x86_64"):
- system = "macos"
- elif sys.platform == "linux" and machine in ("aarch64", "x86_64"):
- system = "linux"
- else:
- raise RuntimeError(
- f"Unsupported wheel build platform: {sys.platform}/{machine}"
- )
-
- root = Path(self.root)
- supplied = os.environ.get("PROXY_ENGINE")
- if supplied:
- # Docker already builds the same pinned engine in its native stage.
- # An explicit path reuses that artifact without a second compilation.
- engine = Path(supplied).expanduser().resolve()
- else:
- env = os.environ.copy()
- if system == "macos":
- env.setdefault("MACOSX_DEPLOYMENT_TARGET", "11.0")
- # Keep wheel builds separate from developer builds with different
- # deployment targets, so older cached objects cannot inflate the ABI.
- target = Path(
- env.get("CARGO_TARGET_DIR", root / "target" / "wheel")
- ).resolve()
- env["CARGO_TARGET_DIR"] = str(target)
- subprocess.run(
- [
- sys.executable,
- str(root / "bin/build_engine.py"),
- "--locked",
- "--release",
- ],
- cwd=root,
- env=env,
- check=True,
- )
- engine = target / "release" / "archivebox-proxy-engine"
- if not engine.is_file() or not os.access(engine, os.X_OK):
- raise RuntimeError(f"Native engine is missing or not executable: {engine}")
- subprocess.run([str(engine), "--help"], check=True, capture_output=True)
-
- if system == "macos":
- # Tag the actual Mach-O minimum rather than the builder's OS version.
- # This also handles an explicitly supplied binary honestly.
- metadata = subprocess.check_output(["otool", "-l", str(engine)], text=True)
- versions = re.findall(r"\bminos\s+(\d+)\.(\d+)", metadata)
- versions += re.findall(
- r"cmd LC_VERSION_MIN_MACOSX\s+cmdsize \d+\s+version (\d+)\.(\d+)",
- metadata,
- )
- if not versions:
- raise RuntimeError(
- "Cannot determine the bundled engine's macOS minimum"
- )
- major, minor = max((int(a), int(b)) for a, b in versions)
- platform_tag = f"macosx_{major}_{minor}_{machine}"
- else:
- # Linux release jobs audit/repair this native tag in manylinux before
- # publishing; no Python C ABI is involved in this executable.
- platform_tag = f"linux_{machine}"
- build_data["pure_python"] = False
- build_data["tag"] = f"py3-none-{platform_tag}"
- build_data["force_include"][str(engine)] = (
- "archivebox_proxy/bin/archivebox-proxy-engine"
- )
diff --git a/pyproject.toml b/pyproject.toml
index 396fee9..ab71092 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ version = "0.1.0"
description = "Caching proxy with automatic ArchiveBox captures and archive replay"
readme = "README.md"
license = "MIT"
-license-files = ["LICENSE", "patches/Proxelar.LICENSE-MIT"]
+license-files = ["LICENSE", "src/archivebox_proxy/engine/patches/Proxelar.LICENSE-MIT"]
requires-python = ">=3.11"
dependencies = [
"aiohttp>=3.12,<4",
@@ -22,21 +22,14 @@ Issues = "https://github.com/ArchiveBox/archivebox-proxy/issues"
archivebox-proxy = "archivebox_proxy.cli:main"
[build-system]
-requires = ["hatchling>=1.27,<2"]
-build-backend = "hatchling.build"
+requires = ["uv_build>=0.11.29,<0.12"]
+build-backend = "uv_build"
-[tool.hatch.build.targets.wheel]
-packages = ["archivebox_proxy"]
-
-[tool.hatch.build.targets.wheel.hooks.custom]
-path = "hatch_build.py"
-
-[tool.hatch.build.targets.sdist]
-include = [
- "/archivebox_proxy", "/bin/build_engine.py", "/bin/test_wheel.py", "/hatch_build.py",
- "/src", "/patches", "/Cargo.toml", "/Cargo.lock",
- "/rust-toolchain.toml", "/pyproject.toml", "/uv.lock", "/README.md", "/LICENSE",
-]
+[tool.uv.build-backend]
+source-include = ["bin/**", "uv.lock"]
+# Native sources belong in source distributions; installed wheels only need the
+# prepared executable and its license. bin/build_wheel.py builds platform wheels.
+wheel-exclude = ["*.rs", "Cargo.toml", "Cargo.lock", "*.patch"]
[dependency-groups]
dev = [
@@ -50,19 +43,3 @@ testpaths = ["tests"]
# Anchor Ruff here so parent workspace settings cannot hide standalone CI errors.
[tool.ruff]
-
-[tool.cibuildwheel]
-# The executable has no Python ABI, so one build serves every supported Python.
-build = "cp313-*"
-skip = "*-musllinux_*"
-build-frontend = "build[uv]"
-test-command = "uv run --no-project python {project}/bin/test_wheel.py"
-
-[tool.cibuildwheel.linux]
-manylinux-x86_64-image = "manylinux_2_28"
-manylinux-aarch64-image = "manylinux_2_28"
-before-all = "dnf install -y clang clang-devel cmake git && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.99.1 --profile minimal"
-environment = { PATH = "$HOME/.cargo/bin:$PATH" }
-
-[tool.cibuildwheel.macos]
-environment = { MACOSX_DEPLOYMENT_TARGET = "11.0" }
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
deleted file mode 100644
index 58eef2c..0000000
--- a/rust-toolchain.toml
+++ /dev/null
@@ -1,4 +0,0 @@
-[toolchain]
-channel = "1.99.1"
-profile = "minimal"
-components = ["rustfmt", "clippy"]
diff --git a/archivebox_proxy/__init__.py b/src/archivebox_proxy/__init__.py
similarity index 100%
rename from archivebox_proxy/__init__.py
rename to src/archivebox_proxy/__init__.py
diff --git a/archivebox_proxy/archive.py b/src/archivebox_proxy/archive.py
similarity index 100%
rename from archivebox_proxy/archive.py
rename to src/archivebox_proxy/archive.py
diff --git a/archivebox_proxy/cache.py b/src/archivebox_proxy/cache.py
similarity index 100%
rename from archivebox_proxy/cache.py
rename to src/archivebox_proxy/cache.py
diff --git a/archivebox_proxy/cli.py b/src/archivebox_proxy/cli.py
similarity index 99%
rename from archivebox_proxy/cli.py
rename to src/archivebox_proxy/cli.py
index 4f24380..0aae1b4 100644
--- a/archivebox_proxy/cli.py
+++ b/src/archivebox_proxy/cli.py
@@ -46,14 +46,16 @@ def argv(value):
def default_engine():
- bundled = Path(__file__).resolve().parent / "bin/archivebox-proxy-engine"
+ bundled = Path(__file__).resolve().parent / "engine/archivebox-proxy-engine"
if bundled.is_file():
return str(bundled)
# Editable source checkouts use their local build; installed wheels always
# carry the executable and never download or compile anything at startup.
- source = Path(__file__).resolve().parents[1]
+ source = Path(__file__).resolve().parents[2]
development = source / "target/debug/archivebox-proxy-engine"
- if (source / "Cargo.toml").is_file() and development.is_file():
+ if (
+ source / "src/archivebox_proxy/engine/Cargo.toml"
+ ).is_file() and development.is_file():
return str(development)
# Retain existing source installations that placed their compiled executable
# on PATH, while preferring the matching executable shipped in each wheel.
diff --git a/Cargo.lock b/src/archivebox_proxy/engine/Cargo.lock
similarity index 100%
rename from Cargo.lock
rename to src/archivebox_proxy/engine/Cargo.lock
diff --git a/Cargo.toml b/src/archivebox_proxy/engine/Cargo.toml
similarity index 93%
rename from Cargo.toml
rename to src/archivebox_proxy/engine/Cargo.toml
index c2870ae..044709c 100644
--- a/Cargo.toml
+++ b/src/archivebox_proxy/engine/Cargo.toml
@@ -5,6 +5,10 @@ edition = "2024"
rust-version = "1.99"
license = "MIT"
+[[bin]]
+name = "archivebox-proxy-engine"
+path = "main.rs"
+
[dependencies]
proxyapi = { git = "https://github.com/emanuele-em/proxelar", rev = "91bf33d21c6ff6daa984979310e9b54795f70e4c", features = ["http3"] }
proxyapi_models = { git = "https://github.com/emanuele-em/proxelar", rev = "91bf33d21c6ff6daa984979310e9b54795f70e4c" }
diff --git a/src/main.rs b/src/archivebox_proxy/engine/main.rs
similarity index 100%
rename from src/main.rs
rename to src/archivebox_proxy/engine/main.rs
diff --git a/patches/Proxelar.LICENSE-MIT b/src/archivebox_proxy/engine/patches/Proxelar.LICENSE-MIT
similarity index 100%
rename from patches/Proxelar.LICENSE-MIT
rename to src/archivebox_proxy/engine/patches/Proxelar.LICENSE-MIT
diff --git a/patches/proxelar-capture.patch b/src/archivebox_proxy/engine/patches/proxelar-capture.patch
similarity index 100%
rename from patches/proxelar-capture.patch
rename to src/archivebox_proxy/engine/patches/proxelar-capture.patch
diff --git a/patches/proxelar-replay.patch b/src/archivebox_proxy/engine/patches/proxelar-replay.patch
similarity index 100%
rename from patches/proxelar-replay.patch
rename to src/archivebox_proxy/engine/patches/proxelar-replay.patch
diff --git a/archivebox_proxy/hooks.py b/src/archivebox_proxy/hooks.py
similarity index 100%
rename from archivebox_proxy/hooks.py
rename to src/archivebox_proxy/hooks.py
diff --git a/archivebox_proxy/server.py b/src/archivebox_proxy/server.py
similarity index 100%
rename from archivebox_proxy/server.py
rename to src/archivebox_proxy/server.py
diff --git a/archivebox_proxy/trust.py b/src/archivebox_proxy/trust.py
similarity index 100%
rename from archivebox_proxy/trust.py
rename to src/archivebox_proxy/trust.py