@@ -161,69 +161,6 @@ def __init__(self, python_holder: 'BasicPythonExternalProgram', embed: bool):
161161 else :
162162 self .major_version = 2
163163
164-
165- class PythonPkgConfigDependency (PkgConfigDependency , _PythonDependencyBase ):
166-
167- def __init__ (self , name : str , environment : 'Environment' ,
168- kwargs : T .Dict [str , T .Any ], installation : 'BasicPythonExternalProgram' ,
169- libpc : bool = False ):
170- if libpc :
171- mlog .debug (f'Searching for { name !r} via pkgconfig lookup in LIBPC' )
172- else :
173- mlog .debug (f'Searching for { name !r} via fallback pkgconfig lookup in default paths' )
174-
175- PkgConfigDependency .__init__ (self , name , environment , kwargs )
176- _PythonDependencyBase .__init__ (self , installation , kwargs .get ('embed' , False ))
177-
178- if libpc and not self .is_found :
179- mlog .debug (f'"python-{ self .version } " could not be found in LIBPC, this is likely due to a relocated python installation' )
180-
181- # pkg-config files are usually accurate starting with python 3.8
182- if not self .link_libpython and mesonlib .version_compare (self .version , '< 3.8' ):
183- self .link_args = []
184-
185-
186- class PythonFrameworkDependency (ExtraFrameworkDependency , _PythonDependencyBase ):
187-
188- def __init__ (self , name : str , environment : 'Environment' ,
189- kwargs : T .Dict [str , T .Any ], installation : 'BasicPythonExternalProgram' ):
190- ExtraFrameworkDependency .__init__ (self , name , environment , kwargs )
191- _PythonDependencyBase .__init__ (self , installation , kwargs .get ('embed' , False ))
192-
193-
194- class PythonSystemDependency (SystemDependency , _PythonDependencyBase ):
195-
196- def __init__ (self , name : str , environment : 'Environment' ,
197- kwargs : T .Dict [str , T .Any ], installation : 'BasicPythonExternalProgram' ):
198- SystemDependency .__init__ (self , name , environment , kwargs )
199- _PythonDependencyBase .__init__ (self , installation , kwargs .get ('embed' , False ))
200-
201- # match pkg-config behavior
202- if self .link_libpython :
203- # link args
204- if mesonlib .is_windows ():
205- self .find_libpy_windows (environment , limited_api = False )
206- else :
207- self .find_libpy (environment )
208- else :
209- self .is_found = True
210-
211- # compile args
212- inc_paths = mesonlib .OrderedSet ([
213- self .variables .get ('INCLUDEPY' ),
214- self .paths .get ('include' ),
215- self .paths .get ('platinclude' )])
216-
217- self .compile_args += ['-I' + path for path in inc_paths if path ]
218-
219- # https://sourceforge.net/p/mingw-w64/mailman/message/30504611/
220- # https://github.com/python/cpython/pull/100137
221- if mesonlib .is_windows () and self .get_windows_python_arch ().endswith ('64' ) and mesonlib .version_compare (self .version , '<3.12' ):
222- self .compile_args += ['-DMS_WIN64=' ]
223-
224- if not self .clib_compiler .has_header ('Python.h' , '' , environment , extra_args = self .compile_args )[0 ]:
225- self .is_found = False
226-
227164 def find_libpy (self , environment : 'Environment' ) -> None :
228165 if self .is_pypy :
229166 if self .major_version == 3 :
@@ -347,6 +284,68 @@ def find_libpy_windows(self, env: 'Environment', limited_api: bool = False) -> N
347284 self .link_args = largs
348285 self .is_found = True
349286
287+ class PythonPkgConfigDependency (PkgConfigDependency , _PythonDependencyBase ):
288+
289+ def __init__ (self , name : str , environment : 'Environment' ,
290+ kwargs : T .Dict [str , T .Any ], installation : 'BasicPythonExternalProgram' ,
291+ libpc : bool = False ):
292+ if libpc :
293+ mlog .debug (f'Searching for { name !r} via pkgconfig lookup in LIBPC' )
294+ else :
295+ mlog .debug (f'Searching for { name !r} via fallback pkgconfig lookup in default paths' )
296+
297+ PkgConfigDependency .__init__ (self , name , environment , kwargs )
298+ _PythonDependencyBase .__init__ (self , installation , kwargs .get ('embed' , False ))
299+
300+ if libpc and not self .is_found :
301+ mlog .debug (f'"python-{ self .version } " could not be found in LIBPC, this is likely due to a relocated python installation' )
302+
303+ # pkg-config files are usually accurate starting with python 3.8
304+ if not self .link_libpython and mesonlib .version_compare (self .version , '< 3.8' ):
305+ self .link_args = []
306+
307+
308+ class PythonFrameworkDependency (ExtraFrameworkDependency , _PythonDependencyBase ):
309+
310+ def __init__ (self , name : str , environment : 'Environment' ,
311+ kwargs : T .Dict [str , T .Any ], installation : 'BasicPythonExternalProgram' ):
312+ ExtraFrameworkDependency .__init__ (self , name , environment , kwargs )
313+ _PythonDependencyBase .__init__ (self , installation , kwargs .get ('embed' , False ))
314+
315+
316+ class PythonSystemDependency (SystemDependency , _PythonDependencyBase ):
317+
318+ def __init__ (self , name : str , environment : 'Environment' ,
319+ kwargs : T .Dict [str , T .Any ], installation : 'BasicPythonExternalProgram' ):
320+ SystemDependency .__init__ (self , name , environment , kwargs )
321+ _PythonDependencyBase .__init__ (self , installation , kwargs .get ('embed' , False ))
322+
323+ # match pkg-config behavior
324+ if self .link_libpython :
325+ # link args
326+ if mesonlib .is_windows ():
327+ self .find_libpy_windows (environment , limited_api = False )
328+ else :
329+ self .find_libpy (environment )
330+ else :
331+ self .is_found = True
332+
333+ # compile args
334+ inc_paths = mesonlib .OrderedSet ([
335+ self .variables .get ('INCLUDEPY' ),
336+ self .paths .get ('include' ),
337+ self .paths .get ('platinclude' )])
338+
339+ self .compile_args += ['-I' + path for path in inc_paths if path ]
340+
341+ # https://sourceforge.net/p/mingw-w64/mailman/message/30504611/
342+ # https://github.com/python/cpython/pull/100137
343+ if mesonlib .is_windows () and self .get_windows_python_arch ().endswith ('64' ) and mesonlib .version_compare (self .version , '<3.12' ):
344+ self .compile_args += ['-DMS_WIN64=' ]
345+
346+ if not self .clib_compiler .has_header ('Python.h' , '' , environment , extra_args = self .compile_args )[0 ]:
347+ self .is_found = False
348+
350349 @staticmethod
351350 def log_tried () -> str :
352351 return 'sysconfig'
0 commit comments