Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
util.cpython-313.pyc106 linesDownload Raw Back to __pycache__
1�

2z�j31��l�SrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK4r5SSKJr SSK
Jr SSKrSSKrSSKJr SSKJr SSKJrJr S!SjrS	rS6r"SS5r\(d\"5r\R;5 S
rSrSr Sr!Sq"Sq#\	RHS:Xa=\"\%5RLRLRLr'\("\'RS55r)Sr*Sr+Sr,Sr-\-///S4Sj5r.\-///SS4Sj5r/"SS\5r0S!Sjr1"SS5r2Sr3\RhS 5r5g)"z�7Utility functions for8 9- building and importing modules on test time, using a temporary location10- detecting if compilers are present11- determining paths to tests12 13�N)�
import_module)�Path)�	asunicode)�MesonBackend)�IS_WASM�temppathc��[RS:Xa[R"SSS9 [R14"5n[RRUS5n[US5nURS5 URSUS	35 U(aLURUS15US	35 URUSUS35 URS
USUSUSUS3	5 SSS5 [R"/SQSUSS9nWRS:H[R "U5 $!,(df   NM=f![Ra [R"SSS9 Naf=f![R "U5 f=f)N�win32z*No Fortran tests on Windows (Issue #25134)T)�allow_module_levelzmeson.build�wzproject('check_compilers')16zadd_languages('z')17z _compiler = meson.get_compiler('z_code = '''z'''18�_have_z19_feature =z_compiler.compiles(z_code, name: 'z feature check')20)�meson�setup�btmpF)�check�cwd�capture_outputz3meson not present, skipping compiler dependent testr)�sys�platform�pytest�skip�tempfile�mkdtemp�os�path�join�open�write�21subprocess�run�CalledProcessError�22returncode�shutil�rmtree)�lang�code_snippet�tmpdir�23meson_file�f�runmesons      �[D:\code\apps\devtools\python\user_packages\Python313\site-packages\numpy/f2py/tests/util.py�check_languager, s]��24�|�|�w�����@�UY�Z�
�
�
�
�F���W�W�\�\�&�-�8�25�
�*�c�
"�a�
�G�G�2�3�
�G�G�o�d�V�4�0�1�����4�&� @���d�K�L����4�&��L�>��?�@�����T�F�*��f�/��v�6�#�f�$6�8��
#�	h�!�~�~�*���#�	�H��"�"�a�'��
�
�f��-#�
"��$�,�,�	h��K�K�M�bf�g�	h��	�
�
�f��sI�,E-�,A:D-�&E-�/D>�E-�-26D;�7E-�>)E*�'E-�)E*�*E-�-Fz]27C Example Fortran 77 code28      PROGRAM HELLO29      PRINT *, 'Hello, Fortran 77!'30      END31z�32! Example Fortran 90 code33program hello9034  type :: greeting35    character(len=20) :: text36  end type greeting37 38  type(greeting) :: greet39  greet%text = 'hello, fortran 90!'40  print *, greet%text41end program hello9042c� �\rSrSrSrSrSrg)�CompilerChecker�Tc�<�SUlSUlSUlSUlg)NF��compilers_checked�has_c�has_f77�has_f90��selfs r+�__init__�CompilerChecker.__init__Us��!&�����43�������c���UR(d�[RS:Xd�[RR5nUR
[S5UR
[S[5UR
[S[5/nUSR5UlUSR5UlUSR5Ul
SSS5 SUlggg!,(df   N=f)N�cygwin�c�fortranr��T)r2rr�44concurrent�futures�ThreadPoolExecutor�submitr,�fortran77_code�fortran90_code�resultr3r4r5)r7�executorrBs   r+�check_compilers�CompilerChecker.check_compilers[s����&�&�����1I��#�#�6�6�8�H��O�O�N�C�8��O�O�N�I�~�N��O�O�N�I�~�N���%�Q�Z�.�.�0��45�&�q�z�0�0�2���&�q�z�0�0�2���9�&*�D�"�2J�&�8�8�s
�BC*�*46C8r1N)�__name__�47__module__�__qualname__�__firstlineno__r8rI�__static_attributes__�r:r+r.r.Ts���
*r:r.c�"�[R$�N)�checkerr3rPr:r+�has_c_compilerrTos���=�=�r:c�"�[R$rR)rSr4rPr:r+�has_f77_compilerrVr����?�?�r:c�"�[R$rR)rSr5rPr:r+�has_f90_compilerrYurWr:c�P�[R=(a [R$rR)rSr5r4rPr:r+�has_fortran_compilerr[xs���O�O�/����0r:ir<z**/*.dllc���[bB[RR[5 [48R"[5 Sqgg![a N+f=f![a N f=frR)�_module_dirrr�remove�49ValueErrorr#r$�OSErrorrPr:r+�_cleanupra�sa����	��H�H�O�O�K�(�	��M�M�+�&������	��	���	��	�s"�#A�A�50A�A�51A(�'A(c���[ck[R"5q[R"[525 [[R;a$[RRS[5 [$)Nr)	r]rr�atexit�registerrarr�insertrPr:r+�get_module_dirrf�sF�����&�&�(������!��c�h�h�&��H�H�O�O�A�{�+��r:c�|�[5 S[-n[S-
qU[R;a[	S5eU$)Nz_test_ext_module_%dr?z%Temporary module name already in use.)rf�_module_numr�modules�RuntimeError)�names r+�get_temp_module_namerl�s;���� �;�.�D��1��K��s�{�{���B�C�C��Kr:c�>^^�0mUU4SjnTRUlU$)Nc�>�[X45nUT;aT"U0UD6TU'TUn[U[5(aUeU$![anUTU'eSnAff=frR)�repr�	Exception�53isinstance)�a�kw�key�e�ret�func�memos     ��r+�wrapper�_memoize.<locals>.wrapper�sk����A�7�m���d�?�
� �!�N�r�N��S�	��3�i���c�9�%�%��I��54��
�
���S�	���
�s�>�55A�A�A)rK)rwryrxs` @r+�_memoizer{�s ���
�D���}�}�G���Nr:c	�T�S[R<S3n[5n[5(d[R56"S5 /n/nUH�n	[RRU	5(d[U	S35e[RRU[RRU	55n57[R"X�5 URU585 [RRU595up�US;dM�URU605 M� U(deUc61[5n/n
SU;a	SU;aS/n
S	S62U/U-U
-U-nUSS/-
nU(a	US
/U--
nU(a	US/U--
n[R "5n[R""U5 [R$S	U/U-n[&R("U[&R*[&R,S9nUR/5unnUR0S:wa[SUSSS[3U535e[R""U5 UHn	[R4"U	5 M [R6S:Xai[8R;[<R<"[RRXdSS3555 [&R>"/SQ[8-5 [AU5$![R""U5 UHn	[R4"U	5 M f=f)z@63Compile and import a f2py module, built from the given files.64 65zimport sys; sys.path = z&; import numpy.f2py; numpy.f2py.main()�No Fortran compiler availablez is not a file)�.f90z.f95�.fz.c�.pyfNz--freethreading-compatiblez--no-freethreading-compatiblez-cz-mz	--backendrzskip:zonly:)�stdout�stderrrzRunning f2py failed: ��66r<�s�*)z/usr/bin/rebasez67--databasez--obliviousz	--verbose)!rrrfr[rrr�isfilerjr�basenamer#�copyfile�append�splitextrl�getcwd�chdir�68executabler�Popen�PIPE�STDOUT�communicater"r�unlinkr�_module_list�extend�glob�69check_callr)�source_files�optionsr�only�module_name�code�d�dst_sources�f2py_sources�fn�dst�base�ext�gil_options�	f2py_optsr�cmd�p�out�errs                    r+�build_moduler��s���%�S�X�X�L�0V�W�D���A��!�!����3�4��K��L����w�w�~�~�b�!�!��"��^�4�5�5��g�g�l�l�1�b�g�g�.�.�r�2�3������ ����3���G�G�$�$�S�)�	���6�6�����$����<���*�,���K�#�7�2�7V�^e�7e�3�4���t�[�)�G�3�k�A�L�P�I�
�+�w�'�'�I���g�Y��%�%�	���g�Y��%�%�	�
�)�)�+�C��70������~�~�t�T�*�Y�6�����S�$.�O�O�$.�$5�$5�
7���=�=�?���S��<�<�1���!6�s�1�2�w�i�r�)�C�.�AQ�R�S�S��	����
��B��I�I�b�M���|�|�x��	����I�I�b�g�g�l�l�1�Q��q�&9�:�;�	71�	���I��
�	72���%�%��)	����
��B��I�I�b�M��s
�BK0�07L'c	���UcSn[US9n[US5nURU5 SSS5 [U/UUUUS9sSSS5 $!,(df   N%=f!,(df   g=f)z.73Compile and import Fortran code using f2py.74 75Nr)�suffixr�r�rr�r�)rrrr�)�source_coder�rr�r�r�rr)s        r+�76build_coder�sc���~���	��	 �D�
�$��_��
�G�G�K� ���T�F�$+�!%�!%�(3�	5�77!�	 �
�_��78!�	 �s!�
A�A
�A�
79A	�A�80A,c�.^�\rSrSrU4SjrSrSrU=r$)�SimplifiedMesonBackendi0c�&>�[TU]"U0UD6 grR)�superr8)r7�args�kwargs�	__class__s   �r+r8�SimplifiedMesonBackend.__init__1s���
���$�)�&�)r:c�p�URUR5 URUR5 grR)�write_meson_build�	build_dir�	run_mesonr6s r+�compile�SimplifiedMesonBackend.compile4s$�����t�~�~�.����t�~�~�&r:rP)rKrLrMrNr8r�rO�
__classcell__)r�s@r+r�r�0s���*�'�'r:r�c	� �[5(d[R"S5 [5nUc81[	5n[S0SU_SU_SUR
S/5_SU_SUR
S/5_SUR
S/5_SUR
S/5_S	UR
S	/5_S82UR
S83/5_SUR
S/5_SUR
S/5_S
UR
S
/5_SUR
S/5_SUR
S/5_SUR
SS5_SUR
S05_6nUR5 [RRSUSUR35 [U5$)z)84Build a module via Meson and import it.85r}�86modulename�sources�
extra_objectsr��include_dirs�library_dirs�	libraries�
define_macros�undef_macros�87f2py_flags�
sysinfo_flags�fc_flags�88flib_flags�setup_flags�remove_build_dirF�	extra_datr�/rP)
r[rrrfrlr��getr�rrre�meson_build_dirr)r�r�r�r��backends     r+�build_mesonr�9s��� �!�!����3�4�� �I���*�,��%�������j�j��"�5���	�89�Z�Z���3���Z�Z���3�
��*�*�[�"�-���j�j��"�5���Z�Z���3���:�:�l�B�/���j�j��"�5�����J��+���:�:�l�B�/���J�J�}�b�1�� ���$6��>�� �*�*�[�"�-�!�G�&�O�O���H�H�O�O�A�)��A�g�&=�&=�%>�?�@���%�%r:c�b�\rSrSrSrSr/r/r/rSr	Sr90SrSrSr
\S5r\S5rSrSrg)�F2PyTestifNrc�x�[U5nSURRSS5SSURS3$)N�_�.r?������_ext_module)�typerL�rsplitrK)r7�clss  r+r��F2PyTest.module_namers;���4�j���3�>�>�(�(��a�0��4�5�Q�s�|�|�n�K�P�Pr:c���[RS:Xa[R"S5 [	5[91l[5[92l[5[93l94[5[95lg)Nr96z)Fails with MinGW64 Gfortran (Issue #9673))
rrrrrTr��_has_c_compilerrV�_has_f77_compilerrY�_has_f90_compilerr[�_has_fortran_compiler)r�s r+�setup_class�F2PyTest.setup_classwsG���<�<�7�"��K�K�C�D�#1�#3�� �%5�%7��"�%5�%7��"�)=�)?��&r:c	�~�URbgUR=(d /nUR(aURUR5 [SU55n[SU55n[SU55nU(a'UR(d[R"S5 U(a'UR(d[R"S5 U(a'UR(d[R"S5 URbO[URURURURURURS9UlURbE[URURURURURS9Ulgg)	Nc3�V# �UHn[U5RS5v� M! g7f)rN��str�endswith��.0r�s  r+�	<genexpr>�(F2PyTest.setup_method.<locals>.<genexpr>�s"���?��2��B��(�(��.�.����')c3�V# �UHn[U5RS5v� M! g7f)r~Nr�r�s  r+r�r���"���A�5�R��B��(�(��0�0�5�r�c3�V# �UHn[U5RS5v� M! g7f)r�Nr�r�s  r+r�r��r�r�z No Fortran 77 compiler availablez No Fortran 90 compiler availabler})r�rr�r�r�r�)�moduler�r�r�r��anyr�rrr�r�r�r�r�r�r�)r7�codes�	needs_f77�	needs_f90�	needs_pyfs     r+�setup_method�F2PyTest.setup_method�s2���;�;�"�����"����9�9��L�L����%��?��?�?�	��A�5�A�A�	��A�5�A�A�	��T�3�3��K�K�:�;��T�3�3��K�K�:�;��T�7�7��K�K�7�8��9�9� �$��	�	�����Y�Y��Y�Y��{�{� �,�,�
�D�K��<�<�#�&��������Y�Y��Y�Y� �,�,��D�K�$r:)r�)rKrLrMrNr�r�r�rr�r�r�r�r�r��propertyr��classmethodr�r�rOrPr:r+r�r�fse���D��G��G�
�D�
�D�
�F�
�F��O�����
�Q��Q��@��@�%r:r�c��[[RR5RR5nUR"U6$rR)r�numpy�f2py�__file__�parent�resolve�joinpath)rrr�s  r+�getpathr�s3���U�Z�Z�
 �
 �!�(�(�0�0�2�A��:�:�q�>�r:c#��# �[R"5n[R"U5 Sv� [R"U5 g![R"U5 f=f7frR)rrrr�)r�curpaths  r+�	switchdirr�s;����h�h�j�G��H�H�T�N��
�97�����������s�,A%�A98�A%�99A"�"A%rR)6�__doc__rc�concurrent.futuresrA�100contextlibr�rr#rrr�	importlibr�pathlibrrr��numpy._utilsr�numpy.f2py._backends._mesonr�
numpy.testingrrr,rErFr.rSrIrTrVrYr[r]rhrrr�NUMPY_INSTALL_ROOT�listr�rarfrlr{r�r�r�r�r�r�contextmanagerrrPr:r+�<module>rsc�������	�
��101��#��
��"�4�+��>����*�*�.���G��������1������<�<�8���h��.�.�5�5�<�<���*�/�/�102�;�<�L���	��2103�')����K&�104�K&�\105������5�106�5�6'�\�'�%&�Z?�?�N������r:
codekingpro/portable-devtools · Team Ai