HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/cffi/__pycache__/pkgconfig.cpython-310.pyc
o

%we�@sHddlZddlZddlZddlmZdd�Ze��fdd�Zdd	�ZdS)
�N�)�PkgConfigErrorcCsj|��D].\}}||vr|||<qt||t�std|f��t|t�s+td|f��||�|�q|S)z�Merge values from cffi config flags cfg2 to cf1

    Example:
        merge_flags({"libraries": ["one"]}, {"libraries": ["two"]})
        {"libraries": ["one", "two"]}
    z$cfg1[%r] should be a list of stringsz$cfg2[%r] should be a list of strings)�items�
isinstance�list�	TypeError�extend)�cfg1�cfg2�key�value�r
�G/home/arjun/projects/env/lib/python3.10/site-packages/cffi/pkgconfig.py�merge_flagss

rc
Csddg}|�|�|�|�ztj|tjtjd�}Wnty1}ztdt|���f��d}~ww|��\}}|j	dkrTz|�
|�}Wn	tyMYnwt|����tj
dkrwt|t�swz|�
|�}Wntyvtd||||f��wtjd	kr�d	|vr�td
|||f��|S)z5Calls pkg-config and returns the output if found
    z
pkg-configz--print-errors)�stdout�stderrzcannot run pkg-config: %sNr)�zKpkg-config %s %s returned bytes that cannot be decoded with encoding %r:
%r�\zEpkg-config %s %s returned an unsupported backslash-escaped output:
%r)�append�
subprocess�Popen�PIPE�EnvironmentErrorr�str�strip�communicate�
returncode�decode�	Exception�sys�version_infor�UnicodeDecodeError�os�altsep)�libname�flag�encoding�a�pc�e�bout�berrr
r
r�calls<

��
�
���r,csjdd��dd��dd��dd��d	d
��dd��������fd
d�}i}|D]}||�}t||�q'|S)a�Return compiler line flags for FFI.set_source based on pkg-config output

    Usage
        ...
        ffibuilder.set_source("_foo", pkgconfig = ["libfoo", "libbar >= 1.8.3"])

    If pkg-config is installed on build machine, then arguments include_dirs,
    library_dirs, libraries, define_macros, extra_compile_args and
    extra_link_args are extended with an output of pkg-config for libfoo and
    libbar.

    Raises PkgConfigError in case the pkg-config call fails.
    cS�dd�|��D�S)NcS�"g|]
}|�d�r|dd��qS)�-I�N��
startswith��.0�xr
r
r�
<listcomp>L�"zBflags_from_pkgconfig.<locals>.get_include_dirs.<locals>.<listcomp>��split��stringr
r
r�get_include_dirsK�z.flags_from_pkgconfig.<locals>.get_include_dirscSr-)NcSr.)�-Lr0Nr1r3r
r
rr6Or7zBflags_from_pkgconfig.<locals>.get_library_dirs.<locals>.<listcomp>r8r:r
r
r�get_library_dirsNr=z.flags_from_pkgconfig.<locals>.get_library_dirscSr-)NcSr.)�-lr0Nr1r3r
r
rr6Rr7z?flags_from_pkgconfig.<locals>.get_libraries.<locals>.<listcomp>r8r:r
r
r�
get_librariesQr=z+flags_from_pkgconfig.<locals>.get_librariescsdd���fdd�|��D�S)NcSs,|dd�}d|vrt|�dd��S|dfS)Nr0�=r)�tupler9)r5r
r
r�_macroVsz8flags_from_pkgconfig.<locals>.get_macros.<locals>._macrocsg|]}|�d�r�|��qS)�-Dr1r3�rDr
rr6\sz<flags_from_pkgconfig.<locals>.get_macros.<locals>.<listcomp>r8r:r
rFr�
get_macrosUsz(flags_from_pkgconfig.<locals>.get_macroscSr-)NcS�$g|]}|�d�s|�d�s|�qS)r/rEr1r3r
r
rr6_�
�zBflags_from_pkgconfig.<locals>.get_other_cflags.<locals>.<listcomp>r8r:r
r
r�get_other_cflags^r=z.flags_from_pkgconfig.<locals>.get_other_cflagscSr-)NcSrH)r>r@r1r3r
r
rr6crIz@flags_from_pkgconfig.<locals>.get_other_libs.<locals>.<listcomp>r8r:r
r
r�get_other_libsbr=z,flags_from_pkgconfig.<locals>.get_other_libscsFt��}t|d�}t|d�}�|��|��|��|��|��|�d�S)Nz--cflagsz--libs)�include_dirs�library_dirs�	libraries�
define_macros�extra_compile_args�extra_link_args)r�getfilesystemencodingr,)r$�fse�
all_cflags�all_libs�r<rAr?rGrJrKr
r�kwargsgs

�z$flags_from_pkgconfig.<locals>.kwargs)r)�libsrW�retr$�	lib_flagsr
rVr�flags_from_pkgconfig<s	r[)	rr"r�errorrrrRr,r[r
r
r
r�<module>s
"