# Missing dependencies for SOCKS support: loopback lab

This download reproduces `Missing dependencies for SOCKS support` in Requests
and pip, the `socksio` `ImportError` in HTTPX, and the `AttributeError` caused
by a local file or folder named `socks`. It backs the guide at
https://ipvolt.com/guides/fix-missing-dependencies-for-socks-support.

Everything listens on `127.0.0.1`. No proxy account is needed. The only
outbound traffic is pip talking to PyPI to install the packages under test.

| Listener | Port | Role |
| --- | --- | --- |
| `python -m http.server` | 18080 | plain HTTP target |
| `socks5_relay.py` | 1080 | SOCKS5 relay without authentication; prints one line per request |
| nothing | 1081, 18081 | closed ports for the connection-refused cases |

## How a case runs

Each case gets:

- a fresh virtual environment with pip upgraded (except the one case that
  keeps the pip bundled with Python), then the packages listed in `setup`;
- a new working directory holding only the files that case names;
- an empty `HOME`, so pip has no cache and no configuration file;
- an environment that contains `PATH`, `HOME`, `LANG` and the variables listed
  for that step, nothing else.

Every step is a shell command, recorded with its exit code, stdout, stderr and
the lines the relay printed while it ran. A failing step with an empty relay
log never reached the SOCKS layer.

Case groups, by `id` prefix:

- `requests-`: the proxy in code, in `ALL_PROXY` / `all_proxy` / `HTTP_PROXY`,
  empty values, upper against lower case, `NO_PROXY`, `trust_env`, the
  `requests[socks]` extra, and `pip` on `PATH` belonging to another
  environment than `python`.
- `shadow-`: a `socks.py` file, a `socks/` package and a `socks/` folder
  without `__init__.py` in the directory Python searches first, with and
  without PySocks installed.
- `pip-`: pip under `all_proxy` / `ALL_PROXY`, clearing the variables for one
  command, and pip through the relay once PySocks is installed.
- `httpx-`: the same questions for HTTPX and socksio.

## Run it

Requirements: Linux or another Unix with `bash`, Python 3.10 or later with the
`venv` module, and network access to PyPI. Ports 1080 and 18080 must be free.

```sh
python3 run_lab.py "$(command -v python3)"
```

Pass more interpreters as extra arguments to repeat every case on each of
them. The runner writes `results.json` next to itself and keeps its
environments under `/var/tmp/socks-lab` (override with `LAB_WORK`), deleting
each one as soon as its case has finished. A full pass takes about four
minutes per interpreter.

## Files

- `run_lab.py`: the case list and the runner.
- `socks5_relay.py`: the SOCKS5 relay. It can be started alone with
  `python3 socks5_relay.py 1080`.
- `results.json`: the run recorded on 5 October 2026 on Ubuntu 26.04.1
  (x86_64).

## Recorded run

- Python 3.13.5 (OpenSSL 3.0.16) and Python 3.14.4 (OpenSSL 3.5.5), 47 cases
  each.
- Requests 2.34.2 with urllib3 2.8.0, PySocks 1.7.1.
- HTTPX 0.28.1 with httpcore 1.0.9, socksio 1.0.0.
- pip 26.2.1, and pip 25.1.1 in `pip-bundled-socks-with-pysocks`.

In `results.json`, the installation prefix of the Python 3.13.5 build is
written as `<python-3.13.5>`. Other paths are the lab's own temporary
directories.

Not covered: macOS and Windows, SOCKS4, authenticated SOCKS proxies, older
releases of Requests and HTTPX, and installers other than pip.
