add-determinism 0.7.3

RPM buildroot helper to strip nondeterministic bits in files
Documentation
�

��Vc�?cs�dZddlZddlZddlZddlmZmZmZddlZddl	m
Z
ddlmZddl
mZmZmZmZddlmZddlmZd	�ZGd
�de
��ZGd�d
e��ZdZdZdZd�Zejd��Zd�Zd�Z d�Z!dS)adistutils.cygwinccompiler

Provides the CygwinCCompiler class, a subclass of UnixCCompiler that
handles the Cygwin port of the GNU C compiler to Windows.  It also contains
the Mingw32CCompiler class which handles the mingw32 port of GCC (same as
cygwin in no-cygwin mode).
�N)�Popen�PIPE�check_output)�
UnixCCompiler)�
write_file)�DistutilsExecError�CCompilerError�CompileError�UnknownFileError)�LooseVersion)�find_executablecs�tj�d��}|dkrYtj|dz|dz�}|dkrdgS|dkrdgS|d	krd
gS|dkrdgS|d
krdgStd|z���dS)zaInclude the appropriate MSVC runtime library if Python was built
    with MSVC 7.0 or later.
    zMSC v.i����ii
Z1300Zmsvcr70Z1310Zmsvcr71Z1400Zmsvcr80Z1500Zmsvcr90Z1600Zmsvcr100zUnknown MS Compiler version %s N)�sys�versionZfindZ
ValueError)Zmsc_posZmsc_ver�  �2/usr/lib64/python3.11/distutils/cygwinccompiler.py�	get_msvcrr=s����k���x�(�(�G��"�}�J��+�g�a�i���
�2�3���f��	J��;��
��
�
	J��;��
��
�
	J��;��
��
�	J��;��
��
�	J��<���>��H�I�I�I�%J�J�csT�eZdZdZdZdZdZdZdZdZ	dZ
dd
�Zd�Z				dd
�Z
dd�ZdS)�CygwinCCompilerz? Handles the Cygwin port of the GNU C compiler to Windows.
    Zcygwinz.o�.az.dllzlib%s%sz%s%sz.exerc
s��tj||||��t��\}}|�d|�d|�d���|tur|�d|z��t
��\|_|_|_	|�|j
d|j�d|j�d|j	�d�z��|jd	krd
|_nd|_|jdkrd
}nd}|�dddd|j�d|�����|jdkrdg|_
|�d��dSt��|_
dS)NzPython's GCC status: z (details: z)z�Python's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.z: gcc z, ld z
, dllwrap z
z2.10.90�gcc�dllwrap�2.13�-shared�
-mdll -staticzgcc -mcygwin -O -Wallzgcc -mcygwin -mdll -O -Wallzg++ -mcygwin -O -Wallzgcc -mcygwinz
 -mcygwin �Zcompiler�compiler_soZcompiler_cxxZ
