Skip to content

Commit 16b2b10

Browse files
committed
Use pip config get to resolve the test index URL
Per asnare's review on #4803, the prior helper emulated pip's config-file loading and assumed env vars (PIP_INDEX_URL, UV_INDEX_URL) that aren't set in either dev or CI. Shell out to `pip config get global.index-url` instead and fall back to public PyPI when no mirror is configured. After #4804 the JFrog URL no longer carries credentials, so embedding it in the notebook fixture is safe. Co-authored-by: Isaac
1 parent c915101 commit 16b2b10

1 file changed

Lines changed: 6 additions & 18 deletions

File tree

tests/integration/source_code/test_libraries.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
because it uses the context and the time it takes to run the test.
44
"""
55

6-
import configparser
76
import logging
8-
import os
97
import re
8+
import subprocess
9+
import sys
1010
import textwrap
1111
from pathlib import Path
1212

@@ -17,22 +17,10 @@
1717

1818

1919
def _resolved_index_url() -> str:
20-
"""Return a pip-usable index URL for the current environment.
21-
22-
The notebook fixture invokes a real `pip install --index-url <url>`. CI's jfrog-auth action
23-
writes a pip.conf at ``$PIP_CONFIG_FILE`` whose ``[global] index-url`` carries the
24-
JFrog token; ``UV_INDEX_URL`` exists too but lacks credentials (uv stores auth in its keyring),
25-
so passing it to pip would 401. Prefer ``PIP_CONFIG_FILE`` so pip can authenticate; fall back
26-
to ``PIP_INDEX_URL`` and finally to the dev proxy used in local development.
27-
"""
28-
pip_config_file = os.environ.get("PIP_CONFIG_FILE")
29-
if pip_config_file and Path(pip_config_file).is_file():
30-
parser = configparser.ConfigParser()
31-
parser.read(pip_config_file)
32-
url = parser.get("global", "index-url", fallback=None)
33-
if url:
34-
return url
35-
return os.environ.get("PIP_INDEX_URL") or "https://pypi-proxy.dev.databricks.com/simple/"
20+
"""Return whichever pip mirror is configured locally, or public PyPI as a fallback."""
21+
cmd = [sys.executable, "-m", "pip", "config", "get", "global.index-url"]
22+
result = subprocess.run(cmd, capture_output=True, text=True, check=False, timeout=10)
23+
return result.stdout.strip() if result.returncode == 0 else "https://pypi.python.org/simple"
3624

3725

3826
def _write_pytest_with_index_url_notebook(directory: Path) -> str:

0 commit comments

Comments
 (0)