A global mechanism for injection of Requests transport adapters
Project description
requests-adapter-injector
This package provides a global mechanism for injection of Requests
transport adapters. Injection is done with the help of importhook
library and a .pth
file as described
here.
You may probably want to use this package in a separate venv, where you would install
Python tools using Requests which you want to inject transport adapters into, along with
a package implementing desired adapters to inject. You may want to try pipx tool
to manage venvs for Python-based tools.
With that you would probably do pipx install <target-tool> && pipx inject <target-tool> <adapter-package>
.
This package itself can be tested using the built-in test transport adapter, which can also serve as an example for authors of adapter packages.
$ python -mvenv venv
$ venv/bin/pip install requests-adapter-injector
$ venv/bin/python -c "import requests; r = requests.get('injector-test://some/url'); print(r.json())"
{'method': 'GET', 'url': 'injector-test://some/url', 'headers': {'User-Agent': 'python-requests/2.23.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'}, 'body': None}
Adapter packages have to declare one or more requests_adapter_injector.adapter
entry_points, and are expected
to require this package, to have it installed automatically.
Note: this package will not work when installed as editable install because
src/requests_adapter_injector.pth
is not installed then.
Existing transport adapter packages
None so far and some in planning.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for requests_adapter_injector-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6fe55d30f385a1734b03e264a88cfb26aa53bbd07769d498a6c72d3534db999 |
|
MD5 | 0b8cea0eb19e3464d524b23ea5de6e4e |
|
BLAKE2b-256 | 76e67208f622ce9db584dbb774a084dec5b0ca86c11d11b533999a06f89b6edc |
Hashes for requests_adapter_injector-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c1e085eca6fa6d6a03f5e99ff294f00c4043157b70849df322be28e24d9f6ad |
|
MD5 | f3310df8a46c3b945101fc793617df0f |
|
BLAKE2b-256 | 6b415b1c36bdbc98a60842fb713943bc3feb0d674a5b888da214ce77ed948b50 |