관리-도구
편집 파일: build_ext.cpython-39.opt-1.pyc
a �����DOg�{����������������������@���s����d�Z�ddlZddlZddlZddlZddlmZ�ddlT�ddlm Z m Z �ddlmZ�ddlm Z �ddlmZ�dd lmZ�dd lmZ�ddlmZ�e�d�Zd d��ZG�dd��de�ZdS�)z�distutils.command.build_ext Implements the Distutils 'build_ext' command, for building extension modules (currently limited to C extensions, should accommodate C++ extensions ASAP).�����N)�Command)�*)�customize_compiler�get_python_version)�get_config_h_filename)�newer_group)� Extension)�get_platform)�log)� USER_BASEz3^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$c������������������C���s���ddl�m}��|����d�S�)Nr�����show_compilers)�distutils.ccompilerr ���r�����r����3/usr/lib64/python3.9/distutils/command/build_ext.pyr ������s����r ���c�������������������@���s��e�Zd�ZdZdej�Zddddde���fdd d de�fdd dddde�fddddddddddgZg�d�Z ddde fgZd d!��Zd"d#��Z d$d%��Zd&d'��Zd(d)��Zd*d+��Zd,d-��Zd.d/��Zd0d1��Zejd2d3���Zd4d5��Zd6d7��Zd8d9��Zd:d;��Zd<d=��Zd>d?��Zd@dA��ZdBdC��ZdS�)D� build_extz8build C/C++ extensions (compile/link to build directory)z (separated by '%s'))z build-lib=�bz(directory for compiled extension modules)zbuild-temp=�tz1directory for temporary files (build by-products)z plat-name=�pz>platform name to cross-compile for, if supported (default: %s))�inplace�iziignore build-lib and put compiled extensions into the source directory alongside your pure Python modulesz include-dirs=�Iz.list of directories to search for header files)zdefine=�DzC preprocessor macros to define)zundef=�Uz!C preprocessor macros to undefine)z libraries=�lz!external C libraries to link withz library-dirs=�Lz.directories to search for external C libraries)zrpath=�Rz7directories to search for shared C libraries at runtime)z link-objects=�Oz2extra explicit link objects to include in the link)�debug�gz'compile/link with debugging information)�force�fz2forcibly build everything (ignore file timestamps))z compiler=�czspecify the compiler type)z parallel=�jznumber of parallel build jobs)�swig-cppNz)make SWIG create C++ files (default is C))z swig-opts=Nz!list of SWIG command line options)zswig=Nzpath to the SWIG executable)�userNz#add user include, library and rpath)r���r���r ���r$���r%���z help-compilerNzlist available compilersc�����������������C���s����d�|�_�d�|�_d�|�_d�|�_d|�_d�|�_d�|�_d�|�_d�|�_d�|�_ d�|�_ d�|�_d�|�_d�|�_ d�|�_d�|�_d�|�_d�|�_d�|�_d�|�_d�|�_d�S�)Nr���)� extensions� build_lib� plat_name� build_tempr����package�include_dirs�define�undef� libraries�library_dirs�rpath�link_objectsr���r ����compiler�swig�swig_cpp� swig_optsr%����parallel��selfr���r���r����initialize_optionsj���s*����zbuild_ext.initialize_optionsc����������� ��� ���C���s���ddl�m}�|��ddddddd d ��|�jd�u�r8|�jj|�_|�jj|�_|���}|jdd�}|�j d�u�rn|�jj pjg�|�_ t |�j t�r�|�j �t j�|�_ tjtjkr�|�j �t j�tjd ���|�j �|�t jj���||kr�|�j �|�t jj���|��d��|��d��|�jd�u��rg�|�_|�jd�u��rg�|�_nt |�jt��r:|�j�t j�|�_|�jd�u��rNg�|�_nt |�jt��rl|�j�t j�|�_t jdk�rh|�j�t j�tjd���tjtjk�r�|�j�t j�tjd���|�j�r�t j�|�jd�|�_nt j�|�jd�|�_|�j �t j�t�����t tdd��}|�r|�j�|��|�j!dk�r*d}n|�j!dd���}t j�tjd�}|�r\t j�||�}|�j�|��tj"d�d��dk�r�tj#�$t j�tjd���r�|�j�t j�tjddt%���d���n|�j�d��|�&d��r�|j'�s�|�j�|�&d ���n|�j�d��|�j(�r|�j(�d!�}d"d#��|D��|�_(|�j)�r4|�j)�d!�|�_)|�j*d�u��rHg�|�_*n|�j*�d$�|�_*|�j+�r�t j�t,d �}t j�t,d�} t j�-|��r�|�j �|��t j�-| ��r�|�j�| ��|�j�| ��t |�j.t��r�zt/|�j.�|�_.W�n�t0�y����t1d%��Y�n0�d�S�)&Nr���)� sysconfigZbuild)r'���r'���)r)���r)���)r2���r2���)r���r���)r ���r ���)r6���r6���)r(���r(�������)Z plat_specificZincluder.���r1����ntZlibsZDebugZRelease�_home�win32����ZPCbuild�����cygwin�bin�lib�pythonZconfig�.�Py_ENABLE_SHAREDZLIBDIR�,c�����������������S���s���g�|�]}|d�f�qS�)�1r���)�.0�symbolr���r���r���� <listcomp>���������z.build_ext.finalize_options.<locals>.<listcomp>� zparallel should be an integer)2� distutilsr:���Zset_undefined_optionsr*����distributionZext_packageZext_modulesr&���Zget_python_incr+���� isinstance�str�split�os�pathsep�sys�exec_prefix�base_exec_prefix�append�path�join�extendZensure_string_listr.���r/���r0����name�prefixr���r)����dirnamer����getattrr(����platform� executable� startswithr����get_config_varZpython_buildr,���r-���r5���r%���r����isdirr6����int� ValueErrorZDistutilsOptionError) r8���r:���Z py_includeZplat_py_includeZ _sys_home�suffixZnew_libZdefinesZuser_includeZuser_libr���r���r����finalize_options����s������ � �zbuild_ext.finalize_optionsc�����������������C���sj��ddl�m}�|�jsd�S�|�j���rL|��d�}|�j�|���p:g���|�j � |j��||�j|�j |�j|�jd�|�_t|�j��tjdkr�|�jt��kr�|�j�|�j��|�jd�ur�|�j�|�j��|�jd�ur�|�jD�]\}}|�j�||��q�|�jd�ur�|�jD�]}|�j�|��q�|�jd�u�r|�j�|�j��|�j d�u�r*|�j�|�j ��|�jd�u�rD|�j�|�j��|�j d�u�r^|�j�!|�j ��|��"���d�S�)Nr���)�new_compiler� build_clib)r2����verbose�dry_runr ���r<���)#r���ri���r&���rO���Zhas_c_libraries�get_finalized_commandr.���r[���Zget_library_namesr/���rX���rj���r2���rk���rl���r ���r���rS���r\���r(���r ���Z initializer+���Zset_include_dirsr,���Zdefine_macror-���Zundefine_macroZ set_librariesZset_library_dirsr0���Zset_runtime_library_dirsr1���Zset_link_objects�build_extensions)r8���ri���rj���r\����value�macror���r���r����run��s@���� � z build_ext.runc����������� ������C���sv��t�|t�std��t|�D��]T\}}t�|t�r0qt�|t�rFt|�dkrNtd��|\}}t�d|��t�|t �rvt �|�s~td��t�|t�s�td��t||d��}dD�]"}|� |�}|d ur�t|||��q�|� d �|_d|v�r�t�d��|� d �}|�rhg�|_g�|_|D�]b} t�| t��r"t| �dv��s*td��t| �dk�rJ|j�| d���nt| �dk�r|j�| ���q|||<�qd S�)a���Ensure that the list of extensions (presumably provided as a command option 'extensions') is valid, i.e. it is a list of Extension objects. We also support the old-style list of 2-tuples, where the tuples are (ext_name, build_info), which are converted to Extension instances here. Raise DistutilsSetupError if the structure is invalid anywhere; just returns otherwise. z:'ext_modules' option must be a list of Extension instances����zMeach element of 'ext_modules' option must be an Extension instance or 2-tuplezvold-style (ext_name, build_info) tuple found in ext_modules for extension '%s' -- please convert to Extension instancezRfirst element of each tuple in 'ext_modules' must be the extension name (a string)zOsecond element of each tuple in 'ext_modules' must be a dictionary (build info)�sources)r+���r/���r.���� extra_objects�extra_compile_args�extra_link_argsNr0���Zdef_filez9'def_file' element of build info dict no longer supported�macros)r;���rr���z9'macros' element of build info dict must be 1- or 2-tupler;���r���)rP����list�DistutilsSetupError� enumerater����tuple�lenr ����warnrQ����extension_name_re�match�dict�get�setattr�runtime_library_dirs� define_macros�undef_macrosrX���) r8���r&���r����ext�ext_nameZ build_info�key�valrw���rp���r���r���r����check_extensions_listV��s^���� � �� �� � �zbuild_ext.check_extensions_listc�����������������C���s,���|���|�j��g�}|�jD�]}|�|j��q|S��N)r����r&���r[���rs���)r8���� filenamesr����r���r���r����get_source_files���s ���� zbuild_ext.get_source_filesc�����������������C���s2���|���|�j��g�}|�jD�]}|�|��|j���q|S�r����)r����r&���rX����get_ext_fullpathr\���)r8���Zoutputsr����r���r���r����get_outputs���s ���� zbuild_ext.get_outputsc�����������������C���s(���|���|�j��|�jr|�����n|�����d�S�r����)r����r&���r6����_build_extensions_parallel�_build_extensions_serialr7���r���r���r���rn������s���� zbuild_ext.build_extensionsc�������������� ������s�����j�}�j�du�rt���}zddlm}�W�n�ty>���d�}Y�n0�|d�u�rT�����d�S�||d��n�����fdd��jD��}t�j|�D�]:\}}�� |���|� ���W�d�����q�1�s�0����Y��q�W�d�����n1�s�0����Y��d�S�)NTr���)�ThreadPoolExecutor)�max_workersc��������������������s���g�|�]}�����j|��qS�r���)�submit�build_extension)rI���r������executorr8���r���r���rK������s����z8build_ext._build_extensions_parallel.<locals>.<listcomp>)r6���rS���� cpu_count�concurrent.futuresr�����ImportErrorr����r&����zip�_filter_build_errors�result)r8����workersr�����futuresr����Zfutr���r����r���r�������s"���� �z$build_ext._build_extensions_parallelc�������������� ���C���sD���|�j�D�]8}|��|���|��|��W�d�����q1�s40����Y��qd�S�r����)r&���r����r����)r8���r����r���r���r���r�������s���� z"build_ext._build_extensions_serialc�������������� ���c���sV���z d�V��W�nF�t�ttfyP�}�z(|js(��|��d|j|f���W�Y�d�}~n d�}~0�0�d�S�)Nz"building extension "%s" failed: %s)ZCCompilerErrorZDistutilsErrorZCompileErrorZoptionalr}���r\���)r8���r�����er���r���r���r�������s���� �zbuild_ext._filter_build_errorsc����������� ������C���sP��|j�}|d�u�st|ttf�s*td|j���t|�}|��|j�}||j�}|�j slt ||d�slt�d|j��d�S�t� d|j��|��||�}|jp�g�}|jd�d���}|jD�]}|�|f��q�|�jj||�j||j|�j||jd�}|d�d���|�_|jr�|�|j��|j�pg�}|j�p|�j�|�} |�jj|||��|�|j|j ||��!|�|�j|�j| d� �d�S�)Nzjin 'ext_modules' option (extension '%s'), 'sources' must be present and must be a list of source filenamesZnewerz$skipping '%s' extension (up-to-date)zbuilding '%s' extension)Z output_dirrw���r+���r����extra_postargs�depends)r.���r/���r����r�����export_symbolsr���r)���Ztarget_lang)"rs���rP���rx���r{���ry���r\����sortedr����r����r ���r���r ���r����info�swig_sourcesru���r����r����rX���r2����compiler)���r+���Z_built_objectsrt���r[���rv����languageZdetect_languageZlink_shared_object� get_librariesr/���r�����get_export_symbols) r8���r����rs����ext_pathr����� extra_argsrw���r-���Zobjectsr����r���r���r���r�������sV������ � �zbuild_ext.build_extensionc�����������������C���s$��g�}g�}i�}|�j�rt�d��|�j�s6d|�jv�s6d|jv�r<d}nd}|D�]P}tj�|�\}} | dkr�|�|d�|���|�|��|d�||<�qD|�|��qD|s�|S�|�jp�|�� ��} | dg}|� |�j��|�j�r�|�d��|�js�|jD�]}|�|��q�|D�].}||�} t�d || ��|��|d | |g���q�|S�)z�Walk the list of source files in 'sources', looking for SWIG interface (.i) files. Run SWIG on all that are found, and return a modified 'sources' list with SWIG source files replaced by the generated C (or C++) files. z/--swig-cpp is deprecated - use --swig-opts=-c++z-c++z.cppz.cz.i�_wrap���z-pythonzswigging %s to %sz-o) r4���r ���r}���r5���rS���rY����splitextrX���r3���� find_swigr[���r�����spawn)r8���rs���� extensionZnew_sourcesr����Zswig_targetsZ target_ext�source�baser����r3���Zswig_cmd�o�targetr���r���r���r����2��s@���� � zbuild_ext.swig_sourcesc�����������������C���s^���t�jdkrdS�t�jdkrLdD�]*}t�j�d|�d�}t�j�|�r|��S�qdS�tdt�j���dS�) z�Return the name of the SWIG executable. On Unix, this is just "swig" -- it should be in the PATH. Tries a bit harder on Windows. �posixr3���r<���)z1.3z1.2z1.1z c:\swig%szswig.exez>I don't know how to find (much less run) SWIG on platform '%s'N)rS���r\���rY���rZ����isfileZDistutilsPlatformError)r8���Zvers�fnr���r���r���r����h��s���� ��zbuild_ext.find_swigc�����������������C���s����|���|�}|�d�}|��|d��}|�jsRtjj|dd��|g���}tj�|�j|�S�d�|dd���}|��d�}tj� |� |��}tj�||�S�)z�Returns the path of the filename for a given extension. The file is located in `build_lib` or directly in the package (inplace option). rE���r����Nr����build_py)�get_ext_fullnamerR����get_ext_filenamer���rS���rY���rZ���r'���rm����abspathZget_package_dir)r8���r�����fullname�modpath�filenamer*���r����Zpackage_dirr���r���r���r�������s���� zbuild_ext.get_ext_fullpathc�����������������C���s ���|�j�du�r|S�|�j�d�|�S�dS�)zSReturns the fullname of a given extension name. Adds the `package.` prefixNrE���)r*���)r8���r����r���r���r���r�������s���� zbuild_ext.get_ext_fullnamec�����������������C���s.���ddl�m}�|�d�}|d�}tjj|��|�S�)z�Convert the name of an extension (eg. "foo.bar") into the name of the file from which it will be loaded (eg. "foo/bar.so", or "foo\bar.pyd"). r����rc���rE���Z EXT_SUFFIX)�distutils.sysconfigrc���rR���rS���rY���rZ���)r8���r����rc���r����Z ext_suffixr���r���r���r�������s���� zbuild_ext.get_ext_filenamec�����������������C���sv���d|j��d�d��}z|�d��W�n.�tyP���d|�d��dd��d��}Y�n0�d |�}||jvrp|j�|��|jS�) a��Return the list of symbols that a shared extension has to export. This either uses 'ext.export_symbols' or, if it's not provided, "PyInit_" + module_name. Only relevant on Windows, where the .pyd file (DLL) must export the module "PyInit_" function. �_rE���r�����asciir���Zpunycode����-����_ZPyInit)r\���rR����encode�UnicodeEncodeError�replace�decoder����rX���)r8���r����rg���Z initfunc_namer���r���r���r�������s����" zbuild_ext.get_export_symbolsc�����������������C���s����t�jdkr^ddlm}�t|�j|�s�d}|�jr4|d�}|t�jd?�t�jd?�d@�f�}|j|g�S�n�dd l m }�d }|d�r�tt�d�r�d }n<t�jdkr�d }n,dtj v�r�|d�dkr�d }n|d�dkr�d }|r�|d�}|jd|�g�S�|jS�)z�Return the list of libraries to link against when building a shared extension. On most platforms, this is just 'ext.libraries'; on Windows, we add the Python library (eg. python20.dll). r>���r���)�MSVCCompilerz python%d%dZ_d������������r����FrF����getandroidapilevelTrA���Z_PYTHON_HOST_PLATFORMZANDROID_API_LEVELZMACHDEPZ LDVERSIONrD���)rU���r`���Zdistutils._msvccompilerr����rP���r2���r���� hexversionr.���r����rc����hasattrrS����environ)r8���r����r�����templateZ pythonlibrc���Zlink_libpythonZ ldversionr���r���r���r�������s4���� � zbuild_ext.get_libraries) �__name__� __module__�__qualname__�descriptionrS���rT���Zsep_byr ���Zuser_optionsZboolean_optionsr ���Zhelp_optionsr9���rh���rq���r����r����r����rn���r����r����� contextlib�contextmanagerr����r����r����r����r����r����r����r����r����r���r���r���r���r���!���sn��� �����+���@N L6 r���)�__doc__r����rS����rerU���Zdistutils.corer���Zdistutils.errorsr����r���r���r���Zdistutils.dep_utilr���Zdistutils.extensionr���Zdistutils.utilr ���rN���r ���Zsiter���r����r~���r ���r���r���r���r���r����<module>���s$����