Skip to content

Commit

Permalink
Stop using the removed importlib.resources.path on Python >=3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
rgommers committed Oct 20, 2023
1 parent 450b3db commit 265a09e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mesonbuild/dependencies/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import functools, json, os, textwrap
from pathlib import Path
import sys
import typing as T

from .. import mesonlib, mlog
Expand Down Expand Up @@ -112,8 +113,13 @@ def sanity(self) -> bool:
# Sanity check, we expect to have something that at least quacks in tune

import importlib.resources
if sys.version_info >= (3, 13):
traversable = importlib.resources.files('mesonbuild.scripts').joinpath('python_info.py')
context_mgr = importlib.resources.as_file(traversable)
else:
context_mgr = importlib.resources.path('mesonbuild.scripts', 'python_info.py')

with importlib.resources.path('mesonbuild.scripts', 'python_info.py') as f:
with context_mgr as f:
cmd = self.get_command() + [str(f)]
env = os.environ.copy()
env['SETUPTOOLS_USE_DISTUTILS'] = 'stdlib'
Expand Down

0 comments on commit 265a09e

Please sign in to comment.