DSPy: The framework for programming—not prompting—language models
Python
fix(dspy): require patched installers and CA bundles (#10703)
Isaac Miller000b09cd15b0
diff --git a/.github/workflow_scripts/install_testpypi_pkg.sh b/.github/workflow_scripts/install_testpypi_pkg.shindex e8cee27f8..7043004c1 100755--- a/.github/workflow_scripts/install_testpypi_pkg.sh+++ b/.github/workflow_scripts/install_testpypi_pkg.sh@@ -1,4 +1,7 @@#!/bin/bash+set -euo pipefail++bash "$(dirname "$0")/../../scripts/bootstrap_python.sh"# The $1 argument is the version number passed from the workflowVERSION=$1@@ -6,10 +9,10 @@ VERSION=$1echo "version: $VERSION"for i in {1..5}; do- if python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple dspy-ai-test=="$VERSION"; then+ if python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple 'certifi>=2026.10.19' dspy-ai-test=="$VERSION"; thenbreakelseecho "Attempt $i failed. Waiting before retrying..."sleep 10fi-done\ No newline at end of file+donediff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.ymlindex 662ffe0ab..a1c4a13a5 100644--- a/.github/workflows/build_and_release.yml+++ b/.github/workflows/build_and_release.yml@@ -37,7 +37,9 @@ jobs:with:python-version: "3.11"- name: Install dependencies- run: python3 -m pip install --upgrade setuptools wheel twine build semver packaging+ run: |+ bash scripts/bootstrap_python.sh+ python3 -m pip install --upgrade setuptools wheel twine build semver packaging- name: Install Denouses: denoland/setup-deno@22d081ff2d3a40755e97629de92e3bcbfa7cf2ed # v2.0.5with:@@ -68,6 +70,7 @@ jobs:- name: Test package installation and functionalityrun: |source test_before_testpypi/bin/activate+ bash scripts/bootstrap_python.sh# Install the locally built wheel and testing dependenciespip install dist/*.whl pytest pytest-asyncio pytest-mockpytest tests/metadata/test_metadata.py tests/predict@@ -75,7 +78,7 @@ jobs:deactivate# Publish to test-PyPI- name: Publish distribution 📦 to test-PyPI- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1 # This requires a trusted publisher to be setup in pypi/testpypi+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 # This requires a trusted publisher to be setup in pypi/testpypiwith:repository-url: https://test.pypi.org/legacy/@@ -100,7 +103,9 @@ jobs:with:python-version: "3.11"- name: Install dependencies- run: python3 -m pip install --upgrade setuptools wheel twine build+ run: |+ bash scripts/bootstrap_python.sh+ python3 -m pip install --upgrade setuptools wheel twine build- name: Install Denouses: denoland/setup-deno@22d081ff2d3a40755e97629de92e3bcbfa7cf2ed # v2.0.5with:@@ -128,6 +133,7 @@ jobs:- name: Test package installation and functionalityrun: |source test_before_pypi/bin/activate+ bash scripts/bootstrap_python.sh# Install the locally built wheel and testing dependenciespip install dist/*.whl pytest pytest-asyncio pytest-mockpytest tests/metadata/test_metadata.py tests/predict@@ -141,7 +147,7 @@ jobs:path: dist/*.whlif-no-files-found: error- name: Publish distribution 📦 to PyPI (dspy)- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3with:attestations: false# Publish to dspy-ai@@ -160,7 +166,7 @@ jobs:- name: Validate built distributions (dspy-ai)run: python3 -m twine check --strict .github/.internal_dspyai/dist/*- name: Publish distribution 📦 to PyPI (dspy-ai)- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3with:attestations: falsepackages-dir: .github/.internal_dspyai/dist/@@ -199,7 +205,9 @@ jobs:path: release-wheel- name: Install documentation dependencies and release wheelif: steps.publishable.outputs.publish == 'true'- run: python -m pip install -r docs/requirements.txt release-wheel/*.whl+ run: |+ bash scripts/bootstrap_python.sh+ python -m pip install -r docs/requirements.txt release-wheel/*.whl- name: Verify API introspection uses the release wheelif: steps.publishable.outputs.publish == 'true'run: |diff --git a/.github/workflows/dependency-range.yml b/.github/workflows/dependency-range.ymlindex 63d24afae..8c9f48fc1 100644--- a/.github/workflows/dependency-range.yml+++ b/.github/workflows/dependency-range.yml@@ -44,7 +44,6 @@ jobs:- name: Install uvuses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1with:- version: "0.11.2"enable-cache: truecache-dependency-glob: pyproject.tomldiff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.ymlindex 647cdbf89..279580c4a 100644--- a/.github/workflows/docs-push.yml+++ b/.github/workflows/docs-push.yml@@ -31,6 +31,7 @@ jobs:persist-credentials: false- name: Install dependencies and buildrun: |+ bash scripts/bootstrap_python.shpip install -r docs/requirements.txt -e .python docs/scripts/build_docs.py current \--config docs/mkdocs.yml \@@ -56,7 +57,9 @@ jobs:cache: "pip"cache-dependency-path: docs/requirements.txt- name: Install documentation dependencies- run: python -m pip install -r docs/requirements.txt -e .+ run: |+ bash scripts/bootstrap_python.sh+ python -m pip install -r docs/requirements.txt -e .- name: Build Current documentationrun: |python docs/scripts/build_docs.py current \diff --git a/.github/workflows/precommits_check.yml b/.github/workflows/precommits_check.ymlindex e70ba7f94..b8511e014 100644--- a/.github/workflows/precommits_check.yml+++ b/.github/workflows/precommits_check.yml@@ -38,8 +38,8 @@ jobs:env:CHANGED_FILES: ${{ steps.files.outputs.all }}run: |- python -m pip install --upgrade pip- pip install pre-commit+ bash scripts/bootstrap_python.sh+ pip install 'uv>=0.13.4' 'virtualenv>=21.14.12' pre-commitecho "Running pre-commit scans:"# adding log display in case of pre-commit errors# shellcheck disable=SC2086diff --git a/docs/Pipfile b/docs/Pipfileindex a137d190a..697ac824c 100644--- a/docs/Pipfile+++ b/docs/Pipfile@@ -4,6 +4,7 @@ verify_ssl = truename = "pypi"[packages]+certifi = ">=2026.10.19"dspy = {git = "https://github.com/stanfordnlp/dspy.git"}mkdocs-material = "*"mkdocs-jupyter = "*"diff --git a/docs/Pipfile.lock b/docs/Pipfile.lockindex 60417e07c..2a13ab9ba 100644--- a/docs/Pipfile.lock+++ b/docs/Pipfile.lock@@ -1,7 +1,7 @@{"_meta": {"hash": {- "sha256": "5849f8c4dfeca64e52d84e7dbbf62497392fe0ea0a7bf79690371f6de02fe4f0"+ "sha256": "bdf3f2970da58eaf930c0b13a015041baf44357825e745ad8a61ccaa4212506a"},"pipfile-spec": 6,"requires": {@@ -240,11 +240,11 @@},"certifi": {"hashes": [- "sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775",- "sha256:741e2c3b351ddf169a738da9f2c048608ff7f2c5cc02f1ebc6b118bb090d5d55"+ "sha256:035c1e85572b141bf1c3a3eff0e33a8eb74917522f2559075ff8d2fea780a1ae",+ "sha256:42d35340cc5b9ba78e818ddbff0c5b1c2b779de448a340fd1b989f5fa8670e1b"],"markers": "python_version >= '3.7'",- "version": "==2026.7.22"+ "version": "==2026.10.19"},"cffi": {"hashes": [diff --git a/docs/requirements.txt b/docs/requirements.txtindex 948bc167c..77f9907fe 100644--- a/docs/requirements.txt+++ b/docs/requirements.txt@@ -1,4 +1,5 @@beautifulsoup4==4.15.0+certifi>=2026.10.19markdownify==1.2.3mdformat==0.7.22mdformat-tables==1.0.0diff --git a/docs/vercel.json b/docs/vercel.jsonindex 9cad5af98..9b19f47e7 100644--- a/docs/vercel.json+++ b/docs/vercel.json@@ -1,6 +1,6 @@{"framework": null,- "installCommand": "uv venv && uv pip install -r requirements.txt",+ "installCommand": "bash ../scripts/bootstrap_python.sh && python -m pip install --upgrade 'uv>=0.13.4' && python -m uv venv && python -m uv pip install --python .venv/bin/python -r requirements.txt","buildCommand": ".venv/bin/mkdocs build","outputDirectory": "site","trailingSlash": true,diff --git a/pyproject.toml b/pyproject.tomlindex 0db231fed..f98c381e4 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -26,6 +26,7 @@ dependencies = ["orjson>=3.9.0","tqdm>=4.66.1","requests>=2.31.0",+ "certifi>=2026.10.19", # distrust the compromised emSign CA"pydantic>=2.11.0","pyyaml>=6.0.1",# litellm and gepa declare requires-python <3.15, so pip cannot install them on 3.15.@@ -58,6 +59,7 @@ dev = ["ruff>=0.3.0","ty==0.0.89","pre-commit>=3.7.0",+ "virtualenv>=21.14.12", # seed pre-commit environments with pip>=26.2.2"pillow>=10.1.0","datamodel_code_generator>=0.26.3","build>=1.0.3",@@ -82,6 +84,10 @@ dev = ["dspy-interpreters @ git+https://github.com/cmpnd-ai/dspy-interpreters",]+[tool.uv]+# Also used by setup-uv when selecting the CI installer.+required-version = ">=0.13.4"+[tool.setuptools.packages.find]where = ["."]include = ["dspy", "dspy.*"]diff --git a/scripts/bootstrap_python.sh b/scripts/bootstrap_python.shnew file mode 100644index 000000000..25c43d3e0--- /dev/null+++ b/scripts/bootstrap_python.sh@@ -0,0 +1,9 @@+#!/usr/bin/env bash+set -euo pipefail++# Bootstrap through a hash-verified wheel: the existing pip may trust the+# compromised emSign CA. A normal index-based pip upgrade is not safe yet.+# https://discuss.python.org/t/109576+python -m pip --disable-pip-version-check install --no-deps --upgrade \+ 'https://files.pythonhosted.org/packages/3f/06/3e4420302363fbb71be3c7f35ce042f54bfca330e3e66b3a2e3c4cca579f/pip-26.2.2-py3-none-any.whl#sha256=fd7f4dfa8190e014013b9f08f3e973f4e4c26ffd179a204895533a7254813a70'+python -m pip install --upgrade 'certifi>=2026.10.19'diff --git a/uv.lock b/uv.lockindex 06594e364..efce219af 100644--- a/uv.lock+++ b/uv.lock@@ -1,5 +1,5 @@version = 1-revision = 3+revision = 5requires-python = ">=3.10, <3.16"resolution-markers = ["python_full_version >= '3.15' and sys_platform != 'win32'",@@ -453,11 +453,11 @@ wheels = [[[package]]name = "certifi"-version = "2026.7.22"+version = "2026.10.19"source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/a3/c2/24167ea9858356b47a87a50d39908bfdb72ceeefe0041586e704e5376b3a/certifi-2026.7.22.tar.gz", hash = "sha256:741e2c3b351ddf169a738da9f2c048608ff7f2c5cc02f1ebc6b118bb090d5d55", size = 138112, upload-time = "2026-07-22T03:35:12.644Z" }+sdist = { url = "https://files.pythonhosted.org/packages/a6/bd/1436c50cc46699de0230fbaacc1d1de7bfec413176099949e9d5112e88f2/certifi-2026.10.19.tar.gz", hash = "sha256:035c1e85572b141bf1c3a3eff0e33a8eb74917522f2559075ff8d2fea780a1ae", size = 137598, upload-time = "2026-10-20T02:24:16.604Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/0b/a7/71ac2cff56fec219ed242bb11b8efb69fcc4bec75db06fb7bfe35de520e6/certifi-2026.7.22-py3-none-any.whl", hash = "sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775", size = 136983, upload-time = "2026-07-22T03:35:11.276Z" },+ { url = "https://files.pythonhosted.org/packages/c4/51/29046e48f693c54e5b7412216d447a1d8362c9653148d98c02cdf65fa733/certifi-2026.10.19-py3-none-any.whl", hash = "sha256:42d35340cc5b9ba78e818ddbff0c5b1c2b779de448a340fd1b989f5fa8670e1b", size = 136464, upload-time = "2026-10-20T02:24:15.072Z" },][[package]]@@ -900,6 +900,7 @@ source = { editable = "." }dependencies = [{ name = "anyio" },{ name = "cachetools" },+ { name = "certifi" },{ name = "cloudpickle" },{ name = "diskcache" },{ name = "gepa", marker = "python_full_version < '3.15'" },@@ -941,6 +942,7 @@ dev = [{ name = "pytest-xdist" },{ name = "ruff" },{ name = "ty" },+ { name = "virtualenv" },]langchain = [{ name = "langchain-core" },@@ -985,6 +987,7 @@ requires-dist = [{ name = "anyio" },{ name = "build", marker = "extra == 'dev'", specifier = ">=1.0.3" },{ name = "cachetools", specifier = ">=5.5.0" },+ { name = "certifi", specifier = ">=2026.10.19" },{ name = "cloudpickle", specifier = ">=3.1.2" },{ name = "datamodel-code-generator", marker = "extra == 'dev'", specifier = ">=0.26.3" },{ name = "datasets", marker = "extra == 'test-extras'", specifier = ">=2.14.6" },@@ -1025,6 +1028,7 @@ requires-dist = [{ name = "tenacity", specifier = ">=8.2.3" },{ name = "tqdm", specifier = ">=4.66.1" },{ name = "ty", marker = "extra == 'dev'", specifier = "==0.0.89" },+ { name = "virtualenv", marker = "extra == 'dev'", specifier = ">=21.14.12" },{ name = "weaviate-client", marker = "extra == 'weaviate'", specifier = ">=4.5.4,<4.22.0" },]provides-extras = ["anthropic", "weaviate", "mcp", "deno", "langchain", "optuna", "numpy", "litellm", "dev", "test-extras"]@@ -3742,14 +3746,14 @@ wheels = [[[package]]name = "python-discovery"-version = "1.5.1"+version = "1.6.4"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "filelock" },]-sdist = { url = "https://files.pythonhosted.org/packages/04/b7/1581a8103855c43567776aa34135e5ec3c597346c23bfd10c7eb5e0b10a4/python_discovery-1.5.1.tar.gz", hash = "sha256:e2ea8b884cd1701f386eda8cf327b87743f1dc21b7f784470799537d95635384", size = 77200, upload-time = "2026-07-31T22:06:02.48Z" }+sdist = { url = "https://files.pythonhosted.org/packages/f3/ee/cf608372c88ce2c136ee13c69ab6f667dbc0d0c1176af188b4ddc8853e66/python_discovery-1.6.4.tar.gz", hash = "sha256:bc70d31f0ec5de11eda13d4d64c16e24b3506a65984684f2b6c98cb83b2ea9df", size = 89883, upload-time = "2026-10-19T01:45:14.855Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/6a/07/a89b539750a159d5101c4eb9fc84e2961f65cefbd5e0b7440b284471c0b0/python_discovery-1.5.1-py3-none-any.whl", hash = "sha256:ac07f44cade589d954e9d6a1e1468539fdddd2cf676beb51da73e0f156b7c932", size = 35752, upload-time = "2026-07-31T22:06:01.116Z" },+ { url = "https://files.pythonhosted.org/packages/60/91/1aa70d3dfcab0dbcf88a2cbc3bce7f7c69562287a90216e617eaa4937e25/python_discovery-1.6.4-py3-none-any.whl", hash = "sha256:530179cc51a1816d512b15635b3dc931295ae12efb183783ad31190a5d425d2b", size = 39385, upload-time = "2026-10-19T01:45:13.668Z" },][[package]]@@ -4953,18 +4957,19 @@ wheels = [[[package]]name = "virtualenv"-version = "21.7.4"+version = "21.14.12"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "distlib" },{ name = "filelock" },+ { name = "packaging" },{ name = "platformdirs" },{ name = "python-discovery" },{ name = "typing-extensions", marker = "python_full_version < '3.11'" },]-sdist = { url = "https://files.pythonhosted.org/packages/2d/dc/a6eb1ddfa7f1e390fa599b078453c97edb3f6f846b34fb4eac3e8ea16401/virtualenv-21.7.4.tar.gz", hash = "sha256:c9d960c95fa458171e58222a5ccab7465298e4b6559977865e627c4719f1e825", size = 5345511, upload-time = "2026-08-10T22:54:33.316Z" }+sdist = { url = "https://files.pythonhosted.org/packages/c9/2c/1a69b3346931e9a7db9cc00cc0fa847c843a85fa7cf52a598f57261c68df/virtualenv-21.14.12.tar.gz", hash = "sha256:bbcfb78e36c22ad70c6917c4aecb5e63477d3c138e9f88c946f320e31859c76a", size = 5562800, upload-time = "2026-10-21T01:58:51.724Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/40/4c/eb2f52aeeaf30dbd073d315a251a63ae2b8263171ec4428c135140cb0802/virtualenv-21.7.4-py3-none-any.whl", hash = "sha256:376ec93cd6aab3044fa395d7db226db38043b7b5748948044b2a87168525e843", size = 5324444, upload-time = "2026-08-10T22:54:31.515Z" },+ { url = "https://files.pythonhosted.org/packages/a0/92/f3b8af2d36ddec4dc61dc25655dc010e419ff456cb4ca0e720c8112f1047/virtualenv-21.14.12-py3-none-any.whl", hash = "sha256:7820aeaef23f1f59a96458edfc7f9d3deac937155718de15f1c9a64471e15551", size = 5556824, upload-time = "2026-10-21T01:58:48.505Z" },][[package]]