linker_exeZ	linker_so�2.91.57Zmsvcrtz,Consider upgrading to a newer version of gcc)r�__init__�check_config_hZdebug_print�CONFIG_H_OKZwarn�get_versions�gcc_version�
ld_versionZdllwrap_version�
compiler_type�
linker_dll�set_executables�
dll_librariesr)�self�verbose�dry_run�forceZstatusZdetails�
shared_options       rrzCygwinCCompiler.__init__bs�����t�W�g�u�=�=�=�(�*�*�������� �&�&�'�'�'�+�	,�	,�	,���$�	��I�I�O���
�
�
�
�N�N�	@���$�/�4�+?�����+�+��*�*�*��/�/�/��.�.�.�/0�0�	2�	2�	2��?�i�'�	(�#�D�O�O�'�D�O��?�f�$�	,�%�M�M�+�M�	
���&=�)F�*A�(6�)-����-�-�)I�		�	K�	K�	K���y�(�		-�!)�z�D���I�I�>�
@�
@�
@�
@�
@�
"+���D���rcs*�|dks|dkr>	|�dd|d|g��dS#t$r}t|���d}~wwxYw	|�|j|z|d|gz|z��dS#t$r}t|���d}~wwxYw)z:Compiles the source by spawning GCC and windres if needed.�.rc�.resZwindresz-iz-oN)Zspawnrrr)r&ZobjZsrc�extZcc_args�extra_postargsZpp_optsZmsg�        r�_compilezCygwinCCompiler._compile�s����%�<�	(�3�&�=�	(�
(��
�
�I�t�S�$��<�=�=�=�=�=��%�
(�
(�
(�"�3�'�'�'�����
(����
(��
�
�4�+�g�5��d�C�8H�H�)�*�+�+�+�+�+��%�
(�
(�
(�"�3�'�'�'�����
(���s,�*�
A�A�A�&A4�4
B�>B
�
BNcs�tj|
pg��}
tj|pg��}tj|pg��}|�|j��|��r||jks|jdk�r[t
j�|d��}t
j�t
j�	|����\}}t
j�
||dz��}t
j�
|d|zdz��}dt
j�	|��zdg}|D]}|�|���|�t||fd	|z��|jd
kr/|
�d|g��|
�d|g��n|�|��|	s|
�d
��tj||||||||d|	|
|||
��dS)zLink the objects.Nrrz.defZlibrz
LIBRARY %sZEXPORTSz
writing %srz--output-libz--defz-s)�copyZextendr%Z
EXECUTABLEr#�os�pathZdirname�splitext�basename�join�appendZexecuterr�link)r&Ztarget_descZobjectsZoutput_filename�
output_dirZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsZdebugZ
extra_preargsr.Z
build_tempZtarget_langZtemp_dirZdll_nameZ
dll_extensionZdef_fileZlib_fileZcontentsZsyms                     rr8zCygwinCCompiler.link�s+���	�-�"5�2�6�6�
��I�i�o�2�.�.�	��)�G�M�r�*�*��	����+�,�,�,��(	)�
�D�O�
+�(	)�/3��%�/G�(	)��w���w�q�z�2�2�H�(*��(8�(8��� � ��1�1�)3�)3�%�X�}��w�|�|�H�h��.?�@�@�H��w�|�|�H�e�h�.>��.E�F�F�H��r�w�/�/��@�@�@���H�&�
%�
%������$�$�$�$��L�L��h��%9�%��0�
2�
2�
2���)�+�	
)��$�$�n�h�%?�@�@�@��$�$�g�x�%8�9�9�9�9����x�(�(�(��	'�� � ��&�&�&���4��g��%�y�,�/�� �-���&�	(�	(�	(�	(�	(r�cs$�|�d}g}|D�]}tj�tj�|����\}}||jddgzvrtd|�d|�d����|rtj�|��}|dvr?|�tj�|||z|j	z������|�tj�|||j	z������|S)	z#Adds supports for rc and res files.Nr:r+r,zunknown file type 'z	' (from 'z'))r,r+)
r2r3r4ZnormcaseZsrc_extensionsr	r5r7r6�
obj_extension)r&Zsource_filenamesZ	strip_dirr9Z	obj_namesZsrc_nameZbaser-r/r�object_filenamesz CygwinCCompiler.object_filenames�sI���	��J��	�(�	K�	K�H���(�(���)9�)9�(�)C�)C�D�D�I�D�#��4�.�%���?�@�
'�&�&��s�s�H�H�H�(&�'�'�'��
/��w�'�'��.�.���o�%�
K�� � �"�'�,�,�z�.2�S�j�4�;M�.M�#O�#O�P�P�P�P�� � �"�'�,�,�z�/3�d�6H�/H�#J�#J�K�K�K�K��r�rrr)
NNNNNrNNNN)rr:)�__name__�
__module__�__qualname__�__doc__r"r;Zstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionrr0r8r<�rrrrWs����������M��M���!��!�����M�9-�9-�9-�9-�v
(�
(�
(�FJ�EI�9=�?C�J(�J(�J(�J(�\�����rrcs�eZdZdZdZdd�ZdS)�Mingw32CCompilerz@ Handles the Mingw32 port of the GNU C compiler to Windows.
    Zmingw32rcs<�t�||||��|jdkrd}nd}|jdkrd}nd}t	��rtd���|�dd	d
d|j�d|�d|���
��g|_t��|_dS)Nrrrrz--entry _DllMain@12r:z1Cygwin gcc cannot be used with --compiler=mingw32zgcc -O -Wallzgcc -mdll -O -Wallzg++ -O -Wallrz r)
rrr!r �is_cygwingccrr$r#r%r)r&r'r(r)r*Zentry_points      rrzMingw32CCompiler.__init__s���� � �$���%�@�@�@��?�f�$�	,�%�M�M�+�M���y�(�	�/�K�K��K��>�>�	E� �C�E�E�
E�	
���n�)=�*8�(-�+/�?�?�?�M�M�M�+6�;�(8�		�	9�	9�	9����'�[�[����rNr=)r>r?r@rAr"rrBrrrCrCs7���������M�&)�&)�&)�&)�&)�&)rrCZokznot okZ	uncertaincs��ddlm}dtjvr	tdfS|���}	t
|��}	d|���vr td|zf|���Std|zf|���S#|���wxYw#t$r}td|�d	|j��fcYd
}~Sd
}~wwxYw)awCheck if the current Python installation appears amenable to building
    extensions with GCC.

    Returns a tuple (status, details), where 'status' is one of the following
    constants:

    - CONFIG_H_OK: all is well, go ahead and compile
    - CONFIG_H_NOTOK: doesn't look good
    - CONFIG_H_UNCERTAIN: not sure -- unable to read pyconfig.h

    'details' is a human-readable string explaining the situation.

    Note there are two ways to conclude "OK": either 'sys.version' contains
    the string "GCC" (implying that this Python was built with GCC), or the
    installed "pyconfig.h" contains the string "__GNUC__".
    r)�	sysconfigZGCCzsys.version mentions 'GCC'Z__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'zcouldn't read 'z': N)
