Skip to content

Commit 74737e6

Browse files
committed
TST: install pip 24.1b1 or later when on Python 3.13t
Earlier pip releases do not recognize the free-threading ABI flag.
1 parent 56e7d18 commit 74737e6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
import shutil
1111
import subprocess
1212
import sys
13+
import sysconfig
1314
import tempfile
1415
import warnings
1516

1617
from venv import EnvBuilder
1718

19+
import packaging.version
1820
import pytest
1921

2022
import mesonpy
@@ -77,13 +79,23 @@ def tmp_path_session(tmp_path_factory):
7779
class VEnv(EnvBuilder):
7880
def __init__(self, env_dir):
7981
super().__init__(symlinks=True, with_pip=True)
82+
8083
# This warning is mistakenly generated by CPython 3.11.0
8184
# https://github.com/python/cpython/pull/98743
8285
with warnings.catch_warnings():
8386
if sys.version_info[:3] == (3, 11, 0):
8487
warnings.filterwarnings('ignore', 'check_home argument is deprecated and ignored.', DeprecationWarning)
8588
self.create(env_dir)
8689

90+
# Free-threaded Python 3.13 requires pip 24.1b1 or later.
91+
if sysconfig.get_config_var('Py_GIL_DISABLED'):
92+
# importlib.metadata is not available on Python 3.7 and
93+
# earlier, however no-gil builds are available only for
94+
# Python 3.13 and later.
95+
import importlib.metadata
96+
if packaging.version.Version(importlib.metadata.version('pip')) < packaging.version.Version('24.1b1'):
97+
self.pip('install', '--upgrade', 'pip >= 24.1b1')
98+
8799
def ensure_directories(self, env_dir):
88100
context = super().ensure_directories(env_dir)
89101
# Store the path to the venv Python interpreter. There does

0 commit comments

Comments
 (0)