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: //usr/local/lib/python3.10/dist-packages/numpy/distutils/__pycache__/ccompiler.cpython-310.pyc
o

���g�o�@s�ddlZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
mZmZmZmZddlmZmZmZmZmZddlmZddlmZdd	lmZdd
lmZm Z ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'ddl(Z(da)e(�*�Z+e,�Z-dd
�Z.dd�Z/dd�Z0e/ede0�dPdd�Z1e/ede1�dQdd�Z2e/ede2�			dRdd�Z3e/ede3�dSdd�Z4e/ed e4�d!d"�Z5d#d$�Z6e/ed%e6�dTd&d'�Z7e/ed(e7�dUd*d+�Z8d,dgfd-d.�Z9e/ed/e9�d0d1�Z:e/ed2e:�d3e
d4<d5e
d6<d7e
d8<d9e
d:<d;e
d<<d=e
d><d?e
d@<dAe
dB<ej;dC7_;ejdDk�r8dEe
dF<e$��r8e�<dG�dHej;e_;eZ=					dVdIdJ�Zee_eZ>dKdL�Zee_dMD]Z?ej@�AdNe?dO�ZBeBdu�rieCeBdLe��qRdS)W�N)�copy)�Path)�	ccompiler)�compiler_class�gen_lib_options�get_default_compiler�new_compiler�	CCompiler)�DistutilsExecError�DistutilsModuleError�DistutilsPlatformError�CompileError�UnknownFileError)�customize_compiler)�LooseVersion)�log)�filepath_from_subprocess_output�forward_bytes_to_stdout)�	cyg2win32�is_sequence�mingw32�get_num_build_jobs�_commandline_dep_string�sanitize_cxx_flagscCs�|d}tj�|�sdSt|��}|��}Wd�n1swYt|||�}|d}||kr4dSd�|dd��}	dd�tj|	dd�D�}
zt�	|�j
}|
D]}t�	|�j
|kr`WdSqRWd	StymYdSw)
z�
    Check if an objects needs to be rebuild based on its dependencies

    Parameters
    ----------
    obj : str
        object file

    Returns
    -------
    bool
    �.dTN����cSs"g|]
}|dkr|�d�s|�qS)�
�:)�endswith)�.0�x�r"�D/usr/local/lib/python3.10/dist-packages/numpy/distutils/ccompiler.py�
<listcomp>Gs�z _needs_build.<locals>.<listcomp>)�posixF)�os�path�exists�open�	readlinesr�join�shlex�split�stat�st_mtime�OSError)�obj�cc_args�extra_postargs�pp_opts�dep_file�f�lines�cmdline�last_cmdline�contents�deps�t_objr"r"r#�_needs_build's.

�����r=cs�fdd�}t|||�dS)Ncs�|g|�Ri|��S�Nr")�self�args�kw��funcr"r#�<lambda>[sz replace_method.<locals>.<lambda>)�setattr)�klass�method_namerC�mr"rBr#�replace_methodYsrIcCsdS)z�
    Does nothing here, but is called by the get_version method and can be
    overridden by subclasses. In particular it is redefined in the `FCompiler`
    class where more documentation can be found.

    Nr"�r?r"r"r#�CCompiler_find_executablesdsrK�find_executablesc	CsV|dur|nttj�}|dur|}t|�rd�t|��}t�|�z|jr/t	j
||d�WdSt	j
|t	j|d�WdSt	jyS}z|j
}|j}WYd}~n6d}~wty�}z&d|�d�}z	|�tjj�}Wntyw|�d�}Ynwd}WYd}~nd}~wwt|�r�d�t|��}|jr�t|�t�d	|�r�d
}nd}td|||f��)
a�
    Execute a command in a sub-process.

    Parameters
    ----------
    cmd : str
        The command to execute.
    display : str or sequence of str, optional
        The text to add to the log file kept by `numpy.distutils`.
        If not given, `display` is equal to `cmd`.
    env : a dictionary for environment variables, optional

    Returns
    -------
    None

    Raises
    ------
    DistutilsExecError
        If the command failed, i.e. the exit status was not 0.

    N� )�env)�stderrrNz

z


�utf8�sToo many open filesz2
Try rerunning setup command until build succeeds.rz)Command "%s" failed with exit status %d%s)�dictr&�environrr+�listr�info�verbose�
subprocess�check_output�STDOUT�CalledProcessError�output�
returncoder0�encode�sys�stdout�encoding�AttributeErrorr�re�searchr
)	r?�cmd�displayrN�exc�o�s�e�msgr"r"r#�CCompiler_spawnrsH
�������rk�spawnrcCs�|durd}g}|D]h}tj�tj�|��\}}tj�|�d}|tj�|�d�}|�d�rN|�d�d}|d|�}	tj�tj�	|	��}	|	||d�}||j
vr[td||f��|rctj�|�}tj�|||j
�}
|�|
�q
|S)a�
    Return the name of the object files for the given source files.

    Parameters
    ----------
    source_filenames : list of str
        The list of paths to source files. Paths can be either relative or
        absolute, this is handled transparently.
    strip_dir : bool, optional
        Whether to strip the directory from the returned paths. If True,
        the file name prepended by `output_dir` is returned. Default is False.
    output_dir : str, optional
        If given, this path is prepended to the returned paths to the
        object files.

    Returns
    -------
    obj_names : list of str
        The list of paths to the object files corresponding to the source
        files in `source_filenames`.

    Nr�z..�z"unknown file type '%s' (from '%s'))r&r'�splitext�normpath�
splitdrive�isabs�
startswith�rfind�basename�abspath�src_extensionsrr+�
obj_extension�append)r?�source_filenames�	strip_dir�
output_dir�	obj_names�src_name�base�ext�i�d�obj_namer"r"r#�CCompiler_object_filenames�s&

r��object_filenamesc	snt�}	t�tdurt�|	�aWd�n1swY|s"gSddlm}
m}m}t	�|
�rVg}
dD]}t
�d|�}|durCq5|
�d|d�|�f�q5d�|
�}
n�j
}d	d�|�f}
t�|
���|||||��\}}��}���||��d
d���}
�r�|
dd���7}
t�|
�����fdd
�}t	�|
�r�t|���}gg}}|D]9}||vr�||\}}�jdkr�t|�}t|�}t|�j��|vr�||�s�|�|||ff�q�|�|||ff�q�|}|D]}||�q�n|��}t|�dk�r+|	dk�r+ddlm}||	��}|�||�}Wd�n	1�s wYt|�|S|D]}||��q-|S)a�
    Compile one or more source files.

    Please refer to the Python distutils API reference for more details.

    Parameters
    ----------
    sources : list of str
        A list of filenames
    output_dir : str, optional
        Path to the output directory.
    macros : list of tuples
        A list of macro definitions.
    include_dirs : list of str, optional
        The directories to add to the default include file search path for
        this compilation only.
    debug : bool, optional
        Whether or not to output debug symbols in or alongside the object
        file(s).
    extra_preargs, extra_postargs : ?
        Extra pre- and post-arguments.
    depends : list of str, optional
        A list of file names that all targets depend on.

    Returns
    -------
    objects : list of str
        A list of object file names, one per source file `sources`.

    Raises
    ------
    CompileError
        If compilation fails.

    Nr)�	FCompiler�FORTRAN_COMMON_FIXED_EXTENSIONS�has_f90_header)�f77�f90�fix�	compiler_zFortran %s compiler: %srMrzC compiler: %s
zcompile options: '%s'z
extra options: '%s'cs|\}\}}t|����sdS	t�|tvr$t�|�	Wd�nWd�n1s.wYt�d�qz7t���|||����Wd�n1sQwYWt�t�|�Wd�dS1sjwYdSt�
t�|�Wd�w1s�wYw)NTg�������?)	r=�_global_lock�_processing_files�add�time�sleep�_job_semaphore�_compile�remove)r@r1�srcr��r2r3r4r?r"r#�single_compile4s.
��
�
��(��z)CCompiler_compile.<locals>.single_compile�absoftrm)�ThreadPoolExecutor)rr�r��	threading�	Semaphore�numpy.distutils.fcompilerr�r�r��
isinstance�getattrryr+�compiler_sorrU�_setup_compile�_get_cc_argsrT�keys�
compiler_typerr�suffix�lower�items�len�concurrent.futuresr��map)r?�sourcesr|�macros�include_dirs�debug�
extra_preargsr3�depends�jobsr�r�r�re�fc�fcomp�ccomp�objects�buildr��objects_to_build�f77_objects�
other_objectsr1r�r��build_itemsrgr��pool�resr"r�r#�CCompiler_compile�sx(
��

��



��
�
��r��compiler"cs(t�d|jj�jjf�t|d�r0d|jdvr0t��dkr$tjdks0|j�	d�|j
�	d���fdd	�}|d
�rA|��j�|d�rS�j
D]
\}}|�||�qH|d�rb�jD]}|�|�qZ|d
�ro|�|j�j�|d�r||�|j�j�|d�r�|��j�|d�r�|��j�dSdS)a�
    Customize compiler using distutils command.

    Parameters
    ----------
    cmd : class instance
        An instance inheriting from `distutils.cmd.Command`.
    ignore : sequence of str, optional
        List of `CCompiler` commands (without ``'set_'``) that should not be
        altered. Strings that are checked for are:
        ``('include_dirs', 'define', 'undef', 'libraries', 'library_dirs',
        'rpath', 'link_objects')``.

    Returns
    -------
    None

    zcustomize %s using %s�compiler�clangr�arm64�darwinz-ftrapping-mathcst�|d�duo|�vSr>)r�)�attr�rd�ignorer"r#�allow�sz&CCompiler_customize_cmd.<locals>.allowr��define�undef�	libraries�library_dirs�rpath�link_objectsN)rrU�	__class__�__name__�hasattrr��platform�machiner^ryr��set_include_dirsr�r��define_macror��undefine_macro�
set_librariesr��set_library_dirsr��set_runtime_library_dirsr��set_link_objectsr�)r?rdr�r��name�value�macror"r�r#�CCompiler_customize_cmdxs6��
�r��
customize_cmdcs�g}d}t|j���}dD]}||vr|�|�q
|D]}t||�r7t||�}t|t|��}|�|t|�f�qdt|d�d��fdd�|D�}d�	|�S)	Nr)
�versionr�r��
object_switch�compile_switchr�r�r�r�r�z%-rmzs = %scsg|]}�|�qSr"r")r �prop��fmtr"r#r$�sz'_compiler_to_string.<locals>.<listcomp>r)
rT�executablesr�ryr�r��maxr��reprr+)r��props�mxr��key�vr7r"r�r#�_compiler_to_string�s 
�

�
r�cCsZz|��Wn	tyYnwtjjdkr+td�t|j�tt|��td�dSdS)z�
    Print the compiler customizations to stdout.

    Parameters
    ----------
    None

    Returns
    -------
    None

    Notes
    -----
    Printing is only done if the distutils log threshold is < 2.

    rnzP********************************************************************************N)�get_version�	Exceptionr�_global_log�	threshold�printr�r�rJr"r"r#�CCompiler_show_customization�s�
�r��show_customizationc
	Cs�t�d|jj�t|�|rrz|j�d�Wnttfy"Ynwt	|d�rVd|j
dvrV|jsU|j
d�d�r?d\}}nd\}}|j
d�
||�g|j
d	d
�|_nt	|d�rdt�d|j
f�t	|d�srt�d
|jj�t	|d�r�d|j
dvs�d|j
dvs�d|j
dvr�d|_d
Stjdkr�dd
l}dd
l}|��}zQz4tj�|d�}t|d��
}	|	�d�Wd
�n1s�wY|j|g|dd|dgd�d|_Wnty�d|_Yn	wW|�|�d
SW|�|�d
S|�|�wd
S)am
    Do any platform-specific customization of a compiler instance.

    This method calls `distutils.sysconfig.customize_compiler` for
    platform-specific customization, as well as optionally remove a flag
    to suppress spurious warnings in case C++ code is being compiled.

    Parameters
    ----------
    dist : object
        This parameter is not used for anything.
    need_cxx : bool, optional
        Whether or not C++ has to be compiled. If so (True), the
        ``"-Wstrict-prototypes"`` option is removed to prevent spurious
        warnings. Default is False.

    Returns
    -------
    None

    Notes
    -----
    All the default options used by distutils can be extracted with::

      from distutils import sysconfig
      sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'BASECFLAGS',
                                'CCSHARED', 'LDSHARED', 'SO')

    zcustomize %sz-Wstrict-prototypesr��ccr�gcc)r��g++)r�zc++rmNz#### %s #######�compiler_cxxzMissing compiler_cxx fix for r�r�Tr%zfile.c�wzint a;
z-MMDz-MFr)r|r�F)rrUr�r�rr�r�ra�
ValueErrorr�r�r�rs�replace�warn�
_auto_dependsr&r��tempfile�shutil�mkdtempr'r+r)�writer�r
�rmtree)
r?�dist�need_cxx�a�br�r��tmpdir�fnr6r"r"r#�CCompiler_customize�sd�
��


��
�

��
�
�r�	customize�[-.\d]+cs���fdd�}|S)aU
    Simple matching of version numbers, for use in CCompiler and FCompiler.

    Parameters
    ----------
    pat : str, optional
        A regular expression matching version numbers.
        Default is ``r'[-.\d]+'``.
    ignore : str, optional
        A regular expression matching patterns to skip.
        Default is ``''``, in which case nothing is skipped.
    start : str, optional
        A regular expression matching the start of where to start looking
        for version numbers.
        Default is ``''``, in which case searching is started at the
        beginning of the version string given to `matcher`.

    Returns
    -------
    matcher : callable
        A function that is appropriate to use as the ``.version_match``
        attribute of a `CCompiler` class. `matcher` takes a single parameter,
        a version string.

    csz|�dd�}d}�rt��|�}|sdS|��}	t��||d��}|s'dS�r7t��|�d��r7|��}q	|�d�S)NrrMr)r�rb�match�endrc�group)r?�version_string�posrH�r��pat�startr"r#�matcherLs 
z%simple_version_match.<locals>.matcherr")rr�rrr"rr#�simple_version_match2srFc	s.|s
t|d�r
|jS|��z|j}Wn
tyYdSw|r$|ds&dSz|j}Wn tyKz|j�WntyBYYdSw�fdd�}Ynwz
tj|tj	d�}Wn%tj
yo}z|j}|j}WYd}~nd}~wt
y{d}d}Ynwt|�}d}d}||vr�||�}|r�t|�}||_|S)	a�
    Return compiler version, or None if compiler is not available.

    Parameters
    ----------
    force : bool, optional
        If True, force a new determination of the version, even if the
        compiler already has a version attribute. Default is False.
    ok_status : list of int, optional
        The list of status values returned by the version look-up process
        for which a version string is returned. If the status value is not
        in `ok_status`, None is returned. Default is ``[0]``.

    Returns
    -------
    version : str or None
        Version string, in the format of `distutils.version.LooseVersion`.

    r�Nrcs"t��|�}|s
dS|�d�}|S)Nr�)rbr	r)rrHr��rr"r#r�s

z&CCompiler_get_version.<locals>.matcher)rOrQ�)r�r�rL�version_cmdra�
version_match�version_patternrWrXrYrZr[r\r0rr)	r?�force�	ok_statusrrr[rf�statusr�r"rr#�CCompiler_get_versionasN
�

����rr�cCs�|jdvr|St|�}|j|_|jdgt|jdd��|_tj�d�r>d|jdvr>|jd|jdg|jdd�|_tj�d�rX|j�	d	�|j�	d
�|j�	d
�|S|jdg|jdd�|_|S)z�
    Return the C++ compiler.

    Parameters
    ----------
    None

    Returns
    -------
    cxx : class instance
        The C++ compiler, as a `CCompiler` instance.

    )�msvc�intelw�intelemwrrmN)�aix�os400�	ld_so_aixrnr z-D__STDC_FORMAT_MACROSz-fno-extern-tls-init)
r�rr�rr�r^r�rs�	linker_sory)r?�cxxr"r"r#�CCompiler_cxx_compiler�s&

���r$�cxx_compiler)�intelccompiler�IntelCCompilerz(Intel C Compiler for 32-bit applications�intel)r&�IntelItaniumCCompilerz7Intel C Itanium Compiler for Itanium-based applications�intele)r&�IntelEM64TCCompilerz(Intel C Compiler for 64-bit applications�intelem)r&�IntelCCompilerWz3Intel C Compiler for 32-bit applications on Windowsr)r&�IntelEM64TCCompilerWz3Intel C Compiler for 64-bit applications on Windowsr)�
pathccompiler�PathScaleCCompilerz2PathScale Compiler for SiCortex-based applications�pathcc)�armccompiler�ArmCCompilerzArm C Compiler�arm)�fujitsuccompiler�FujitsuCCompilerzFujitsu C Compiler�fujitsu))�linux.*r()r8r*)r8r,)r8r1)�ntr)r9r�win32)�mingw32ccompiler�Mingw32CCompilerz>Mingw32 port of GNU C Compiler for Win32(for MSC built Python)rz+Setting mingw32 as default compiler for nt.))r9rc
Csp|durt��tjk}|durtj}z|durt|�}t|\}}}Wnty<d|}|dur8|d|}t|��wd|}zt	|�WnAt
y�}	z5t|	�}t�dt|��|dd�}zt	|�Wnt
y}}	z
t|	�}t
d|��d}	~	wwWYd}	~	nd}	~	wwz
tj|}
t|
�|}Wnty�t
d||f��w|d||�}||_t�d|�|S)	Nz5don't know how to compile C/C++ code on platform '%s'z with '%s' compilerznumpy.distutils.z,%s in numpy.distutils; trying from distutils�z4can't compile C/C++ code: unable to load module '%s'zBcan't compile C/C++ code: unable to find class '%s' in module '%s'znew_compiler returns %s)r�
get_threshold�INFOr&r�rr�KeyErrorr�
__import__�ImportError�strrUrr^�modules�varsrVr�)�platr�rV�dry_runr�module_name�
class_name�long_descriptionrjri�modulerFr"r"r#r�s^��������
��rcCsBt||||�}g}|D]}t|�r|�t|��q|�|�q|Sr>)�_distutils_gen_lib_optionsr�extendrTry)r�r��runtime_library_dirsr��r�lib_optsr�r"r"r#r s�r)�msvc9r�_msvc�bcpp�cygwinc�emxc�unixcz
distutils.r�)NN)rr)NNNrNNN)r")r)rrr)NNNrr)Dr&rbr^r�r,r�rWr�pathlibr�	distutilsr�distutils.ccompilerrrrrr	�distutils.errorsr
rrr
r�distutils.sysconfigr�distutils.versionr�numpy.distutilsr�numpy.distutils.exec_commandrr�numpy.distutils.misc_utilrrrrrrr�r��Lockr��setr�r=rIrKrkr�r�r�r�r�rrrr$�_default_compilersrU�_distutils_new_compilerrL�_ccrD�get�_mrEr"r"r"r#�<module>s� 2

G
-
�
6
Q
/C$
�
�,
��