Z	distutilsrErr
rZget_config_h_filenameZopen�read�close�CONFIG_H_NOTOKZOSError�CONFIG_H_UNCERTAINZstrerror)rEZfnZconfig_hZexcs    rrrFs%��*$�#�#�#�#�#�
����9��8�8�8�
�	(�	(�	*�	*�B�?���8�8��	��X�]�]�_�_�,�
O�"�$>��$C�C�
�N�N�����&�'I�B�'N�N��N�N������H�N�N����������?�?�?�"�"�,.�B�B����=�?�	?�	?�	?�	?�	?�	?�����?���sA�B2�!B�$B2�9B�B2�B/�/B2�2
C�<C�C�Cs(\d+\.\d+(\.\d+)*)cs��|���d}t|���dSt|dt���j}	|���}|���n#|���wxYwt�|��}|�dSt|�
d�������S)z�Find the version of an executable by running `cmd` in the shell.

    If the command is not found, or the output does not match
    `RE_VERSION`, returns None.
    rNT)Zshell�stdouti)ZsplitrrrrJrFrG�
RE_VERSIONZsearchr
ZgroupZdecode)�cmdZ
executableZout�
out_stringZresults     r�_find_exe_versionrNss��������Q��J��z�"�"���t�
��4��
-�
-�
-�
4�C���X�X�Z�Z�
��	�	�������	�	��������
�
�
�z�
*�
*�F�
���t�����Q���.�.�0�0�1�1�1s�	A2�2Bcs<�gd�}td�|D����S)zg Try to find out the versions of gcc, ld and dllwrap.

    If not possible it returns None for it.
    )zgcc -dumpversionzld -vzdllwrap --versioncs,�g|]}t|����SrB)rN)Z.0rLrrz
<listcomp>z get_versions.<locals>.<listcomp>�s!��=�=�=�S�#�C�(�(�=�=�=r)Ztuple)Zcommands� rrr�s-��
B�A�A�H��=�=�H�=�=�=�>�>�>rcsr�tddg��}|����d��S)z>Try to determine if the gcc that would be used is from cygwin.rz-dumpmachinescygwin)rZstripZendswith)rMrOrrDrD�s4���u�n�5�6�6�J������&�&�y�1�1�1r)"rAr2rr1Z
subprocessrrrZreZdistutils.unixccompilerrZdistutils.file_utilrZdistutils.errorsrrrr	Zdistutils.versionr
Zdistutils.spawnrrrrCrrHrIrZcompilerKrNrrDrBrr�<module>rPs�����^
�	�	�	�
�
�
�
�����0�0�0�0�0�0�0�0�0�0�	�	�	�	�1�1�1�1�1�1�*�*�*�*�*�*�(�(�(�(�(�(�(�(�(�(�(�(�*�*�*�*�*�*�+�+�+�+�+�+�J�J�J�4w�w�w�w�w�m�w�w�w�t+)�+)�+)�+)�+)��+)�+)�+)�b���� ��)?�)?�)?�V�R�Z�.�
/�
/�
�2�2�2�*?�?�?�2�2�2�2�2r