Skip to content

Commit ee1d16d

Browse files
authored
Merge pull request #99 from influxdata/crepererum/bundle-urllib3
feat: bundle `urllib3` with Python guest
2 parents df26b2c + d4bf4b9 commit ee1d16d

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Install [cargo-deny] to check dependencies.
2222
### Just
2323
Install [just] to easily run all the tests/scripts.
2424

25+
### Python
26+
Install [Python] to set up the environment for the [Python] guest.
27+
2528

2629
## Checks
2730
There is one "run everything" [just] recipe:

guests/python/Justfile

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ DOWNLOADS_DIR := source_directory() / "downloads"
1616
export PYO3_CROSS_PYTHON_VERSION := PYTHON_VERSION_MAJOR + "." + PYTHON_VERSION_MINOR
1717
export PYO3_CROSS_LIB_DIR := DOWNLOADS_DIR / "python-sdk"
1818

19+
PYTHON_TMP_VENV := DOWNLOADS_DIR / "venv"
20+
PYTHON_SITE_PACKAGES := PYO3_CROSS_LIB_DIR / "lib" / "python" + PYO3_CROSS_PYTHON_VERSION / "site-packages"
21+
1922
export WASI_SDK_LINK_PATH := DOWNLOADS_DIR / "wasi-sysroot" / "lib" / "wasm32-wasip2"
2023

2124
# download pre-built Python WASM SDK
@@ -33,6 +36,8 @@ download-python-sdk:
3336
# skip if already downloaded
3437
if [ -d python-sdk ]; then
3538
echo "python sdk already present"
39+
set +x
40+
echo ::endgroup::
3641
exit 0
3742
fi
3843

@@ -90,6 +95,8 @@ download-wasi-sdk:
9095
# skip if already downloaded
9196
if [ -d wasi-sysroot ]; then
9297
echo "wasi sdk already present"
98+
set +x
99+
echo ::endgroup::
93100
exit 0
94101
fi
95102

@@ -111,7 +118,34 @@ download-wasi-sdk:
111118
echo ::endgroup::
112119

113120
[private]
114-
build-lib profile: download-python-sdk download-wasi-sdk
121+
python-site-packages: download-python-sdk
122+
#!/usr/bin/env bash
123+
set -euo pipefail
124+
125+
echo ::group::guests::python::python-site-packages
126+
set -x
127+
128+
# skip if already downloaded
129+
if [ -d "{{PYTHON_TMP_VENV}}" ]; then
130+
echo "site-packages already set up"
131+
set +x
132+
echo ::endgroup::
133+
exit 0
134+
fi
135+
136+
python -m venv "{{PYTHON_TMP_VENV}}"
137+
"{{PYTHON_TMP_VENV}}"/bin/pip install \
138+
--disable-pip-version-check \
139+
--ignore-installed \
140+
--isolated \
141+
--requirement=requirements.txt \
142+
--target="{{PYTHON_SITE_PACKAGES}}"
143+
144+
set +x
145+
echo ::endgroup::
146+
147+
[private]
148+
build-lib profile: download-python-sdk download-wasi-sdk python-site-packages
115149
@echo ::group::guests::python::build-lib {{profile}}
116150
cargo build --target=wasm32-wasip2 --profile={{replace(profile, "debug", "dev")}}
117151
@echo ::endgroup::

guests/python/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# That's https://github.com/urllib3/urllib3/pull/3593 as a wheel.
2+
urllib3 @ https://github.com/crepererum/urllib3/releases/download/2.5.100/urllib3-2.5.100-py3-none-any.whl --hash=sha256:b48be99c923c989e8db2a41a21f2511d830a7b7e99bfde24ae7214baadf7daaf

0 commit comments

Comments
 (0)