File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -110,8 +110,15 @@ def sanity(self) -> bool:
110
110
# Sanity check, we expect to have something that at least quacks in tune
111
111
112
112
import importlib .resources
113
+ import sys
114
+ if sys .version_info >= (3 , 9 ):
115
+ ctx = importlib .resources .as_file (
116
+ importlib .resources .files ('mesonbuild.scripts' ).joinpath ('python_info.py' )
117
+ )
118
+ else :
119
+ ctx = importlib .resources .path ('mesonbuild.scripts' , 'python_info.py' )
113
120
114
- with importlib . resources . path ( 'mesonbuild.scripts' , 'python_info.py' ) as f :
121
+ with ctx as f :
115
122
cmd = self .get_command () + [str (f )]
116
123
p , stdout , stderr = mesonlib .Popen_safe (cmd )
117
124
Original file line number Diff line number Diff line change @@ -329,7 +329,11 @@ def should_append(f, isdir: bool = False):
329
329
import importlib .resources
330
330
pycompile = os .path .join (self .interpreter .environment .get_scratch_dir (), 'pycompile.py' )
331
331
with open (pycompile , 'wb' ) as f :
332
- f .write (importlib .resources .read_binary ('mesonbuild.scripts' , 'pycompile.py' ))
332
+ import sys
333
+ if sys .version_info >= (3 , 9 ):
334
+ f .write (importlib .resources .files ('mesonbuild.scripts' ).joinpath ('pycompile.py' ).read_bytes ())
335
+ else :
336
+ f .write (importlib .resources .read_binary ('mesonbuild.scripts' , 'pycompile.py' ))
333
337
334
338
for i in self .installations .values ():
335
339
if isinstance (i , PythonExternalProgram ) and i .run_bytecompile [i .info ['version' ]]:
You can’t perform that action at this time.
0 commit comments