numpy 2.4.1__pp311-pypy311_pp73-macosx_14_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- numpy/__config__.py +170 -0
- numpy/__config__.pyi +108 -0
- numpy/__init__.cython-30.pxd +1242 -0
- numpy/__init__.pxd +1155 -0
- numpy/__init__.py +942 -0
- numpy/__init__.pyi +6202 -0
- numpy/_array_api_info.py +346 -0
- numpy/_array_api_info.pyi +206 -0
- numpy/_configtool.py +39 -0
- numpy/_configtool.pyi +1 -0
- numpy/_core/__init__.py +201 -0
- numpy/_core/__init__.pyi +666 -0
- numpy/_core/_add_newdocs.py +7151 -0
- numpy/_core/_add_newdocs.pyi +2 -0
- numpy/_core/_add_newdocs_scalars.py +381 -0
- numpy/_core/_add_newdocs_scalars.pyi +16 -0
- numpy/_core/_asarray.py +130 -0
- numpy/_core/_asarray.pyi +43 -0
- numpy/_core/_dtype.py +366 -0
- numpy/_core/_dtype.pyi +56 -0
- numpy/_core/_dtype_ctypes.py +120 -0
- numpy/_core/_dtype_ctypes.pyi +83 -0
- numpy/_core/_exceptions.py +162 -0
- numpy/_core/_exceptions.pyi +54 -0
- numpy/_core/_internal.py +968 -0
- numpy/_core/_internal.pyi +61 -0
- numpy/_core/_methods.py +252 -0
- numpy/_core/_methods.pyi +22 -0
- numpy/_core/_multiarray_tests.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_multiarray_umath.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_operand_flag_tests.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_rational_tests.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_simd.pyi +35 -0
- numpy/_core/_simd.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_string_helpers.py +100 -0
- numpy/_core/_string_helpers.pyi +12 -0
- numpy/_core/_struct_ufunc_tests.pypy311-pp73-darwin.so +0 -0
- numpy/_core/_type_aliases.py +131 -0
- numpy/_core/_type_aliases.pyi +86 -0
- numpy/_core/_ufunc_config.py +515 -0
- numpy/_core/_ufunc_config.pyi +69 -0
- numpy/_core/_umath_tests.pyi +47 -0
- numpy/_core/_umath_tests.pypy311-pp73-darwin.so +0 -0
- numpy/_core/arrayprint.py +1779 -0
- numpy/_core/arrayprint.pyi +158 -0
- numpy/_core/cversions.py +13 -0
- numpy/_core/defchararray.py +1414 -0
- numpy/_core/defchararray.pyi +1150 -0
- numpy/_core/einsumfunc.py +1650 -0
- numpy/_core/einsumfunc.pyi +184 -0
- numpy/_core/fromnumeric.py +4233 -0
- numpy/_core/fromnumeric.pyi +1735 -0
- numpy/_core/function_base.py +547 -0
- numpy/_core/function_base.pyi +276 -0
- numpy/_core/getlimits.py +462 -0
- numpy/_core/getlimits.pyi +124 -0
- numpy/_core/include/numpy/__multiarray_api.c +376 -0
- numpy/_core/include/numpy/__multiarray_api.h +1628 -0
- numpy/_core/include/numpy/__ufunc_api.c +55 -0
- numpy/_core/include/numpy/__ufunc_api.h +349 -0
- numpy/_core/include/numpy/_neighborhood_iterator_imp.h +90 -0
- numpy/_core/include/numpy/_numpyconfig.h +33 -0
- numpy/_core/include/numpy/_public_dtype_api_table.h +86 -0
- numpy/_core/include/numpy/arrayobject.h +7 -0
- numpy/_core/include/numpy/arrayscalars.h +198 -0
- numpy/_core/include/numpy/dtype_api.h +547 -0
- numpy/_core/include/numpy/halffloat.h +70 -0
- numpy/_core/include/numpy/ndarrayobject.h +304 -0
- numpy/_core/include/numpy/ndarraytypes.h +1982 -0
- numpy/_core/include/numpy/npy_2_compat.h +249 -0
- numpy/_core/include/numpy/npy_2_complexcompat.h +28 -0
- numpy/_core/include/numpy/npy_3kcompat.h +374 -0
- numpy/_core/include/numpy/npy_common.h +989 -0
- numpy/_core/include/numpy/npy_cpu.h +126 -0
- numpy/_core/include/numpy/npy_endian.h +79 -0
- numpy/_core/include/numpy/npy_math.h +602 -0
- numpy/_core/include/numpy/npy_no_deprecated_api.h +20 -0
- numpy/_core/include/numpy/npy_os.h +42 -0
- numpy/_core/include/numpy/numpyconfig.h +185 -0
- numpy/_core/include/numpy/random/LICENSE.txt +21 -0
- numpy/_core/include/numpy/random/bitgen.h +20 -0
- numpy/_core/include/numpy/random/distributions.h +209 -0
- numpy/_core/include/numpy/random/libdivide.h +2079 -0
- numpy/_core/include/numpy/ufuncobject.h +343 -0
- numpy/_core/include/numpy/utils.h +37 -0
- numpy/_core/lib/libnpymath.a +0 -0
- numpy/_core/lib/npy-pkg-config/mlib.ini +12 -0
- numpy/_core/lib/npy-pkg-config/npymath.ini +20 -0
- numpy/_core/lib/pkgconfig/numpy.pc +7 -0
- numpy/_core/memmap.py +363 -0
- numpy/_core/memmap.pyi +3 -0
- numpy/_core/multiarray.py +1740 -0
- numpy/_core/multiarray.pyi +1316 -0
- numpy/_core/numeric.py +2758 -0
- numpy/_core/numeric.pyi +1276 -0
- numpy/_core/numerictypes.py +633 -0
- numpy/_core/numerictypes.pyi +196 -0
- numpy/_core/overrides.py +188 -0
- numpy/_core/overrides.pyi +47 -0
- numpy/_core/printoptions.py +32 -0
- numpy/_core/printoptions.pyi +28 -0
- numpy/_core/records.py +1088 -0
- numpy/_core/records.pyi +340 -0
- numpy/_core/shape_base.py +996 -0
- numpy/_core/shape_base.pyi +182 -0
- numpy/_core/strings.py +1813 -0
- numpy/_core/strings.pyi +536 -0
- numpy/_core/tests/_locales.py +72 -0
- numpy/_core/tests/_natype.py +144 -0
- numpy/_core/tests/data/astype_copy.pkl +0 -0
- numpy/_core/tests/data/generate_umath_validation_data.cpp +170 -0
- numpy/_core/tests/data/recarray_from_file.fits +0 -0
- numpy/_core/tests/data/umath-validation-set-README.txt +15 -0
- numpy/_core/tests/data/umath-validation-set-arccos.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-arccosh.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-arcsin.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-arcsinh.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-arctan.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-arctanh.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-cbrt.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-cos.csv +1375 -0
- numpy/_core/tests/data/umath-validation-set-cosh.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-exp.csv +412 -0
- numpy/_core/tests/data/umath-validation-set-exp2.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-expm1.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-log.csv +271 -0
- numpy/_core/tests/data/umath-validation-set-log10.csv +1629 -0
- numpy/_core/tests/data/umath-validation-set-log1p.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-log2.csv +1629 -0
- numpy/_core/tests/data/umath-validation-set-sin.csv +1370 -0
- numpy/_core/tests/data/umath-validation-set-sinh.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-tan.csv +1429 -0
- numpy/_core/tests/data/umath-validation-set-tanh.csv +1429 -0
- numpy/_core/tests/examples/cython/checks.pyx +373 -0
- numpy/_core/tests/examples/cython/meson.build +43 -0
- numpy/_core/tests/examples/cython/setup.py +39 -0
- numpy/_core/tests/examples/limited_api/limited_api1.c +17 -0
- numpy/_core/tests/examples/limited_api/limited_api2.pyx +11 -0
- numpy/_core/tests/examples/limited_api/limited_api_latest.c +19 -0
- numpy/_core/tests/examples/limited_api/meson.build +59 -0
- numpy/_core/tests/examples/limited_api/setup.py +24 -0
- numpy/_core/tests/test__exceptions.py +90 -0
- numpy/_core/tests/test_abc.py +54 -0
- numpy/_core/tests/test_api.py +655 -0
- numpy/_core/tests/test_argparse.py +90 -0
- numpy/_core/tests/test_array_api_info.py +113 -0
- numpy/_core/tests/test_array_coercion.py +928 -0
- numpy/_core/tests/test_array_interface.py +222 -0
- numpy/_core/tests/test_arraymethod.py +84 -0
- numpy/_core/tests/test_arrayobject.py +75 -0
- numpy/_core/tests/test_arrayprint.py +1324 -0
- numpy/_core/tests/test_casting_floatingpoint_errors.py +154 -0
- numpy/_core/tests/test_casting_unittests.py +955 -0
- numpy/_core/tests/test_conversion_utils.py +209 -0
- numpy/_core/tests/test_cpu_dispatcher.py +48 -0
- numpy/_core/tests/test_cpu_features.py +450 -0
- numpy/_core/tests/test_custom_dtypes.py +393 -0
- numpy/_core/tests/test_cython.py +352 -0
- numpy/_core/tests/test_datetime.py +2792 -0
- numpy/_core/tests/test_defchararray.py +858 -0
- numpy/_core/tests/test_deprecations.py +460 -0
- numpy/_core/tests/test_dlpack.py +190 -0
- numpy/_core/tests/test_dtype.py +2110 -0
- numpy/_core/tests/test_einsum.py +1351 -0
- numpy/_core/tests/test_errstate.py +131 -0
- numpy/_core/tests/test_extint128.py +217 -0
- numpy/_core/tests/test_finfo.py +86 -0
- numpy/_core/tests/test_function_base.py +504 -0
- numpy/_core/tests/test_getlimits.py +171 -0
- numpy/_core/tests/test_half.py +593 -0
- numpy/_core/tests/test_hashtable.py +36 -0
- numpy/_core/tests/test_indexerrors.py +122 -0
- numpy/_core/tests/test_indexing.py +1692 -0
- numpy/_core/tests/test_item_selection.py +167 -0
- numpy/_core/tests/test_limited_api.py +102 -0
- numpy/_core/tests/test_longdouble.py +370 -0
- numpy/_core/tests/test_mem_overlap.py +933 -0
- numpy/_core/tests/test_mem_policy.py +453 -0
- numpy/_core/tests/test_memmap.py +248 -0
- numpy/_core/tests/test_multiarray.py +11008 -0
- numpy/_core/tests/test_multiprocessing.py +55 -0
- numpy/_core/tests/test_multithreading.py +377 -0
- numpy/_core/tests/test_nditer.py +3533 -0
- numpy/_core/tests/test_nep50_promotions.py +287 -0
- numpy/_core/tests/test_numeric.py +4295 -0
- numpy/_core/tests/test_numerictypes.py +650 -0
- numpy/_core/tests/test_overrides.py +800 -0
- numpy/_core/tests/test_print.py +202 -0
- numpy/_core/tests/test_protocols.py +46 -0
- numpy/_core/tests/test_records.py +544 -0
- numpy/_core/tests/test_regression.py +2677 -0
- numpy/_core/tests/test_scalar_ctors.py +203 -0
- numpy/_core/tests/test_scalar_methods.py +328 -0
- numpy/_core/tests/test_scalarbuffer.py +153 -0
- numpy/_core/tests/test_scalarinherit.py +105 -0
- numpy/_core/tests/test_scalarmath.py +1168 -0
- numpy/_core/tests/test_scalarprint.py +403 -0
- numpy/_core/tests/test_shape_base.py +904 -0
- numpy/_core/tests/test_simd.py +1345 -0
- numpy/_core/tests/test_simd_module.py +105 -0
- numpy/_core/tests/test_stringdtype.py +1855 -0
- numpy/_core/tests/test_strings.py +1523 -0
- numpy/_core/tests/test_ufunc.py +3405 -0
- numpy/_core/tests/test_umath.py +4962 -0
- numpy/_core/tests/test_umath_accuracy.py +132 -0
- numpy/_core/tests/test_umath_complex.py +631 -0
- numpy/_core/tests/test_unicode.py +369 -0
- numpy/_core/umath.py +60 -0
- numpy/_core/umath.pyi +232 -0
- numpy/_distributor_init.py +15 -0
- numpy/_distributor_init.pyi +1 -0
- numpy/_expired_attrs_2_0.py +78 -0
- numpy/_expired_attrs_2_0.pyi +61 -0
- numpy/_globals.py +121 -0
- numpy/_globals.pyi +17 -0
- numpy/_pyinstaller/__init__.py +0 -0
- numpy/_pyinstaller/__init__.pyi +0 -0
- numpy/_pyinstaller/hook-numpy.py +36 -0
- numpy/_pyinstaller/hook-numpy.pyi +6 -0
- numpy/_pyinstaller/tests/__init__.py +16 -0
- numpy/_pyinstaller/tests/pyinstaller-smoke.py +32 -0
- numpy/_pyinstaller/tests/test_pyinstaller.py +35 -0
- numpy/_pytesttester.py +201 -0
- numpy/_pytesttester.pyi +18 -0
- numpy/_typing/__init__.py +173 -0
- numpy/_typing/_add_docstring.py +153 -0
- numpy/_typing/_array_like.py +106 -0
- numpy/_typing/_char_codes.py +213 -0
- numpy/_typing/_dtype_like.py +114 -0
- numpy/_typing/_extended_precision.py +15 -0
- numpy/_typing/_nbit.py +19 -0
- numpy/_typing/_nbit_base.py +94 -0
- numpy/_typing/_nbit_base.pyi +39 -0
- numpy/_typing/_nested_sequence.py +79 -0
- numpy/_typing/_scalars.py +20 -0
- numpy/_typing/_shape.py +8 -0
- numpy/_typing/_ufunc.py +7 -0
- numpy/_typing/_ufunc.pyi +975 -0
- numpy/_utils/__init__.py +95 -0
- numpy/_utils/__init__.pyi +28 -0
- numpy/_utils/_convertions.py +18 -0
- numpy/_utils/_convertions.pyi +4 -0
- numpy/_utils/_inspect.py +192 -0
- numpy/_utils/_inspect.pyi +70 -0
- numpy/_utils/_pep440.py +486 -0
- numpy/_utils/_pep440.pyi +118 -0
- numpy/char/__init__.py +2 -0
- numpy/char/__init__.pyi +111 -0
- numpy/conftest.py +248 -0
- numpy/core/__init__.py +33 -0
- numpy/core/__init__.pyi +0 -0
- numpy/core/_dtype.py +10 -0
- numpy/core/_dtype.pyi +0 -0
- numpy/core/_dtype_ctypes.py +10 -0
- numpy/core/_dtype_ctypes.pyi +0 -0
- numpy/core/_internal.py +27 -0
- numpy/core/_multiarray_umath.py +57 -0
- numpy/core/_utils.py +21 -0
- numpy/core/arrayprint.py +10 -0
- numpy/core/defchararray.py +10 -0
- numpy/core/einsumfunc.py +10 -0
- numpy/core/fromnumeric.py +10 -0
- numpy/core/function_base.py +10 -0
- numpy/core/getlimits.py +10 -0
- numpy/core/multiarray.py +25 -0
- numpy/core/numeric.py +12 -0
- numpy/core/numerictypes.py +10 -0
- numpy/core/overrides.py +10 -0
- numpy/core/overrides.pyi +7 -0
- numpy/core/records.py +10 -0
- numpy/core/shape_base.py +10 -0
- numpy/core/umath.py +10 -0
- numpy/ctypeslib/__init__.py +13 -0
- numpy/ctypeslib/__init__.pyi +15 -0
- numpy/ctypeslib/_ctypeslib.py +603 -0
- numpy/ctypeslib/_ctypeslib.pyi +236 -0
- numpy/distutils/__init__.py +64 -0
- numpy/distutils/__init__.pyi +4 -0
- numpy/distutils/__pycache__/conv_template.pypy311.pyc +0 -0
- numpy/distutils/_shell_utils.py +87 -0
- numpy/distutils/armccompiler.py +26 -0
- numpy/distutils/ccompiler.py +826 -0
- numpy/distutils/ccompiler_opt.py +2668 -0
- numpy/distutils/checks/cpu_asimd.c +27 -0
- numpy/distutils/checks/cpu_asimddp.c +16 -0
- numpy/distutils/checks/cpu_asimdfhm.c +19 -0
- numpy/distutils/checks/cpu_asimdhp.c +15 -0
- numpy/distutils/checks/cpu_avx.c +20 -0
- numpy/distutils/checks/cpu_avx2.c +20 -0
- numpy/distutils/checks/cpu_avx512_clx.c +22 -0
- numpy/distutils/checks/cpu_avx512_cnl.c +24 -0
- numpy/distutils/checks/cpu_avx512_icl.c +26 -0
- numpy/distutils/checks/cpu_avx512_knl.c +25 -0
- numpy/distutils/checks/cpu_avx512_knm.c +30 -0
- numpy/distutils/checks/cpu_avx512_skx.c +26 -0
- numpy/distutils/checks/cpu_avx512_spr.c +26 -0
- numpy/distutils/checks/cpu_avx512cd.c +20 -0
- numpy/distutils/checks/cpu_avx512f.c +20 -0
- numpy/distutils/checks/cpu_f16c.c +22 -0
- numpy/distutils/checks/cpu_fma3.c +22 -0
- numpy/distutils/checks/cpu_fma4.c +13 -0
- numpy/distutils/checks/cpu_lsx.c +11 -0
- numpy/distutils/checks/cpu_neon.c +19 -0
- numpy/distutils/checks/cpu_neon_fp16.c +11 -0
- numpy/distutils/checks/cpu_neon_vfpv4.c +21 -0
- numpy/distutils/checks/cpu_popcnt.c +32 -0
- numpy/distutils/checks/cpu_rvv.c +13 -0
- numpy/distutils/checks/cpu_sse.c +20 -0
- numpy/distutils/checks/cpu_sse2.c +20 -0
- numpy/distutils/checks/cpu_sse3.c +20 -0
- numpy/distutils/checks/cpu_sse41.c +20 -0
- numpy/distutils/checks/cpu_sse42.c +20 -0
- numpy/distutils/checks/cpu_ssse3.c +20 -0
- numpy/distutils/checks/cpu_sve.c +14 -0
- numpy/distutils/checks/cpu_vsx.c +21 -0
- numpy/distutils/checks/cpu_vsx2.c +13 -0
- numpy/distutils/checks/cpu_vsx3.c +13 -0
- numpy/distutils/checks/cpu_vsx4.c +14 -0
- numpy/distutils/checks/cpu_vx.c +16 -0
- numpy/distutils/checks/cpu_vxe.c +25 -0
- numpy/distutils/checks/cpu_vxe2.c +21 -0
- numpy/distutils/checks/cpu_xop.c +12 -0
- numpy/distutils/checks/extra_avx512bw_mask.c +18 -0
- numpy/distutils/checks/extra_avx512dq_mask.c +16 -0
- numpy/distutils/checks/extra_avx512f_reduce.c +41 -0
- numpy/distutils/checks/extra_vsx3_half_double.c +12 -0
- numpy/distutils/checks/extra_vsx4_mma.c +21 -0
- numpy/distutils/checks/extra_vsx_asm.c +36 -0
- numpy/distutils/checks/test_flags.c +1 -0
- numpy/distutils/command/__init__.py +41 -0
- numpy/distutils/command/autodist.py +148 -0
- numpy/distutils/command/bdist_rpm.py +22 -0
- numpy/distutils/command/build.py +62 -0
- numpy/distutils/command/build_clib.py +469 -0
- numpy/distutils/command/build_ext.py +752 -0
- numpy/distutils/command/build_py.py +31 -0
- numpy/distutils/command/build_scripts.py +49 -0
- numpy/distutils/command/build_src.py +773 -0
- numpy/distutils/command/config.py +516 -0
- numpy/distutils/command/config_compiler.py +126 -0
- numpy/distutils/command/develop.py +15 -0
- numpy/distutils/command/egg_info.py +25 -0
- numpy/distutils/command/install.py +79 -0
- numpy/distutils/command/install_clib.py +40 -0
- numpy/distutils/command/install_data.py +24 -0
- numpy/distutils/command/install_headers.py +25 -0
- numpy/distutils/command/sdist.py +27 -0
- numpy/distutils/conv_template.py +329 -0
- numpy/distutils/core.py +215 -0
- numpy/distutils/cpuinfo.py +683 -0
- numpy/distutils/exec_command.py +315 -0
- numpy/distutils/extension.py +101 -0
- numpy/distutils/fcompiler/__init__.py +1035 -0
- numpy/distutils/fcompiler/absoft.py +158 -0
- numpy/distutils/fcompiler/arm.py +71 -0
- numpy/distutils/fcompiler/compaq.py +120 -0
- numpy/distutils/fcompiler/environment.py +88 -0
- numpy/distutils/fcompiler/fujitsu.py +46 -0
- numpy/distutils/fcompiler/g95.py +42 -0
- numpy/distutils/fcompiler/gnu.py +555 -0
- numpy/distutils/fcompiler/hpux.py +41 -0
- numpy/distutils/fcompiler/ibm.py +97 -0
- numpy/distutils/fcompiler/intel.py +211 -0
- numpy/distutils/fcompiler/lahey.py +45 -0
- numpy/distutils/fcompiler/mips.py +54 -0
- numpy/distutils/fcompiler/nag.py +87 -0
- numpy/distutils/fcompiler/none.py +28 -0
- numpy/distutils/fcompiler/nv.py +53 -0
- numpy/distutils/fcompiler/pathf95.py +33 -0
- numpy/distutils/fcompiler/pg.py +128 -0
- numpy/distutils/fcompiler/sun.py +51 -0
- numpy/distutils/fcompiler/vast.py +52 -0
- numpy/distutils/from_template.py +261 -0
- numpy/distutils/fujitsuccompiler.py +28 -0
- numpy/distutils/intelccompiler.py +106 -0
- numpy/distutils/lib2def.py +116 -0
- numpy/distutils/line_endings.py +77 -0
- numpy/distutils/log.py +111 -0
- numpy/distutils/mingw/gfortran_vs2003_hack.c +6 -0
- numpy/distutils/mingw32ccompiler.py +620 -0
- numpy/distutils/misc_util.py +2484 -0
- numpy/distutils/msvc9compiler.py +63 -0
- numpy/distutils/msvccompiler.py +76 -0
- numpy/distutils/npy_pkg_config.py +441 -0
- numpy/distutils/numpy_distribution.py +17 -0
- numpy/distutils/pathccompiler.py +21 -0
- numpy/distutils/system_info.py +3267 -0
- numpy/distutils/tests/__init__.py +0 -0
- numpy/distutils/tests/test_build_ext.py +74 -0
- numpy/distutils/tests/test_ccompiler_opt.py +808 -0
- numpy/distutils/tests/test_ccompiler_opt_conf.py +176 -0
- numpy/distutils/tests/test_exec_command.py +217 -0
- numpy/distutils/tests/test_fcompiler.py +43 -0
- numpy/distutils/tests/test_fcompiler_gnu.py +55 -0
- numpy/distutils/tests/test_fcompiler_intel.py +30 -0
- numpy/distutils/tests/test_fcompiler_nagfor.py +22 -0
- numpy/distutils/tests/test_from_template.py +44 -0
- numpy/distutils/tests/test_log.py +34 -0
- numpy/distutils/tests/test_mingw32ccompiler.py +47 -0
- numpy/distutils/tests/test_misc_util.py +88 -0
- numpy/distutils/tests/test_npy_pkg_config.py +84 -0
- numpy/distutils/tests/test_shell_utils.py +79 -0
- numpy/distutils/tests/test_system_info.py +334 -0
- numpy/distutils/tests/utilities.py +90 -0
- numpy/distutils/unixccompiler.py +141 -0
- numpy/doc/ufuncs.py +138 -0
- numpy/dtypes.py +41 -0
- numpy/dtypes.pyi +630 -0
- numpy/exceptions.py +246 -0
- numpy/exceptions.pyi +27 -0
- numpy/f2py/__init__.py +86 -0
- numpy/f2py/__init__.pyi +5 -0
- numpy/f2py/__main__.py +5 -0
- numpy/f2py/__version__.py +1 -0
- numpy/f2py/__version__.pyi +1 -0
- numpy/f2py/_backends/__init__.py +9 -0
- numpy/f2py/_backends/__init__.pyi +5 -0
- numpy/f2py/_backends/_backend.py +44 -0
- numpy/f2py/_backends/_backend.pyi +46 -0
- numpy/f2py/_backends/_distutils.py +76 -0
- numpy/f2py/_backends/_distutils.pyi +13 -0
- numpy/f2py/_backends/_meson.py +244 -0
- numpy/f2py/_backends/_meson.pyi +62 -0
- numpy/f2py/_backends/meson.build.template +58 -0
- numpy/f2py/_isocbind.py +62 -0
- numpy/f2py/_isocbind.pyi +13 -0
- numpy/f2py/_src_pyf.py +247 -0
- numpy/f2py/_src_pyf.pyi +28 -0
- numpy/f2py/auxfuncs.py +1004 -0
- numpy/f2py/auxfuncs.pyi +262 -0
- numpy/f2py/capi_maps.py +811 -0
- numpy/f2py/capi_maps.pyi +33 -0
- numpy/f2py/cb_rules.py +665 -0
- numpy/f2py/cb_rules.pyi +17 -0
- numpy/f2py/cfuncs.py +1563 -0
- numpy/f2py/cfuncs.pyi +31 -0
- numpy/f2py/common_rules.py +143 -0
- numpy/f2py/common_rules.pyi +9 -0
- numpy/f2py/crackfortran.py +3725 -0
- numpy/f2py/crackfortran.pyi +266 -0
- numpy/f2py/diagnose.py +149 -0
- numpy/f2py/diagnose.pyi +1 -0
- numpy/f2py/f2py2e.py +788 -0
- numpy/f2py/f2py2e.pyi +74 -0
- numpy/f2py/f90mod_rules.py +269 -0
- numpy/f2py/f90mod_rules.pyi +16 -0
- numpy/f2py/func2subr.py +329 -0
- numpy/f2py/func2subr.pyi +7 -0
- numpy/f2py/rules.py +1629 -0
- numpy/f2py/rules.pyi +41 -0
- numpy/f2py/setup.cfg +3 -0
- numpy/f2py/src/fortranobject.c +1436 -0
- numpy/f2py/src/fortranobject.h +173 -0
- numpy/f2py/symbolic.py +1518 -0
- numpy/f2py/symbolic.pyi +219 -0
- numpy/f2py/tests/__init__.py +16 -0
- numpy/f2py/tests/src/abstract_interface/foo.f90 +34 -0
- numpy/f2py/tests/src/abstract_interface/gh18403_mod.f90 +6 -0
- numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c +235 -0
- numpy/f2py/tests/src/assumed_shape/.f2py_f2cmap +1 -0
- numpy/f2py/tests/src/assumed_shape/foo_free.f90 +34 -0
- numpy/f2py/tests/src/assumed_shape/foo_mod.f90 +41 -0
- numpy/f2py/tests/src/assumed_shape/foo_use.f90 +19 -0
- numpy/f2py/tests/src/assumed_shape/precision.f90 +4 -0
- numpy/f2py/tests/src/block_docstring/foo.f +6 -0
- numpy/f2py/tests/src/callback/foo.f +62 -0
- numpy/f2py/tests/src/callback/gh17797.f90 +7 -0
- numpy/f2py/tests/src/callback/gh18335.f90 +17 -0
- numpy/f2py/tests/src/callback/gh25211.f +10 -0
- numpy/f2py/tests/src/callback/gh25211.pyf +18 -0
- numpy/f2py/tests/src/callback/gh26681.f90 +18 -0
- numpy/f2py/tests/src/cli/gh_22819.pyf +6 -0
- numpy/f2py/tests/src/cli/hi77.f +3 -0
- numpy/f2py/tests/src/cli/hiworld.f90 +3 -0
- numpy/f2py/tests/src/common/block.f +11 -0
- numpy/f2py/tests/src/common/gh19161.f90 +10 -0
- numpy/f2py/tests/src/crackfortran/accesstype.f90 +13 -0
- numpy/f2py/tests/src/crackfortran/common_with_division.f +17 -0
- numpy/f2py/tests/src/crackfortran/data_common.f +8 -0
- numpy/f2py/tests/src/crackfortran/data_multiplier.f +5 -0
- numpy/f2py/tests/src/crackfortran/data_stmts.f90 +20 -0
- numpy/f2py/tests/src/crackfortran/data_with_comments.f +8 -0
- numpy/f2py/tests/src/crackfortran/foo_deps.f90 +6 -0
- numpy/f2py/tests/src/crackfortran/gh15035.f +16 -0
- numpy/f2py/tests/src/crackfortran/gh17859.f +12 -0
- numpy/f2py/tests/src/crackfortran/gh22648.pyf +7 -0
- numpy/f2py/tests/src/crackfortran/gh23533.f +5 -0
- numpy/f2py/tests/src/crackfortran/gh23598.f90 +4 -0
- numpy/f2py/tests/src/crackfortran/gh23598Warn.f90 +11 -0
- numpy/f2py/tests/src/crackfortran/gh23879.f90 +20 -0
- numpy/f2py/tests/src/crackfortran/gh27697.f90 +12 -0
- numpy/f2py/tests/src/crackfortran/gh2848.f90 +13 -0
- numpy/f2py/tests/src/crackfortran/operators.f90 +49 -0
- numpy/f2py/tests/src/crackfortran/privatemod.f90 +11 -0
- numpy/f2py/tests/src/crackfortran/publicmod.f90 +10 -0
- numpy/f2py/tests/src/crackfortran/pubprivmod.f90 +10 -0
- numpy/f2py/tests/src/crackfortran/unicode_comment.f90 +4 -0
- numpy/f2py/tests/src/f2cmap/.f2py_f2cmap +1 -0
- numpy/f2py/tests/src/f2cmap/isoFortranEnvMap.f90 +9 -0
- numpy/f2py/tests/src/isocintrin/isoCtests.f90 +34 -0
- numpy/f2py/tests/src/kind/foo.f90 +20 -0
- numpy/f2py/tests/src/mixed/foo.f +5 -0
- numpy/f2py/tests/src/mixed/foo_fixed.f90 +8 -0
- numpy/f2py/tests/src/mixed/foo_free.f90 +8 -0
- numpy/f2py/tests/src/modules/gh25337/data.f90 +8 -0
- numpy/f2py/tests/src/modules/gh25337/use_data.f90 +6 -0
- numpy/f2py/tests/src/modules/gh26920/two_mods_with_no_public_entities.f90 +21 -0
- numpy/f2py/tests/src/modules/gh26920/two_mods_with_one_public_routine.f90 +21 -0
- numpy/f2py/tests/src/modules/module_data_docstring.f90 +12 -0
- numpy/f2py/tests/src/modules/use_modules.f90 +20 -0
- numpy/f2py/tests/src/negative_bounds/issue_20853.f90 +7 -0
- numpy/f2py/tests/src/parameter/constant_array.f90 +45 -0
- numpy/f2py/tests/src/parameter/constant_both.f90 +57 -0
- numpy/f2py/tests/src/parameter/constant_compound.f90 +15 -0
- numpy/f2py/tests/src/parameter/constant_integer.f90 +22 -0
- numpy/f2py/tests/src/parameter/constant_non_compound.f90 +23 -0
- numpy/f2py/tests/src/parameter/constant_real.f90 +23 -0
- numpy/f2py/tests/src/quoted_character/foo.f +14 -0
- numpy/f2py/tests/src/regression/AB.inc +1 -0
- numpy/f2py/tests/src/regression/assignOnlyModule.f90 +25 -0
- numpy/f2py/tests/src/regression/datonly.f90 +17 -0
- numpy/f2py/tests/src/regression/f77comments.f +26 -0
- numpy/f2py/tests/src/regression/f77fixedform.f95 +5 -0
- numpy/f2py/tests/src/regression/f90continuation.f90 +9 -0
- numpy/f2py/tests/src/regression/incfile.f90 +5 -0
- numpy/f2py/tests/src/regression/inout.f90 +9 -0
- numpy/f2py/tests/src/regression/lower_f2py_fortran.f90 +5 -0
- numpy/f2py/tests/src/regression/mod_derived_types.f90 +23 -0
- numpy/f2py/tests/src/return_character/foo77.f +45 -0
- numpy/f2py/tests/src/return_character/foo90.f90 +48 -0
- numpy/f2py/tests/src/return_complex/foo77.f +45 -0
- numpy/f2py/tests/src/return_complex/foo90.f90 +48 -0
- numpy/f2py/tests/src/return_integer/foo77.f +56 -0
- numpy/f2py/tests/src/return_integer/foo90.f90 +59 -0
- numpy/f2py/tests/src/return_logical/foo77.f +56 -0
- numpy/f2py/tests/src/return_logical/foo90.f90 +59 -0
- numpy/f2py/tests/src/return_real/foo77.f +45 -0
- numpy/f2py/tests/src/return_real/foo90.f90 +48 -0
- numpy/f2py/tests/src/routines/funcfortranname.f +5 -0
- numpy/f2py/tests/src/routines/funcfortranname.pyf +11 -0
- numpy/f2py/tests/src/routines/subrout.f +4 -0
- numpy/f2py/tests/src/routines/subrout.pyf +10 -0
- numpy/f2py/tests/src/size/foo.f90 +44 -0
- numpy/f2py/tests/src/string/char.f90 +29 -0
- numpy/f2py/tests/src/string/fixed_string.f90 +34 -0
- numpy/f2py/tests/src/string/gh24008.f +8 -0
- numpy/f2py/tests/src/string/gh24662.f90 +7 -0
- numpy/f2py/tests/src/string/gh25286.f90 +14 -0
- numpy/f2py/tests/src/string/gh25286.pyf +12 -0
- numpy/f2py/tests/src/string/gh25286_bc.pyf +12 -0
- numpy/f2py/tests/src/string/scalar_string.f90 +9 -0
- numpy/f2py/tests/src/string/string.f +12 -0
- numpy/f2py/tests/src/value_attrspec/gh21665.f90 +9 -0
- numpy/f2py/tests/test_abstract_interface.py +26 -0
- numpy/f2py/tests/test_array_from_pyobj.py +678 -0
- numpy/f2py/tests/test_assumed_shape.py +50 -0
- numpy/f2py/tests/test_block_docstring.py +20 -0
- numpy/f2py/tests/test_callback.py +263 -0
- numpy/f2py/tests/test_character.py +641 -0
- numpy/f2py/tests/test_common.py +23 -0
- numpy/f2py/tests/test_crackfortran.py +421 -0
- numpy/f2py/tests/test_data.py +71 -0
- numpy/f2py/tests/test_docs.py +66 -0
- numpy/f2py/tests/test_f2cmap.py +17 -0
- numpy/f2py/tests/test_f2py2e.py +983 -0
- numpy/f2py/tests/test_isoc.py +56 -0
- numpy/f2py/tests/test_kind.py +52 -0
- numpy/f2py/tests/test_mixed.py +35 -0
- numpy/f2py/tests/test_modules.py +83 -0
- numpy/f2py/tests/test_parameter.py +129 -0
- numpy/f2py/tests/test_pyf_src.py +43 -0
- numpy/f2py/tests/test_quoted_character.py +18 -0
- numpy/f2py/tests/test_regression.py +187 -0
- numpy/f2py/tests/test_return_character.py +48 -0
- numpy/f2py/tests/test_return_complex.py +67 -0
- numpy/f2py/tests/test_return_integer.py +55 -0
- numpy/f2py/tests/test_return_logical.py +65 -0
- numpy/f2py/tests/test_return_real.py +109 -0
- numpy/f2py/tests/test_routines.py +29 -0
- numpy/f2py/tests/test_semicolon_split.py +75 -0
- numpy/f2py/tests/test_size.py +45 -0
- numpy/f2py/tests/test_string.py +100 -0
- numpy/f2py/tests/test_symbolic.py +500 -0
- numpy/f2py/tests/test_value_attrspec.py +15 -0
- numpy/f2py/tests/util.py +442 -0
- numpy/f2py/use_rules.py +99 -0
- numpy/f2py/use_rules.pyi +9 -0
- numpy/fft/__init__.py +213 -0
- numpy/fft/__init__.pyi +38 -0
- numpy/fft/_helper.py +235 -0
- numpy/fft/_helper.pyi +44 -0
- numpy/fft/_pocketfft.py +1693 -0
- numpy/fft/_pocketfft.pyi +137 -0
- numpy/fft/_pocketfft_umath.pypy311-pp73-darwin.so +0 -0
- numpy/fft/tests/__init__.py +0 -0
- numpy/fft/tests/test_helper.py +167 -0
- numpy/fft/tests/test_pocketfft.py +589 -0
- numpy/lib/__init__.py +97 -0
- numpy/lib/__init__.pyi +52 -0
- numpy/lib/_array_utils_impl.py +62 -0
- numpy/lib/_array_utils_impl.pyi +10 -0
- numpy/lib/_arraypad_impl.py +926 -0
- numpy/lib/_arraypad_impl.pyi +88 -0
- numpy/lib/_arraysetops_impl.py +1158 -0
- numpy/lib/_arraysetops_impl.pyi +462 -0
- numpy/lib/_arrayterator_impl.py +224 -0
- numpy/lib/_arrayterator_impl.pyi +45 -0
- numpy/lib/_datasource.py +700 -0
- numpy/lib/_datasource.pyi +30 -0
- numpy/lib/_format_impl.py +1036 -0
- numpy/lib/_format_impl.pyi +56 -0
- numpy/lib/_function_base_impl.py +5760 -0
- numpy/lib/_function_base_impl.pyi +2324 -0
- numpy/lib/_histograms_impl.py +1085 -0
- numpy/lib/_histograms_impl.pyi +40 -0
- numpy/lib/_index_tricks_impl.py +1048 -0
- numpy/lib/_index_tricks_impl.pyi +267 -0
- numpy/lib/_iotools.py +900 -0
- numpy/lib/_iotools.pyi +116 -0
- numpy/lib/_nanfunctions_impl.py +2006 -0
- numpy/lib/_nanfunctions_impl.pyi +48 -0
- numpy/lib/_npyio_impl.py +2583 -0
- numpy/lib/_npyio_impl.pyi +299 -0
- numpy/lib/_polynomial_impl.py +1465 -0
- numpy/lib/_polynomial_impl.pyi +338 -0
- numpy/lib/_scimath_impl.py +642 -0
- numpy/lib/_scimath_impl.pyi +93 -0
- numpy/lib/_shape_base_impl.py +1289 -0
- numpy/lib/_shape_base_impl.pyi +236 -0
- numpy/lib/_stride_tricks_impl.py +582 -0
- numpy/lib/_stride_tricks_impl.pyi +73 -0
- numpy/lib/_twodim_base_impl.py +1201 -0
- numpy/lib/_twodim_base_impl.pyi +408 -0
- numpy/lib/_type_check_impl.py +710 -0
- numpy/lib/_type_check_impl.pyi +348 -0
- numpy/lib/_ufunclike_impl.py +199 -0
- numpy/lib/_ufunclike_impl.pyi +60 -0
- numpy/lib/_user_array_impl.py +310 -0
- numpy/lib/_user_array_impl.pyi +226 -0
- numpy/lib/_utils_impl.py +784 -0
- numpy/lib/_utils_impl.pyi +22 -0
- numpy/lib/_version.py +153 -0
- numpy/lib/_version.pyi +17 -0
- numpy/lib/array_utils.py +7 -0
- numpy/lib/array_utils.pyi +6 -0
- numpy/lib/format.py +24 -0
- numpy/lib/format.pyi +24 -0
- numpy/lib/introspect.py +94 -0
- numpy/lib/introspect.pyi +3 -0
- numpy/lib/mixins.py +180 -0
- numpy/lib/mixins.pyi +78 -0
- numpy/lib/npyio.py +1 -0
- numpy/lib/npyio.pyi +5 -0
- numpy/lib/recfunctions.py +1681 -0
- numpy/lib/recfunctions.pyi +444 -0
- numpy/lib/scimath.py +13 -0
- numpy/lib/scimath.pyi +12 -0
- numpy/lib/stride_tricks.py +1 -0
- numpy/lib/stride_tricks.pyi +4 -0
- numpy/lib/tests/__init__.py +0 -0
- numpy/lib/tests/data/py2-np0-objarr.npy +0 -0
- numpy/lib/tests/data/py2-objarr.npy +0 -0
- numpy/lib/tests/data/py2-objarr.npz +0 -0
- numpy/lib/tests/data/py3-objarr.npy +0 -0
- numpy/lib/tests/data/py3-objarr.npz +0 -0
- numpy/lib/tests/data/python3.npy +0 -0
- numpy/lib/tests/data/win64python2.npy +0 -0
- numpy/lib/tests/test__datasource.py +328 -0
- numpy/lib/tests/test__iotools.py +358 -0
- numpy/lib/tests/test__version.py +64 -0
- numpy/lib/tests/test_array_utils.py +32 -0
- numpy/lib/tests/test_arraypad.py +1427 -0
- numpy/lib/tests/test_arraysetops.py +1302 -0
- numpy/lib/tests/test_arrayterator.py +45 -0
- numpy/lib/tests/test_format.py +1054 -0
- numpy/lib/tests/test_function_base.py +4750 -0
- numpy/lib/tests/test_histograms.py +855 -0
- numpy/lib/tests/test_index_tricks.py +693 -0
- numpy/lib/tests/test_io.py +2857 -0
- numpy/lib/tests/test_loadtxt.py +1099 -0
- numpy/lib/tests/test_mixins.py +215 -0
- numpy/lib/tests/test_nanfunctions.py +1438 -0
- numpy/lib/tests/test_packbits.py +376 -0
- numpy/lib/tests/test_polynomial.py +325 -0
- numpy/lib/tests/test_recfunctions.py +1042 -0
- numpy/lib/tests/test_regression.py +231 -0
- numpy/lib/tests/test_shape_base.py +813 -0
- numpy/lib/tests/test_stride_tricks.py +655 -0
- numpy/lib/tests/test_twodim_base.py +559 -0
- numpy/lib/tests/test_type_check.py +473 -0
- numpy/lib/tests/test_ufunclike.py +97 -0
- numpy/lib/tests/test_utils.py +80 -0
- numpy/lib/user_array.py +1 -0
- numpy/lib/user_array.pyi +1 -0
- numpy/linalg/__init__.py +95 -0
- numpy/linalg/__init__.pyi +71 -0
- numpy/linalg/_linalg.py +3657 -0
- numpy/linalg/_linalg.pyi +548 -0
- numpy/linalg/_umath_linalg.pyi +60 -0
- numpy/linalg/_umath_linalg.pypy311-pp73-darwin.so +0 -0
- numpy/linalg/lapack_lite.pyi +143 -0
- numpy/linalg/lapack_lite.pypy311-pp73-darwin.so +0 -0
- numpy/linalg/tests/__init__.py +0 -0
- numpy/linalg/tests/test_deprecations.py +21 -0
- numpy/linalg/tests/test_linalg.py +2442 -0
- numpy/linalg/tests/test_regression.py +182 -0
- numpy/ma/API_CHANGES.txt +135 -0
- numpy/ma/LICENSE +24 -0
- numpy/ma/README.rst +236 -0
- numpy/ma/__init__.py +53 -0
- numpy/ma/__init__.pyi +458 -0
- numpy/ma/core.py +8929 -0
- numpy/ma/core.pyi +3720 -0
- numpy/ma/extras.py +2266 -0
- numpy/ma/extras.pyi +297 -0
- numpy/ma/mrecords.py +762 -0
- numpy/ma/mrecords.pyi +96 -0
- numpy/ma/tests/__init__.py +0 -0
- numpy/ma/tests/test_arrayobject.py +40 -0
- numpy/ma/tests/test_core.py +6008 -0
- numpy/ma/tests/test_deprecations.py +65 -0
- numpy/ma/tests/test_extras.py +1945 -0
- numpy/ma/tests/test_mrecords.py +495 -0
- numpy/ma/tests/test_old_ma.py +939 -0
- numpy/ma/tests/test_regression.py +83 -0
- numpy/ma/tests/test_subclassing.py +469 -0
- numpy/ma/testutils.py +294 -0
- numpy/ma/testutils.pyi +69 -0
- numpy/matlib.py +380 -0
- numpy/matlib.pyi +580 -0
- numpy/matrixlib/__init__.py +12 -0
- numpy/matrixlib/__init__.pyi +3 -0
- numpy/matrixlib/defmatrix.py +1119 -0
- numpy/matrixlib/defmatrix.pyi +218 -0
- numpy/matrixlib/tests/__init__.py +0 -0
- numpy/matrixlib/tests/test_defmatrix.py +455 -0
- numpy/matrixlib/tests/test_interaction.py +360 -0
- numpy/matrixlib/tests/test_masked_matrix.py +240 -0
- numpy/matrixlib/tests/test_matrix_linalg.py +110 -0
- numpy/matrixlib/tests/test_multiarray.py +17 -0
- numpy/matrixlib/tests/test_numeric.py +18 -0
- numpy/matrixlib/tests/test_regression.py +31 -0
- numpy/polynomial/__init__.py +187 -0
- numpy/polynomial/__init__.pyi +31 -0
- numpy/polynomial/_polybase.py +1191 -0
- numpy/polynomial/_polybase.pyi +262 -0
- numpy/polynomial/_polytypes.pyi +501 -0
- numpy/polynomial/chebyshev.py +2001 -0
- numpy/polynomial/chebyshev.pyi +180 -0
- numpy/polynomial/hermite.py +1738 -0
- numpy/polynomial/hermite.pyi +106 -0
- numpy/polynomial/hermite_e.py +1640 -0
- numpy/polynomial/hermite_e.pyi +106 -0
- numpy/polynomial/laguerre.py +1673 -0
- numpy/polynomial/laguerre.pyi +100 -0
- numpy/polynomial/legendre.py +1603 -0
- numpy/polynomial/legendre.pyi +100 -0
- numpy/polynomial/polynomial.py +1625 -0
- numpy/polynomial/polynomial.pyi +109 -0
- numpy/polynomial/polyutils.py +759 -0
- numpy/polynomial/polyutils.pyi +307 -0
- numpy/polynomial/tests/__init__.py +0 -0
- numpy/polynomial/tests/test_chebyshev.py +618 -0
- numpy/polynomial/tests/test_classes.py +613 -0
- numpy/polynomial/tests/test_hermite.py +553 -0
- numpy/polynomial/tests/test_hermite_e.py +554 -0
- numpy/polynomial/tests/test_laguerre.py +535 -0
- numpy/polynomial/tests/test_legendre.py +566 -0
- numpy/polynomial/tests/test_polynomial.py +691 -0
- numpy/polynomial/tests/test_polyutils.py +123 -0
- numpy/polynomial/tests/test_printing.py +557 -0
- numpy/polynomial/tests/test_symbol.py +217 -0
- numpy/py.typed +0 -0
- numpy/random/LICENSE.md +71 -0
- numpy/random/__init__.pxd +14 -0
- numpy/random/__init__.py +213 -0
- numpy/random/__init__.pyi +124 -0
- numpy/random/_bounded_integers.pxd +29 -0
- numpy/random/_bounded_integers.pyi +1 -0
- numpy/random/_bounded_integers.pypy311-pp73-darwin.so +0 -0
- numpy/random/_common.pxd +110 -0
- numpy/random/_common.pyi +16 -0
- numpy/random/_common.pypy311-pp73-darwin.so +0 -0
- numpy/random/_examples/cffi/extending.py +44 -0
- numpy/random/_examples/cffi/parse.py +53 -0
- numpy/random/_examples/cython/extending.pyx +77 -0
- numpy/random/_examples/cython/extending_distributions.pyx +117 -0
- numpy/random/_examples/cython/meson.build +53 -0
- numpy/random/_examples/numba/extending.py +86 -0
- numpy/random/_examples/numba/extending_distributions.py +67 -0
- numpy/random/_generator.pyi +862 -0
- numpy/random/_generator.pypy311-pp73-darwin.so +0 -0
- numpy/random/_mt19937.pyi +27 -0
- numpy/random/_mt19937.pypy311-pp73-darwin.so +0 -0
- numpy/random/_pcg64.pyi +41 -0
- numpy/random/_pcg64.pypy311-pp73-darwin.so +0 -0
- numpy/random/_philox.pyi +36 -0
- numpy/random/_philox.pypy311-pp73-darwin.so +0 -0
- numpy/random/_pickle.py +88 -0
- numpy/random/_pickle.pyi +43 -0
- numpy/random/_sfc64.pyi +25 -0
- numpy/random/_sfc64.pypy311-pp73-darwin.so +0 -0
- numpy/random/bit_generator.pxd +40 -0
- numpy/random/bit_generator.pyi +123 -0
- numpy/random/bit_generator.pypy311-pp73-darwin.so +0 -0
- numpy/random/c_distributions.pxd +119 -0
- numpy/random/lib/libnpyrandom.a +0 -0
- numpy/random/mtrand.pyi +759 -0
- numpy/random/mtrand.pypy311-pp73-darwin.so +0 -0
- numpy/random/tests/__init__.py +0 -0
- numpy/random/tests/data/__init__.py +0 -0
- numpy/random/tests/data/generator_pcg64_np121.pkl.gz +0 -0
- numpy/random/tests/data/generator_pcg64_np126.pkl.gz +0 -0
- numpy/random/tests/data/mt19937-testset-1.csv +1001 -0
- numpy/random/tests/data/mt19937-testset-2.csv +1001 -0
- numpy/random/tests/data/pcg64-testset-1.csv +1001 -0
- numpy/random/tests/data/pcg64-testset-2.csv +1001 -0
- numpy/random/tests/data/pcg64dxsm-testset-1.csv +1001 -0
- numpy/random/tests/data/pcg64dxsm-testset-2.csv +1001 -0
- numpy/random/tests/data/philox-testset-1.csv +1001 -0
- numpy/random/tests/data/philox-testset-2.csv +1001 -0
- numpy/random/tests/data/sfc64-testset-1.csv +1001 -0
- numpy/random/tests/data/sfc64-testset-2.csv +1001 -0
- numpy/random/tests/data/sfc64_np126.pkl.gz +0 -0
- numpy/random/tests/test_direct.py +595 -0
- numpy/random/tests/test_extending.py +131 -0
- numpy/random/tests/test_generator_mt19937.py +2825 -0
- numpy/random/tests/test_generator_mt19937_regressions.py +221 -0
- numpy/random/tests/test_random.py +1724 -0
- numpy/random/tests/test_randomstate.py +2099 -0
- numpy/random/tests/test_randomstate_regression.py +213 -0
- numpy/random/tests/test_regression.py +175 -0
- numpy/random/tests/test_seed_sequence.py +79 -0
- numpy/random/tests/test_smoke.py +882 -0
- numpy/rec/__init__.py +2 -0
- numpy/rec/__init__.pyi +23 -0
- numpy/strings/__init__.py +2 -0
- numpy/strings/__init__.pyi +97 -0
- numpy/testing/__init__.py +22 -0
- numpy/testing/__init__.pyi +107 -0
- numpy/testing/_private/__init__.py +0 -0
- numpy/testing/_private/__init__.pyi +0 -0
- numpy/testing/_private/extbuild.py +250 -0
- numpy/testing/_private/extbuild.pyi +25 -0
- numpy/testing/_private/utils.py +2830 -0
- numpy/testing/_private/utils.pyi +505 -0
- numpy/testing/overrides.py +84 -0
- numpy/testing/overrides.pyi +10 -0
- numpy/testing/print_coercion_tables.py +207 -0
- numpy/testing/print_coercion_tables.pyi +26 -0
- numpy/testing/tests/__init__.py +0 -0
- numpy/testing/tests/test_utils.py +2123 -0
- numpy/tests/__init__.py +0 -0
- numpy/tests/test__all__.py +10 -0
- numpy/tests/test_configtool.py +51 -0
- numpy/tests/test_ctypeslib.py +383 -0
- numpy/tests/test_lazyloading.py +42 -0
- numpy/tests/test_matlib.py +59 -0
- numpy/tests/test_numpy_config.py +47 -0
- numpy/tests/test_numpy_version.py +54 -0
- numpy/tests/test_public_api.py +807 -0
- numpy/tests/test_reloading.py +76 -0
- numpy/tests/test_scripts.py +48 -0
- numpy/tests/test_warnings.py +79 -0
- numpy/typing/__init__.py +233 -0
- numpy/typing/__init__.pyi +3 -0
- numpy/typing/mypy_plugin.py +200 -0
- numpy/typing/tests/__init__.py +0 -0
- numpy/typing/tests/data/fail/arithmetic.pyi +126 -0
- numpy/typing/tests/data/fail/array_constructors.pyi +34 -0
- numpy/typing/tests/data/fail/array_like.pyi +15 -0
- numpy/typing/tests/data/fail/array_pad.pyi +6 -0
- numpy/typing/tests/data/fail/arrayprint.pyi +15 -0
- numpy/typing/tests/data/fail/arrayterator.pyi +14 -0
- numpy/typing/tests/data/fail/bitwise_ops.pyi +17 -0
- numpy/typing/tests/data/fail/char.pyi +63 -0
- numpy/typing/tests/data/fail/chararray.pyi +61 -0
- numpy/typing/tests/data/fail/comparisons.pyi +27 -0
- numpy/typing/tests/data/fail/constants.pyi +3 -0
- numpy/typing/tests/data/fail/datasource.pyi +16 -0
- numpy/typing/tests/data/fail/dtype.pyi +17 -0
- numpy/typing/tests/data/fail/einsumfunc.pyi +12 -0
- numpy/typing/tests/data/fail/flatiter.pyi +38 -0
- numpy/typing/tests/data/fail/fromnumeric.pyi +148 -0
- numpy/typing/tests/data/fail/histograms.pyi +12 -0
- numpy/typing/tests/data/fail/index_tricks.pyi +14 -0
- numpy/typing/tests/data/fail/lib_function_base.pyi +60 -0
- numpy/typing/tests/data/fail/lib_polynomial.pyi +29 -0
- numpy/typing/tests/data/fail/lib_utils.pyi +3 -0
- numpy/typing/tests/data/fail/lib_version.pyi +6 -0
- numpy/typing/tests/data/fail/linalg.pyi +52 -0
- numpy/typing/tests/data/fail/ma.pyi +155 -0
- numpy/typing/tests/data/fail/memmap.pyi +5 -0
- numpy/typing/tests/data/fail/modules.pyi +17 -0
- numpy/typing/tests/data/fail/multiarray.pyi +52 -0
- numpy/typing/tests/data/fail/ndarray.pyi +11 -0
- numpy/typing/tests/data/fail/ndarray_misc.pyi +49 -0
- numpy/typing/tests/data/fail/nditer.pyi +8 -0
- numpy/typing/tests/data/fail/nested_sequence.pyi +17 -0
- numpy/typing/tests/data/fail/npyio.pyi +24 -0
- numpy/typing/tests/data/fail/numerictypes.pyi +5 -0
- numpy/typing/tests/data/fail/random.pyi +62 -0
- numpy/typing/tests/data/fail/rec.pyi +17 -0
- numpy/typing/tests/data/fail/scalars.pyi +86 -0
- numpy/typing/tests/data/fail/shape.pyi +7 -0
- numpy/typing/tests/data/fail/shape_base.pyi +8 -0
- numpy/typing/tests/data/fail/stride_tricks.pyi +9 -0
- numpy/typing/tests/data/fail/strings.pyi +52 -0
- numpy/typing/tests/data/fail/testing.pyi +28 -0
- numpy/typing/tests/data/fail/twodim_base.pyi +39 -0
- numpy/typing/tests/data/fail/type_check.pyi +12 -0
- numpy/typing/tests/data/fail/ufunc_config.pyi +21 -0
- numpy/typing/tests/data/fail/ufunclike.pyi +21 -0
- numpy/typing/tests/data/fail/ufuncs.pyi +17 -0
- numpy/typing/tests/data/fail/warnings_and_errors.pyi +5 -0
- numpy/typing/tests/data/misc/extended_precision.pyi +9 -0
- numpy/typing/tests/data/mypy.ini +8 -0
- numpy/typing/tests/data/pass/arithmetic.py +614 -0
- numpy/typing/tests/data/pass/array_constructors.py +138 -0
- numpy/typing/tests/data/pass/array_like.py +43 -0
- numpy/typing/tests/data/pass/arrayprint.py +37 -0
- numpy/typing/tests/data/pass/arrayterator.py +28 -0
- numpy/typing/tests/data/pass/bitwise_ops.py +131 -0
- numpy/typing/tests/data/pass/comparisons.py +316 -0
- numpy/typing/tests/data/pass/dtype.py +57 -0
- numpy/typing/tests/data/pass/einsumfunc.py +36 -0
- numpy/typing/tests/data/pass/flatiter.py +26 -0
- numpy/typing/tests/data/pass/fromnumeric.py +272 -0
- numpy/typing/tests/data/pass/index_tricks.py +62 -0
- numpy/typing/tests/data/pass/lib_user_array.py +22 -0
- numpy/typing/tests/data/pass/lib_utils.py +19 -0
- numpy/typing/tests/data/pass/lib_version.py +18 -0
- numpy/typing/tests/data/pass/literal.py +52 -0
- numpy/typing/tests/data/pass/ma.py +199 -0
- numpy/typing/tests/data/pass/mod.py +149 -0
- numpy/typing/tests/data/pass/modules.py +45 -0
- numpy/typing/tests/data/pass/multiarray.py +77 -0
- numpy/typing/tests/data/pass/ndarray_conversion.py +81 -0
- numpy/typing/tests/data/pass/ndarray_misc.py +199 -0
- numpy/typing/tests/data/pass/ndarray_shape_manipulation.py +47 -0
- numpy/typing/tests/data/pass/nditer.py +4 -0
- numpy/typing/tests/data/pass/numeric.py +90 -0
- numpy/typing/tests/data/pass/numerictypes.py +17 -0
- numpy/typing/tests/data/pass/random.py +1498 -0
- numpy/typing/tests/data/pass/recfunctions.py +164 -0
- numpy/typing/tests/data/pass/scalars.py +249 -0
- numpy/typing/tests/data/pass/shape.py +19 -0
- numpy/typing/tests/data/pass/simple.py +170 -0
- numpy/typing/tests/data/pass/ufunc_config.py +64 -0
- numpy/typing/tests/data/pass/ufunclike.py +52 -0
- numpy/typing/tests/data/pass/ufuncs.py +16 -0
- numpy/typing/tests/data/pass/warnings_and_errors.py +6 -0
- numpy/typing/tests/data/reveal/arithmetic.pyi +719 -0
- numpy/typing/tests/data/reveal/array_api_info.pyi +70 -0
- numpy/typing/tests/data/reveal/array_constructors.pyi +277 -0
- numpy/typing/tests/data/reveal/arraypad.pyi +27 -0
- numpy/typing/tests/data/reveal/arrayprint.pyi +25 -0
- numpy/typing/tests/data/reveal/arraysetops.pyi +74 -0
- numpy/typing/tests/data/reveal/arrayterator.pyi +27 -0
- numpy/typing/tests/data/reveal/bitwise_ops.pyi +166 -0
- numpy/typing/tests/data/reveal/char.pyi +225 -0
- numpy/typing/tests/data/reveal/chararray.pyi +138 -0
- numpy/typing/tests/data/reveal/comparisons.pyi +264 -0
- numpy/typing/tests/data/reveal/constants.pyi +14 -0
- numpy/typing/tests/data/reveal/ctypeslib.pyi +81 -0
- numpy/typing/tests/data/reveal/datasource.pyi +23 -0
- numpy/typing/tests/data/reveal/dtype.pyi +132 -0
- numpy/typing/tests/data/reveal/einsumfunc.pyi +39 -0
- numpy/typing/tests/data/reveal/emath.pyi +54 -0
- numpy/typing/tests/data/reveal/fft.pyi +37 -0
- numpy/typing/tests/data/reveal/flatiter.pyi +86 -0
- numpy/typing/tests/data/reveal/fromnumeric.pyi +347 -0
- numpy/typing/tests/data/reveal/getlimits.pyi +53 -0
- numpy/typing/tests/data/reveal/histograms.pyi +25 -0
- numpy/typing/tests/data/reveal/index_tricks.pyi +70 -0
- numpy/typing/tests/data/reveal/lib_function_base.pyi +409 -0
- numpy/typing/tests/data/reveal/lib_polynomial.pyi +147 -0
- numpy/typing/tests/data/reveal/lib_utils.pyi +17 -0
- numpy/typing/tests/data/reveal/lib_version.pyi +20 -0
- numpy/typing/tests/data/reveal/linalg.pyi +154 -0
- numpy/typing/tests/data/reveal/ma.pyi +1098 -0
- numpy/typing/tests/data/reveal/matrix.pyi +73 -0
- numpy/typing/tests/data/reveal/memmap.pyi +19 -0
- numpy/typing/tests/data/reveal/mod.pyi +178 -0
- numpy/typing/tests/data/reveal/modules.pyi +51 -0
- numpy/typing/tests/data/reveal/multiarray.pyi +197 -0
- numpy/typing/tests/data/reveal/nbit_base_example.pyi +20 -0
- numpy/typing/tests/data/reveal/ndarray_assignability.pyi +82 -0
- numpy/typing/tests/data/reveal/ndarray_conversion.pyi +83 -0
- numpy/typing/tests/data/reveal/ndarray_misc.pyi +246 -0
- numpy/typing/tests/data/reveal/ndarray_shape_manipulation.pyi +47 -0
- numpy/typing/tests/data/reveal/nditer.pyi +49 -0
- numpy/typing/tests/data/reveal/nested_sequence.pyi +25 -0
- numpy/typing/tests/data/reveal/npyio.pyi +83 -0
- numpy/typing/tests/data/reveal/numeric.pyi +170 -0
- numpy/typing/tests/data/reveal/numerictypes.pyi +16 -0
- numpy/typing/tests/data/reveal/polynomial_polybase.pyi +217 -0
- numpy/typing/tests/data/reveal/polynomial_polyutils.pyi +218 -0
- numpy/typing/tests/data/reveal/polynomial_series.pyi +138 -0
- numpy/typing/tests/data/reveal/random.pyi +1546 -0
- numpy/typing/tests/data/reveal/rec.pyi +171 -0
- numpy/typing/tests/data/reveal/scalars.pyi +191 -0
- numpy/typing/tests/data/reveal/shape.pyi +13 -0
- numpy/typing/tests/data/reveal/shape_base.pyi +52 -0
- numpy/typing/tests/data/reveal/stride_tricks.pyi +27 -0
- numpy/typing/tests/data/reveal/strings.pyi +196 -0
- numpy/typing/tests/data/reveal/testing.pyi +198 -0
- numpy/typing/tests/data/reveal/twodim_base.pyi +225 -0
- numpy/typing/tests/data/reveal/type_check.pyi +67 -0
- numpy/typing/tests/data/reveal/ufunc_config.pyi +29 -0
- numpy/typing/tests/data/reveal/ufunclike.pyi +31 -0
- numpy/typing/tests/data/reveal/ufuncs.pyi +142 -0
- numpy/typing/tests/data/reveal/warnings_and_errors.pyi +11 -0
- numpy/typing/tests/test_isfile.py +38 -0
- numpy/typing/tests/test_runtime.py +110 -0
- numpy/typing/tests/test_typing.py +205 -0
- numpy/version.py +11 -0
- numpy/version.pyi +9 -0
- numpy-2.4.1.dist-info/METADATA +139 -0
- numpy-2.4.1.dist-info/RECORD +1039 -0
- numpy-2.4.1.dist-info/WHEEL +6 -0
- numpy-2.4.1.dist-info/entry_points.txt +13 -0
- numpy-2.4.1.dist-info/licenses/LICENSE.txt +935 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/include/numpy/libdivide/LICENSE.txt +21 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/src/common/pythoncapi-compat/COPYING +14 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/src/highway/LICENSE +371 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/src/multiarray/dragon4_LICENSE.txt +27 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/src/npysort/x86-simd-sort/LICENSE.md +28 -0
- numpy-2.4.1.dist-info/licenses/numpy/_core/src/umath/svml/LICENSE +30 -0
- numpy-2.4.1.dist-info/licenses/numpy/fft/pocketfft/LICENSE.md +25 -0
- numpy-2.4.1.dist-info/licenses/numpy/linalg/lapack_lite/LICENSE.txt +48 -0
- numpy-2.4.1.dist-info/licenses/numpy/ma/LICENSE +24 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/LICENSE.md +71 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/distributions/LICENSE.md +61 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/mt19937/LICENSE.md +61 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/pcg64/LICENSE.md +22 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/philox/LICENSE.md +31 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/sfc64/LICENSE.md +27 -0
- numpy-2.4.1.dist-info/licenses/numpy/random/src/splitmix64/LICENSE.md +9 -0
|
@@ -0,0 +1,2484 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
import sys
|
|
4
|
+
import copy
|
|
5
|
+
import glob
|
|
6
|
+
import atexit
|
|
7
|
+
import tempfile
|
|
8
|
+
import subprocess
|
|
9
|
+
import shutil
|
|
10
|
+
import multiprocessing
|
|
11
|
+
import textwrap
|
|
12
|
+
import importlib.util
|
|
13
|
+
from threading import local as tlocal
|
|
14
|
+
from functools import reduce
|
|
15
|
+
|
|
16
|
+
import distutils
|
|
17
|
+
from distutils.errors import DistutilsError
|
|
18
|
+
|
|
19
|
+
# stores temporary directory of each thread to only create one per thread
|
|
20
|
+
_tdata = tlocal()
|
|
21
|
+
|
|
22
|
+
# store all created temporary directories so they can be deleted on exit
|
|
23
|
+
_tmpdirs = []
|
|
24
|
+
def clean_up_temporary_directory():
|
|
25
|
+
if _tmpdirs is not None:
|
|
26
|
+
for d in _tmpdirs:
|
|
27
|
+
try:
|
|
28
|
+
shutil.rmtree(d)
|
|
29
|
+
except OSError:
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
atexit.register(clean_up_temporary_directory)
|
|
33
|
+
|
|
34
|
+
__all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict',
|
|
35
|
+
'dict_append', 'appendpath', 'generate_config_py',
|
|
36
|
+
'get_cmd', 'allpath', 'get_mathlibs',
|
|
37
|
+
'terminal_has_colors', 'red_text', 'green_text', 'yellow_text',
|
|
38
|
+
'blue_text', 'cyan_text', 'cyg2win32', 'mingw32', 'all_strings',
|
|
39
|
+
'has_f_sources', 'has_cxx_sources', 'filter_sources',
|
|
40
|
+
'get_dependencies', 'is_local_src_dir', 'get_ext_source_files',
|
|
41
|
+
'get_script_files', 'get_lib_source_files', 'get_data_files',
|
|
42
|
+
'dot_join', 'get_frame', 'minrelpath', 'njoin',
|
|
43
|
+
'is_sequence', 'is_string', 'as_list', 'gpaths', 'get_language',
|
|
44
|
+
'get_build_architecture', 'get_info', 'get_pkg_info',
|
|
45
|
+
'get_num_build_jobs', 'sanitize_cxx_flags',
|
|
46
|
+
'exec_mod_from_location']
|
|
47
|
+
|
|
48
|
+
class InstallableLib:
|
|
49
|
+
"""
|
|
50
|
+
Container to hold information on an installable library.
|
|
51
|
+
|
|
52
|
+
Parameters
|
|
53
|
+
----------
|
|
54
|
+
name : str
|
|
55
|
+
Name of the installed library.
|
|
56
|
+
build_info : dict
|
|
57
|
+
Dictionary holding build information.
|
|
58
|
+
target_dir : str
|
|
59
|
+
Absolute path specifying where to install the library.
|
|
60
|
+
|
|
61
|
+
See Also
|
|
62
|
+
--------
|
|
63
|
+
Configuration.add_installed_library
|
|
64
|
+
|
|
65
|
+
Notes
|
|
66
|
+
-----
|
|
67
|
+
The three parameters are stored as attributes with the same names.
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
def __init__(self, name, build_info, target_dir):
|
|
71
|
+
self.name = name
|
|
72
|
+
self.build_info = build_info
|
|
73
|
+
self.target_dir = target_dir
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def get_num_build_jobs():
|
|
77
|
+
"""
|
|
78
|
+
Get number of parallel build jobs set by the --parallel command line
|
|
79
|
+
argument of setup.py
|
|
80
|
+
If the command did not receive a setting the environment variable
|
|
81
|
+
NPY_NUM_BUILD_JOBS is checked. If that is unset, return the number of
|
|
82
|
+
processors on the system, with a maximum of 8 (to prevent
|
|
83
|
+
overloading the system if there a lot of CPUs).
|
|
84
|
+
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
out : int
|
|
88
|
+
number of parallel jobs that can be run
|
|
89
|
+
|
|
90
|
+
"""
|
|
91
|
+
from numpy.distutils.core import get_distribution
|
|
92
|
+
try:
|
|
93
|
+
cpu_count = len(os.sched_getaffinity(0))
|
|
94
|
+
except AttributeError:
|
|
95
|
+
cpu_count = multiprocessing.cpu_count()
|
|
96
|
+
cpu_count = min(cpu_count, 8)
|
|
97
|
+
envjobs = int(os.environ.get("NPY_NUM_BUILD_JOBS", cpu_count))
|
|
98
|
+
dist = get_distribution()
|
|
99
|
+
# may be None during configuration
|
|
100
|
+
if dist is None:
|
|
101
|
+
return envjobs
|
|
102
|
+
|
|
103
|
+
# any of these three may have the job set, take the largest
|
|
104
|
+
cmdattr = (getattr(dist.get_command_obj('build'), 'parallel', None),
|
|
105
|
+
getattr(dist.get_command_obj('build_ext'), 'parallel', None),
|
|
106
|
+
getattr(dist.get_command_obj('build_clib'), 'parallel', None))
|
|
107
|
+
if all(x is None for x in cmdattr):
|
|
108
|
+
return envjobs
|
|
109
|
+
else:
|
|
110
|
+
return max(x for x in cmdattr if x is not None)
|
|
111
|
+
|
|
112
|
+
def quote_args(args):
|
|
113
|
+
"""Quote list of arguments.
|
|
114
|
+
|
|
115
|
+
.. deprecated:: 1.22.
|
|
116
|
+
"""
|
|
117
|
+
import warnings
|
|
118
|
+
warnings.warn('"quote_args" is deprecated.',
|
|
119
|
+
DeprecationWarning, stacklevel=2)
|
|
120
|
+
# don't used _nt_quote_args as it does not check if
|
|
121
|
+
# args items already have quotes or not.
|
|
122
|
+
args = list(args)
|
|
123
|
+
for i in range(len(args)):
|
|
124
|
+
a = args[i]
|
|
125
|
+
if ' ' in a and a[0] not in '"\'':
|
|
126
|
+
args[i] = '"%s"' % (a)
|
|
127
|
+
return args
|
|
128
|
+
|
|
129
|
+
def allpath(name):
|
|
130
|
+
"Convert a /-separated pathname to one using the OS's path separator."
|
|
131
|
+
split = name.split('/')
|
|
132
|
+
return os.path.join(*split)
|
|
133
|
+
|
|
134
|
+
def rel_path(path, parent_path):
|
|
135
|
+
"""Return path relative to parent_path."""
|
|
136
|
+
# Use realpath to avoid issues with symlinked dirs (see gh-7707)
|
|
137
|
+
pd = os.path.realpath(os.path.abspath(parent_path))
|
|
138
|
+
apath = os.path.realpath(os.path.abspath(path))
|
|
139
|
+
if len(apath) < len(pd):
|
|
140
|
+
return path
|
|
141
|
+
if apath == pd:
|
|
142
|
+
return ''
|
|
143
|
+
if pd == apath[:len(pd)]:
|
|
144
|
+
assert apath[len(pd)] in [os.sep], repr((path, apath[len(pd)]))
|
|
145
|
+
path = apath[len(pd)+1:]
|
|
146
|
+
return path
|
|
147
|
+
|
|
148
|
+
def get_path_from_frame(frame, parent_path=None):
|
|
149
|
+
"""Return path of the module given a frame object from the call stack.
|
|
150
|
+
|
|
151
|
+
Returned path is relative to parent_path when given,
|
|
152
|
+
otherwise it is absolute path.
|
|
153
|
+
"""
|
|
154
|
+
|
|
155
|
+
# First, try to find if the file name is in the frame.
|
|
156
|
+
try:
|
|
157
|
+
caller_file = eval('__file__', frame.f_globals, frame.f_locals)
|
|
158
|
+
d = os.path.dirname(os.path.abspath(caller_file))
|
|
159
|
+
except NameError:
|
|
160
|
+
# __file__ is not defined, so let's try __name__. We try this second
|
|
161
|
+
# because setuptools spoofs __name__ to be '__main__' even though
|
|
162
|
+
# sys.modules['__main__'] might be something else, like easy_install(1).
|
|
163
|
+
caller_name = eval('__name__', frame.f_globals, frame.f_locals)
|
|
164
|
+
__import__(caller_name)
|
|
165
|
+
mod = sys.modules[caller_name]
|
|
166
|
+
if hasattr(mod, '__file__'):
|
|
167
|
+
d = os.path.dirname(os.path.abspath(mod.__file__))
|
|
168
|
+
else:
|
|
169
|
+
# we're probably running setup.py as execfile("setup.py")
|
|
170
|
+
# (likely we're building an egg)
|
|
171
|
+
d = os.path.abspath('.')
|
|
172
|
+
|
|
173
|
+
if parent_path is not None:
|
|
174
|
+
d = rel_path(d, parent_path)
|
|
175
|
+
|
|
176
|
+
return d or '.'
|
|
177
|
+
|
|
178
|
+
def njoin(*path):
|
|
179
|
+
"""Join two or more pathname components +
|
|
180
|
+
- convert a /-separated pathname to one using the OS's path separator.
|
|
181
|
+
- resolve `..` and `.` from path.
|
|
182
|
+
|
|
183
|
+
Either passing n arguments as in njoin('a','b'), or a sequence
|
|
184
|
+
of n names as in njoin(['a','b']) is handled, or a mixture of such arguments.
|
|
185
|
+
"""
|
|
186
|
+
paths = []
|
|
187
|
+
for p in path:
|
|
188
|
+
if is_sequence(p):
|
|
189
|
+
# njoin(['a', 'b'], 'c')
|
|
190
|
+
paths.append(njoin(*p))
|
|
191
|
+
else:
|
|
192
|
+
assert is_string(p)
|
|
193
|
+
paths.append(p)
|
|
194
|
+
path = paths
|
|
195
|
+
if not path:
|
|
196
|
+
# njoin()
|
|
197
|
+
joined = ''
|
|
198
|
+
else:
|
|
199
|
+
# njoin('a', 'b')
|
|
200
|
+
joined = os.path.join(*path)
|
|
201
|
+
if os.path.sep != '/':
|
|
202
|
+
joined = joined.replace('/', os.path.sep)
|
|
203
|
+
return minrelpath(joined)
|
|
204
|
+
|
|
205
|
+
def get_mathlibs(path=None):
|
|
206
|
+
"""Return the MATHLIB line from numpyconfig.h
|
|
207
|
+
"""
|
|
208
|
+
if path is not None:
|
|
209
|
+
config_file = os.path.join(path, '_numpyconfig.h')
|
|
210
|
+
else:
|
|
211
|
+
# Look for the file in each of the numpy include directories.
|
|
212
|
+
dirs = get_numpy_include_dirs()
|
|
213
|
+
for path in dirs:
|
|
214
|
+
fn = os.path.join(path, '_numpyconfig.h')
|
|
215
|
+
if os.path.exists(fn):
|
|
216
|
+
config_file = fn
|
|
217
|
+
break
|
|
218
|
+
else:
|
|
219
|
+
raise DistutilsError('_numpyconfig.h not found in numpy include '
|
|
220
|
+
'dirs %r' % (dirs,))
|
|
221
|
+
|
|
222
|
+
with open(config_file) as fid:
|
|
223
|
+
mathlibs = []
|
|
224
|
+
s = '#define MATHLIB'
|
|
225
|
+
for line in fid:
|
|
226
|
+
if line.startswith(s):
|
|
227
|
+
value = line[len(s):].strip()
|
|
228
|
+
if value:
|
|
229
|
+
mathlibs.extend(value.split(','))
|
|
230
|
+
return mathlibs
|
|
231
|
+
|
|
232
|
+
def minrelpath(path):
|
|
233
|
+
"""Resolve `..` and '.' from path.
|
|
234
|
+
"""
|
|
235
|
+
if not is_string(path):
|
|
236
|
+
return path
|
|
237
|
+
if '.' not in path:
|
|
238
|
+
return path
|
|
239
|
+
l = path.split(os.sep)
|
|
240
|
+
while l:
|
|
241
|
+
try:
|
|
242
|
+
i = l.index('.', 1)
|
|
243
|
+
except ValueError:
|
|
244
|
+
break
|
|
245
|
+
del l[i]
|
|
246
|
+
j = 1
|
|
247
|
+
while l:
|
|
248
|
+
try:
|
|
249
|
+
i = l.index('..', j)
|
|
250
|
+
except ValueError:
|
|
251
|
+
break
|
|
252
|
+
if l[i-1]=='..':
|
|
253
|
+
j += 1
|
|
254
|
+
else:
|
|
255
|
+
del l[i], l[i-1]
|
|
256
|
+
j = 1
|
|
257
|
+
if not l:
|
|
258
|
+
return ''
|
|
259
|
+
return os.sep.join(l)
|
|
260
|
+
|
|
261
|
+
def sorted_glob(fileglob):
|
|
262
|
+
"""sorts output of python glob for https://bugs.python.org/issue30461
|
|
263
|
+
to allow extensions to have reproducible build results"""
|
|
264
|
+
return sorted(glob.glob(fileglob))
|
|
265
|
+
|
|
266
|
+
def _fix_paths(paths, local_path, include_non_existing):
|
|
267
|
+
assert is_sequence(paths), repr(type(paths))
|
|
268
|
+
new_paths = []
|
|
269
|
+
assert not is_string(paths), repr(paths)
|
|
270
|
+
for n in paths:
|
|
271
|
+
if is_string(n):
|
|
272
|
+
if '*' in n or '?' in n:
|
|
273
|
+
p = sorted_glob(n)
|
|
274
|
+
p2 = sorted_glob(njoin(local_path, n))
|
|
275
|
+
if p2:
|
|
276
|
+
new_paths.extend(p2)
|
|
277
|
+
elif p:
|
|
278
|
+
new_paths.extend(p)
|
|
279
|
+
else:
|
|
280
|
+
if include_non_existing:
|
|
281
|
+
new_paths.append(n)
|
|
282
|
+
print('could not resolve pattern in %r: %r' %
|
|
283
|
+
(local_path, n))
|
|
284
|
+
else:
|
|
285
|
+
n2 = njoin(local_path, n)
|
|
286
|
+
if os.path.exists(n2):
|
|
287
|
+
new_paths.append(n2)
|
|
288
|
+
else:
|
|
289
|
+
if os.path.exists(n):
|
|
290
|
+
new_paths.append(n)
|
|
291
|
+
elif include_non_existing:
|
|
292
|
+
new_paths.append(n)
|
|
293
|
+
if not os.path.exists(n):
|
|
294
|
+
print('non-existing path in %r: %r' %
|
|
295
|
+
(local_path, n))
|
|
296
|
+
|
|
297
|
+
elif is_sequence(n):
|
|
298
|
+
new_paths.extend(_fix_paths(n, local_path, include_non_existing))
|
|
299
|
+
else:
|
|
300
|
+
new_paths.append(n)
|
|
301
|
+
return [minrelpath(p) for p in new_paths]
|
|
302
|
+
|
|
303
|
+
def gpaths(paths, local_path='', include_non_existing=True):
|
|
304
|
+
"""Apply glob to paths and prepend local_path if needed.
|
|
305
|
+
"""
|
|
306
|
+
if is_string(paths):
|
|
307
|
+
paths = (paths,)
|
|
308
|
+
return _fix_paths(paths, local_path, include_non_existing)
|
|
309
|
+
|
|
310
|
+
def make_temp_file(suffix='', prefix='', text=True):
|
|
311
|
+
if not hasattr(_tdata, 'tempdir'):
|
|
312
|
+
_tdata.tempdir = tempfile.mkdtemp()
|
|
313
|
+
_tmpdirs.append(_tdata.tempdir)
|
|
314
|
+
fid, name = tempfile.mkstemp(suffix=suffix,
|
|
315
|
+
prefix=prefix,
|
|
316
|
+
dir=_tdata.tempdir,
|
|
317
|
+
text=text)
|
|
318
|
+
fo = os.fdopen(fid, 'w')
|
|
319
|
+
return fo, name
|
|
320
|
+
|
|
321
|
+
# Hooks for colored terminal output.
|
|
322
|
+
# See also https://web.archive.org/web/20100314204946/http://www.livinglogic.de/Python/ansistyle
|
|
323
|
+
def terminal_has_colors():
|
|
324
|
+
if sys.platform=='cygwin' and 'USE_COLOR' not in os.environ:
|
|
325
|
+
# Avoid importing curses that causes illegal operation
|
|
326
|
+
# with a message:
|
|
327
|
+
# PYTHON2 caused an invalid page fault in
|
|
328
|
+
# module CYGNURSES7.DLL as 015f:18bbfc28
|
|
329
|
+
# Details: Python 2.3.3 [GCC 3.3.1 (cygming special)]
|
|
330
|
+
# ssh to Win32 machine from debian
|
|
331
|
+
# curses.version is 2.2
|
|
332
|
+
# CYGWIN_98-4.10, release 1.5.7(0.109/3/2))
|
|
333
|
+
return 0
|
|
334
|
+
if hasattr(sys.stdout, 'isatty') and sys.stdout.isatty():
|
|
335
|
+
try:
|
|
336
|
+
import curses
|
|
337
|
+
curses.setupterm()
|
|
338
|
+
if (curses.tigetnum("colors") >= 0
|
|
339
|
+
and curses.tigetnum("pairs") >= 0
|
|
340
|
+
and ((curses.tigetstr("setf") is not None
|
|
341
|
+
and curses.tigetstr("setb") is not None)
|
|
342
|
+
or (curses.tigetstr("setaf") is not None
|
|
343
|
+
and curses.tigetstr("setab") is not None)
|
|
344
|
+
or curses.tigetstr("scp") is not None)):
|
|
345
|
+
return 1
|
|
346
|
+
except Exception:
|
|
347
|
+
pass
|
|
348
|
+
return 0
|
|
349
|
+
|
|
350
|
+
if terminal_has_colors():
|
|
351
|
+
_colour_codes = dict(black=0, red=1, green=2, yellow=3,
|
|
352
|
+
blue=4, magenta=5, cyan=6, white=7, default=9)
|
|
353
|
+
def colour_text(s, fg=None, bg=None, bold=False):
|
|
354
|
+
seq = []
|
|
355
|
+
if bold:
|
|
356
|
+
seq.append('1')
|
|
357
|
+
if fg:
|
|
358
|
+
fgcode = 30 + _colour_codes.get(fg.lower(), 0)
|
|
359
|
+
seq.append(str(fgcode))
|
|
360
|
+
if bg:
|
|
361
|
+
bgcode = 40 + _colour_codes.get(bg.lower(), 7)
|
|
362
|
+
seq.append(str(bgcode))
|
|
363
|
+
if seq:
|
|
364
|
+
return '\x1b[%sm%s\x1b[0m' % (';'.join(seq), s)
|
|
365
|
+
else:
|
|
366
|
+
return s
|
|
367
|
+
else:
|
|
368
|
+
def colour_text(s, fg=None, bg=None):
|
|
369
|
+
return s
|
|
370
|
+
|
|
371
|
+
def default_text(s):
|
|
372
|
+
return colour_text(s, 'default')
|
|
373
|
+
def red_text(s):
|
|
374
|
+
return colour_text(s, 'red')
|
|
375
|
+
def green_text(s):
|
|
376
|
+
return colour_text(s, 'green')
|
|
377
|
+
def yellow_text(s):
|
|
378
|
+
return colour_text(s, 'yellow')
|
|
379
|
+
def cyan_text(s):
|
|
380
|
+
return colour_text(s, 'cyan')
|
|
381
|
+
def blue_text(s):
|
|
382
|
+
return colour_text(s, 'blue')
|
|
383
|
+
|
|
384
|
+
#########################
|
|
385
|
+
|
|
386
|
+
def cyg2win32(path: str) -> str:
|
|
387
|
+
"""Convert a path from Cygwin-native to Windows-native.
|
|
388
|
+
|
|
389
|
+
Uses the cygpath utility (part of the Base install) to do the
|
|
390
|
+
actual conversion. Falls back to returning the original path if
|
|
391
|
+
this fails.
|
|
392
|
+
|
|
393
|
+
Handles the default ``/cygdrive`` mount prefix as well as the
|
|
394
|
+
``/proc/cygdrive`` portable prefix, custom cygdrive prefixes such
|
|
395
|
+
as ``/`` or ``/mnt``, and absolute paths such as ``/usr/src/`` or
|
|
396
|
+
``/home/username``
|
|
397
|
+
|
|
398
|
+
Parameters
|
|
399
|
+
----------
|
|
400
|
+
path : str
|
|
401
|
+
The path to convert
|
|
402
|
+
|
|
403
|
+
Returns
|
|
404
|
+
-------
|
|
405
|
+
converted_path : str
|
|
406
|
+
The converted path
|
|
407
|
+
|
|
408
|
+
Notes
|
|
409
|
+
-----
|
|
410
|
+
Documentation for cygpath utility:
|
|
411
|
+
https://cygwin.com/cygwin-ug-net/cygpath.html
|
|
412
|
+
Documentation for the C function it wraps:
|
|
413
|
+
https://cygwin.com/cygwin-api/func-cygwin-conv-path.html
|
|
414
|
+
|
|
415
|
+
"""
|
|
416
|
+
if sys.platform != "cygwin":
|
|
417
|
+
return path
|
|
418
|
+
return subprocess.check_output(
|
|
419
|
+
["/usr/bin/cygpath", "--windows", path], text=True
|
|
420
|
+
)
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
def mingw32():
|
|
424
|
+
"""Return true when using mingw32 environment.
|
|
425
|
+
"""
|
|
426
|
+
if sys.platform=='win32':
|
|
427
|
+
if os.environ.get('OSTYPE', '')=='msys':
|
|
428
|
+
return True
|
|
429
|
+
if os.environ.get('MSYSTEM', '')=='MINGW32':
|
|
430
|
+
return True
|
|
431
|
+
return False
|
|
432
|
+
|
|
433
|
+
def msvc_runtime_version():
|
|
434
|
+
"Return version of MSVC runtime library, as defined by __MSC_VER__ macro"
|
|
435
|
+
msc_pos = sys.version.find('MSC v.')
|
|
436
|
+
if msc_pos != -1:
|
|
437
|
+
msc_ver = int(sys.version[msc_pos+6:msc_pos+10])
|
|
438
|
+
else:
|
|
439
|
+
msc_ver = None
|
|
440
|
+
return msc_ver
|
|
441
|
+
|
|
442
|
+
def msvc_runtime_library():
|
|
443
|
+
"Return name of MSVC runtime library if Python was built with MSVC >= 7"
|
|
444
|
+
ver = msvc_runtime_major ()
|
|
445
|
+
if ver:
|
|
446
|
+
if ver < 140:
|
|
447
|
+
return "msvcr%i" % ver
|
|
448
|
+
else:
|
|
449
|
+
return "vcruntime%i" % ver
|
|
450
|
+
else:
|
|
451
|
+
return None
|
|
452
|
+
|
|
453
|
+
def msvc_runtime_major():
|
|
454
|
+
"Return major version of MSVC runtime coded like get_build_msvc_version"
|
|
455
|
+
major = {1300: 70, # MSVC 7.0
|
|
456
|
+
1310: 71, # MSVC 7.1
|
|
457
|
+
1400: 80, # MSVC 8
|
|
458
|
+
1500: 90, # MSVC 9 (aka 2008)
|
|
459
|
+
1600: 100, # MSVC 10 (aka 2010)
|
|
460
|
+
1900: 140, # MSVC 14 (aka 2015)
|
|
461
|
+
}.get(msvc_runtime_version(), None)
|
|
462
|
+
return major
|
|
463
|
+
|
|
464
|
+
#########################
|
|
465
|
+
|
|
466
|
+
#XXX need support for .C that is also C++
|
|
467
|
+
cxx_ext_match = re.compile(r'.*\.(cpp|cxx|cc)\Z', re.I).match
|
|
468
|
+
fortran_ext_match = re.compile(r'.*\.(f90|f95|f77|for|ftn|f)\Z', re.I).match
|
|
469
|
+
f90_ext_match = re.compile(r'.*\.(f90|f95)\Z', re.I).match
|
|
470
|
+
f90_module_name_match = re.compile(r'\s*module\s*(?P<name>[\w_]+)', re.I).match
|
|
471
|
+
def _get_f90_modules(source):
|
|
472
|
+
"""Return a list of Fortran f90 module names that
|
|
473
|
+
given source file defines.
|
|
474
|
+
"""
|
|
475
|
+
if not f90_ext_match(source):
|
|
476
|
+
return []
|
|
477
|
+
modules = []
|
|
478
|
+
with open(source) as f:
|
|
479
|
+
for line in f:
|
|
480
|
+
m = f90_module_name_match(line)
|
|
481
|
+
if m:
|
|
482
|
+
name = m.group('name')
|
|
483
|
+
modules.append(name)
|
|
484
|
+
# break # XXX can we assume that there is one module per file?
|
|
485
|
+
return modules
|
|
486
|
+
|
|
487
|
+
def is_string(s):
|
|
488
|
+
return isinstance(s, str)
|
|
489
|
+
|
|
490
|
+
def all_strings(lst):
|
|
491
|
+
"""Return True if all items in lst are string objects. """
|
|
492
|
+
return all(is_string(item) for item in lst)
|
|
493
|
+
|
|
494
|
+
def is_sequence(seq):
|
|
495
|
+
if is_string(seq):
|
|
496
|
+
return False
|
|
497
|
+
try:
|
|
498
|
+
len(seq)
|
|
499
|
+
except Exception:
|
|
500
|
+
return False
|
|
501
|
+
return True
|
|
502
|
+
|
|
503
|
+
def is_glob_pattern(s):
|
|
504
|
+
return is_string(s) and ('*' in s or '?' in s)
|
|
505
|
+
|
|
506
|
+
def as_list(seq):
|
|
507
|
+
if is_sequence(seq):
|
|
508
|
+
return list(seq)
|
|
509
|
+
else:
|
|
510
|
+
return [seq]
|
|
511
|
+
|
|
512
|
+
def get_language(sources):
|
|
513
|
+
# not used in numpy/scipy packages, use build_ext.detect_language instead
|
|
514
|
+
"""Determine language value (c,f77,f90) from sources """
|
|
515
|
+
language = None
|
|
516
|
+
for source in sources:
|
|
517
|
+
if isinstance(source, str):
|
|
518
|
+
if f90_ext_match(source):
|
|
519
|
+
language = 'f90'
|
|
520
|
+
break
|
|
521
|
+
elif fortran_ext_match(source):
|
|
522
|
+
language = 'f77'
|
|
523
|
+
return language
|
|
524
|
+
|
|
525
|
+
def has_f_sources(sources):
|
|
526
|
+
"""Return True if sources contains Fortran files """
|
|
527
|
+
return any(fortran_ext_match(source) for source in sources)
|
|
528
|
+
|
|
529
|
+
def has_cxx_sources(sources):
|
|
530
|
+
"""Return True if sources contains C++ files """
|
|
531
|
+
return any(cxx_ext_match(source) for source in sources)
|
|
532
|
+
|
|
533
|
+
def filter_sources(sources):
|
|
534
|
+
"""Return four lists of filenames containing
|
|
535
|
+
C, C++, Fortran, and Fortran 90 module sources,
|
|
536
|
+
respectively.
|
|
537
|
+
"""
|
|
538
|
+
c_sources = []
|
|
539
|
+
cxx_sources = []
|
|
540
|
+
f_sources = []
|
|
541
|
+
fmodule_sources = []
|
|
542
|
+
for source in sources:
|
|
543
|
+
if fortran_ext_match(source):
|
|
544
|
+
modules = _get_f90_modules(source)
|
|
545
|
+
if modules:
|
|
546
|
+
fmodule_sources.append(source)
|
|
547
|
+
else:
|
|
548
|
+
f_sources.append(source)
|
|
549
|
+
elif cxx_ext_match(source):
|
|
550
|
+
cxx_sources.append(source)
|
|
551
|
+
else:
|
|
552
|
+
c_sources.append(source)
|
|
553
|
+
return c_sources, cxx_sources, f_sources, fmodule_sources
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
def _get_headers(directory_list):
|
|
557
|
+
# get *.h files from list of directories
|
|
558
|
+
headers = []
|
|
559
|
+
for d in directory_list:
|
|
560
|
+
head = sorted_glob(os.path.join(d, "*.h")) #XXX: *.hpp files??
|
|
561
|
+
headers.extend(head)
|
|
562
|
+
return headers
|
|
563
|
+
|
|
564
|
+
def _get_directories(list_of_sources):
|
|
565
|
+
# get unique directories from list of sources.
|
|
566
|
+
direcs = []
|
|
567
|
+
for f in list_of_sources:
|
|
568
|
+
d = os.path.split(f)
|
|
569
|
+
if d[0] != '' and not d[0] in direcs:
|
|
570
|
+
direcs.append(d[0])
|
|
571
|
+
return direcs
|
|
572
|
+
|
|
573
|
+
def _commandline_dep_string(cc_args, extra_postargs, pp_opts):
|
|
574
|
+
"""
|
|
575
|
+
Return commandline representation used to determine if a file needs
|
|
576
|
+
to be recompiled
|
|
577
|
+
"""
|
|
578
|
+
cmdline = 'commandline: '
|
|
579
|
+
cmdline += ' '.join(cc_args)
|
|
580
|
+
cmdline += ' '.join(extra_postargs)
|
|
581
|
+
cmdline += ' '.join(pp_opts) + '\n'
|
|
582
|
+
return cmdline
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
def get_dependencies(sources):
|
|
586
|
+
#XXX scan sources for include statements
|
|
587
|
+
return _get_headers(_get_directories(sources))
|
|
588
|
+
|
|
589
|
+
def is_local_src_dir(directory):
|
|
590
|
+
"""Return true if directory is local directory.
|
|
591
|
+
"""
|
|
592
|
+
if not is_string(directory):
|
|
593
|
+
return False
|
|
594
|
+
abs_dir = os.path.abspath(directory)
|
|
595
|
+
c = os.path.commonprefix([os.getcwd(), abs_dir])
|
|
596
|
+
new_dir = abs_dir[len(c):].split(os.sep)
|
|
597
|
+
if new_dir and not new_dir[0]:
|
|
598
|
+
new_dir = new_dir[1:]
|
|
599
|
+
if new_dir and new_dir[0]=='build':
|
|
600
|
+
return False
|
|
601
|
+
new_dir = os.sep.join(new_dir)
|
|
602
|
+
return os.path.isdir(new_dir)
|
|
603
|
+
|
|
604
|
+
def general_source_files(top_path):
|
|
605
|
+
pruned_directories = {'CVS':1, '.svn':1, 'build':1}
|
|
606
|
+
prune_file_pat = re.compile(r'(?:[~#]|\.py[co]|\.o)$')
|
|
607
|
+
for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):
|
|
608
|
+
pruned = [ d for d in dirnames if d not in pruned_directories ]
|
|
609
|
+
dirnames[:] = pruned
|
|
610
|
+
for f in filenames:
|
|
611
|
+
if not prune_file_pat.search(f):
|
|
612
|
+
yield os.path.join(dirpath, f)
|
|
613
|
+
|
|
614
|
+
def general_source_directories_files(top_path):
|
|
615
|
+
"""Return a directory name relative to top_path and
|
|
616
|
+
files contained.
|
|
617
|
+
"""
|
|
618
|
+
pruned_directories = ['CVS', '.svn', 'build']
|
|
619
|
+
prune_file_pat = re.compile(r'(?:[~#]|\.py[co]|\.o)$')
|
|
620
|
+
for dirpath, dirnames, filenames in os.walk(top_path, topdown=True):
|
|
621
|
+
pruned = [ d for d in dirnames if d not in pruned_directories ]
|
|
622
|
+
dirnames[:] = pruned
|
|
623
|
+
for d in dirnames:
|
|
624
|
+
dpath = os.path.join(dirpath, d)
|
|
625
|
+
rpath = rel_path(dpath, top_path)
|
|
626
|
+
files = []
|
|
627
|
+
for f in os.listdir(dpath):
|
|
628
|
+
fn = os.path.join(dpath, f)
|
|
629
|
+
if os.path.isfile(fn) and not prune_file_pat.search(fn):
|
|
630
|
+
files.append(fn)
|
|
631
|
+
yield rpath, files
|
|
632
|
+
dpath = top_path
|
|
633
|
+
rpath = rel_path(dpath, top_path)
|
|
634
|
+
filenames = [os.path.join(dpath, f) for f in os.listdir(dpath) \
|
|
635
|
+
if not prune_file_pat.search(f)]
|
|
636
|
+
files = [f for f in filenames if os.path.isfile(f)]
|
|
637
|
+
yield rpath, files
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
def get_ext_source_files(ext):
|
|
641
|
+
# Get sources and any include files in the same directory.
|
|
642
|
+
filenames = []
|
|
643
|
+
sources = [_m for _m in ext.sources if is_string(_m)]
|
|
644
|
+
filenames.extend(sources)
|
|
645
|
+
filenames.extend(get_dependencies(sources))
|
|
646
|
+
for d in ext.depends:
|
|
647
|
+
if is_local_src_dir(d):
|
|
648
|
+
filenames.extend(list(general_source_files(d)))
|
|
649
|
+
elif os.path.isfile(d):
|
|
650
|
+
filenames.append(d)
|
|
651
|
+
return filenames
|
|
652
|
+
|
|
653
|
+
def get_script_files(scripts):
|
|
654
|
+
scripts = [_m for _m in scripts if is_string(_m)]
|
|
655
|
+
return scripts
|
|
656
|
+
|
|
657
|
+
def get_lib_source_files(lib):
|
|
658
|
+
filenames = []
|
|
659
|
+
sources = lib[1].get('sources', [])
|
|
660
|
+
sources = [_m for _m in sources if is_string(_m)]
|
|
661
|
+
filenames.extend(sources)
|
|
662
|
+
filenames.extend(get_dependencies(sources))
|
|
663
|
+
depends = lib[1].get('depends', [])
|
|
664
|
+
for d in depends:
|
|
665
|
+
if is_local_src_dir(d):
|
|
666
|
+
filenames.extend(list(general_source_files(d)))
|
|
667
|
+
elif os.path.isfile(d):
|
|
668
|
+
filenames.append(d)
|
|
669
|
+
return filenames
|
|
670
|
+
|
|
671
|
+
def get_shared_lib_extension(is_python_ext=False):
|
|
672
|
+
"""Return the correct file extension for shared libraries.
|
|
673
|
+
|
|
674
|
+
Parameters
|
|
675
|
+
----------
|
|
676
|
+
is_python_ext : bool, optional
|
|
677
|
+
Whether the shared library is a Python extension. Default is False.
|
|
678
|
+
|
|
679
|
+
Returns
|
|
680
|
+
-------
|
|
681
|
+
so_ext : str
|
|
682
|
+
The shared library extension.
|
|
683
|
+
|
|
684
|
+
Notes
|
|
685
|
+
-----
|
|
686
|
+
For Python shared libs, `so_ext` will typically be '.so' on Linux and OS X,
|
|
687
|
+
and '.pyd' on Windows. For Python >= 3.2 `so_ext` has a tag prepended on
|
|
688
|
+
POSIX systems according to PEP 3149.
|
|
689
|
+
|
|
690
|
+
"""
|
|
691
|
+
confvars = distutils.sysconfig.get_config_vars()
|
|
692
|
+
so_ext = confvars.get('EXT_SUFFIX', '')
|
|
693
|
+
|
|
694
|
+
if not is_python_ext:
|
|
695
|
+
# hardcode known values, config vars (including SHLIB_SUFFIX) are
|
|
696
|
+
# unreliable (see #3182)
|
|
697
|
+
# darwin, windows and debug linux are wrong in 3.3.1 and older
|
|
698
|
+
if (sys.platform.startswith('linux') or
|
|
699
|
+
sys.platform.startswith('gnukfreebsd')):
|
|
700
|
+
so_ext = '.so'
|
|
701
|
+
elif sys.platform.startswith('darwin'):
|
|
702
|
+
so_ext = '.dylib'
|
|
703
|
+
elif sys.platform.startswith('win'):
|
|
704
|
+
so_ext = '.dll'
|
|
705
|
+
else:
|
|
706
|
+
# fall back to config vars for unknown platforms
|
|
707
|
+
# fix long extension for Python >=3.2, see PEP 3149.
|
|
708
|
+
if 'SOABI' in confvars:
|
|
709
|
+
# Does nothing unless SOABI config var exists
|
|
710
|
+
so_ext = so_ext.replace('.' + confvars.get('SOABI'), '', 1)
|
|
711
|
+
|
|
712
|
+
return so_ext
|
|
713
|
+
|
|
714
|
+
def get_data_files(data):
|
|
715
|
+
if is_string(data):
|
|
716
|
+
return [data]
|
|
717
|
+
sources = data[1]
|
|
718
|
+
filenames = []
|
|
719
|
+
for s in sources:
|
|
720
|
+
if hasattr(s, '__call__'):
|
|
721
|
+
continue
|
|
722
|
+
if is_local_src_dir(s):
|
|
723
|
+
filenames.extend(list(general_source_files(s)))
|
|
724
|
+
elif is_string(s):
|
|
725
|
+
if os.path.isfile(s):
|
|
726
|
+
filenames.append(s)
|
|
727
|
+
else:
|
|
728
|
+
print('Not existing data file:', s)
|
|
729
|
+
else:
|
|
730
|
+
raise TypeError(repr(s))
|
|
731
|
+
return filenames
|
|
732
|
+
|
|
733
|
+
def dot_join(*args):
|
|
734
|
+
return '.'.join([a for a in args if a])
|
|
735
|
+
|
|
736
|
+
def get_frame(level=0):
|
|
737
|
+
"""Return frame object from call stack with given level.
|
|
738
|
+
"""
|
|
739
|
+
try:
|
|
740
|
+
return sys._getframe(level+1)
|
|
741
|
+
except AttributeError:
|
|
742
|
+
frame = sys.exc_info()[2].tb_frame
|
|
743
|
+
for _ in range(level+1):
|
|
744
|
+
frame = frame.f_back
|
|
745
|
+
return frame
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
######################
|
|
749
|
+
|
|
750
|
+
class Configuration:
|
|
751
|
+
|
|
752
|
+
_list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',
|
|
753
|
+
'libraries', 'headers', 'scripts', 'py_modules',
|
|
754
|
+
'installed_libraries', 'define_macros']
|
|
755
|
+
_dict_keys = ['package_dir', 'installed_pkg_config']
|
|
756
|
+
_extra_keys = ['name', 'version']
|
|
757
|
+
|
|
758
|
+
numpy_include_dirs = []
|
|
759
|
+
|
|
760
|
+
def __init__(self,
|
|
761
|
+
package_name=None,
|
|
762
|
+
parent_name=None,
|
|
763
|
+
top_path=None,
|
|
764
|
+
package_path=None,
|
|
765
|
+
caller_level=1,
|
|
766
|
+
setup_name='setup.py',
|
|
767
|
+
**attrs):
|
|
768
|
+
"""Construct configuration instance of a package.
|
|
769
|
+
|
|
770
|
+
package_name -- name of the package
|
|
771
|
+
Ex.: 'distutils'
|
|
772
|
+
parent_name -- name of the parent package
|
|
773
|
+
Ex.: 'numpy'
|
|
774
|
+
top_path -- directory of the toplevel package
|
|
775
|
+
Ex.: the directory where the numpy package source sits
|
|
776
|
+
package_path -- directory of package. Will be computed by magic from the
|
|
777
|
+
directory of the caller module if not specified
|
|
778
|
+
Ex.: the directory where numpy.distutils is
|
|
779
|
+
caller_level -- frame level to caller namespace, internal parameter.
|
|
780
|
+
"""
|
|
781
|
+
self.name = dot_join(parent_name, package_name)
|
|
782
|
+
self.version = None
|
|
783
|
+
|
|
784
|
+
caller_frame = get_frame(caller_level)
|
|
785
|
+
self.local_path = get_path_from_frame(caller_frame, top_path)
|
|
786
|
+
# local_path -- directory of a file (usually setup.py) that
|
|
787
|
+
# defines a configuration() function.
|
|
788
|
+
# local_path -- directory of a file (usually setup.py) that
|
|
789
|
+
# defines a configuration() function.
|
|
790
|
+
if top_path is None:
|
|
791
|
+
top_path = self.local_path
|
|
792
|
+
self.local_path = ''
|
|
793
|
+
if package_path is None:
|
|
794
|
+
package_path = self.local_path
|
|
795
|
+
elif os.path.isdir(njoin(self.local_path, package_path)):
|
|
796
|
+
package_path = njoin(self.local_path, package_path)
|
|
797
|
+
if not os.path.isdir(package_path or '.'):
|
|
798
|
+
raise ValueError("%r is not a directory" % (package_path,))
|
|
799
|
+
self.top_path = top_path
|
|
800
|
+
self.package_path = package_path
|
|
801
|
+
# this is the relative path in the installed package
|
|
802
|
+
self.path_in_package = os.path.join(*self.name.split('.'))
|
|
803
|
+
|
|
804
|
+
self.list_keys = self._list_keys[:]
|
|
805
|
+
self.dict_keys = self._dict_keys[:]
|
|
806
|
+
|
|
807
|
+
for n in self.list_keys:
|
|
808
|
+
v = copy.copy(attrs.get(n, []))
|
|
809
|
+
setattr(self, n, as_list(v))
|
|
810
|
+
|
|
811
|
+
for n in self.dict_keys:
|
|
812
|
+
v = copy.copy(attrs.get(n, {}))
|
|
813
|
+
setattr(self, n, v)
|
|
814
|
+
|
|
815
|
+
known_keys = self.list_keys + self.dict_keys
|
|
816
|
+
self.extra_keys = self._extra_keys[:]
|
|
817
|
+
for n in attrs.keys():
|
|
818
|
+
if n in known_keys:
|
|
819
|
+
continue
|
|
820
|
+
a = attrs[n]
|
|
821
|
+
setattr(self, n, a)
|
|
822
|
+
if isinstance(a, list):
|
|
823
|
+
self.list_keys.append(n)
|
|
824
|
+
elif isinstance(a, dict):
|
|
825
|
+
self.dict_keys.append(n)
|
|
826
|
+
else:
|
|
827
|
+
self.extra_keys.append(n)
|
|
828
|
+
|
|
829
|
+
if os.path.exists(njoin(package_path, '__init__.py')):
|
|
830
|
+
self.packages.append(self.name)
|
|
831
|
+
self.package_dir[self.name] = package_path
|
|
832
|
+
|
|
833
|
+
self.options = dict(
|
|
834
|
+
ignore_setup_xxx_py = False,
|
|
835
|
+
assume_default_configuration = False,
|
|
836
|
+
delegate_options_to_subpackages = False,
|
|
837
|
+
quiet = False,
|
|
838
|
+
)
|
|
839
|
+
|
|
840
|
+
caller_instance = None
|
|
841
|
+
for i in range(1, 3):
|
|
842
|
+
try:
|
|
843
|
+
f = get_frame(i)
|
|
844
|
+
except ValueError:
|
|
845
|
+
break
|
|
846
|
+
try:
|
|
847
|
+
caller_instance = eval('self', f.f_globals, f.f_locals)
|
|
848
|
+
break
|
|
849
|
+
except NameError:
|
|
850
|
+
pass
|
|
851
|
+
if isinstance(caller_instance, self.__class__):
|
|
852
|
+
if caller_instance.options['delegate_options_to_subpackages']:
|
|
853
|
+
self.set_options(**caller_instance.options)
|
|
854
|
+
|
|
855
|
+
self.setup_name = setup_name
|
|
856
|
+
|
|
857
|
+
def todict(self):
|
|
858
|
+
"""
|
|
859
|
+
Return a dictionary compatible with the keyword arguments of distutils
|
|
860
|
+
setup function.
|
|
861
|
+
|
|
862
|
+
Examples
|
|
863
|
+
--------
|
|
864
|
+
>>> setup(**config.todict()) #doctest: +SKIP
|
|
865
|
+
"""
|
|
866
|
+
|
|
867
|
+
self._optimize_data_files()
|
|
868
|
+
d = {}
|
|
869
|
+
known_keys = self.list_keys + self.dict_keys + self.extra_keys
|
|
870
|
+
for n in known_keys:
|
|
871
|
+
a = getattr(self, n)
|
|
872
|
+
if a:
|
|
873
|
+
d[n] = a
|
|
874
|
+
return d
|
|
875
|
+
|
|
876
|
+
def info(self, message):
|
|
877
|
+
if not self.options['quiet']:
|
|
878
|
+
print(message)
|
|
879
|
+
|
|
880
|
+
def warn(self, message):
|
|
881
|
+
sys.stderr.write('Warning: %s\n' % (message,))
|
|
882
|
+
|
|
883
|
+
def set_options(self, **options):
|
|
884
|
+
"""
|
|
885
|
+
Configure Configuration instance.
|
|
886
|
+
|
|
887
|
+
The following options are available:
|
|
888
|
+
- ignore_setup_xxx_py
|
|
889
|
+
- assume_default_configuration
|
|
890
|
+
- delegate_options_to_subpackages
|
|
891
|
+
- quiet
|
|
892
|
+
|
|
893
|
+
"""
|
|
894
|
+
for key, value in options.items():
|
|
895
|
+
if key in self.options:
|
|
896
|
+
self.options[key] = value
|
|
897
|
+
else:
|
|
898
|
+
raise ValueError('Unknown option: '+key)
|
|
899
|
+
|
|
900
|
+
def get_distribution(self):
|
|
901
|
+
"""Return the distutils distribution object for self."""
|
|
902
|
+
from numpy.distutils.core import get_distribution
|
|
903
|
+
return get_distribution()
|
|
904
|
+
|
|
905
|
+
def _wildcard_get_subpackage(self, subpackage_name,
|
|
906
|
+
parent_name,
|
|
907
|
+
caller_level = 1):
|
|
908
|
+
l = subpackage_name.split('.')
|
|
909
|
+
subpackage_path = njoin([self.local_path]+l)
|
|
910
|
+
dirs = [_m for _m in sorted_glob(subpackage_path) if os.path.isdir(_m)]
|
|
911
|
+
config_list = []
|
|
912
|
+
for d in dirs:
|
|
913
|
+
if not os.path.isfile(njoin(d, '__init__.py')):
|
|
914
|
+
continue
|
|
915
|
+
if 'build' in d.split(os.sep):
|
|
916
|
+
continue
|
|
917
|
+
n = '.'.join(d.split(os.sep)[-len(l):])
|
|
918
|
+
c = self.get_subpackage(n,
|
|
919
|
+
parent_name = parent_name,
|
|
920
|
+
caller_level = caller_level+1)
|
|
921
|
+
config_list.extend(c)
|
|
922
|
+
return config_list
|
|
923
|
+
|
|
924
|
+
def _get_configuration_from_setup_py(self, setup_py,
|
|
925
|
+
subpackage_name,
|
|
926
|
+
subpackage_path,
|
|
927
|
+
parent_name,
|
|
928
|
+
caller_level = 1):
|
|
929
|
+
# In case setup_py imports local modules:
|
|
930
|
+
sys.path.insert(0, os.path.dirname(setup_py))
|
|
931
|
+
try:
|
|
932
|
+
setup_name = os.path.splitext(os.path.basename(setup_py))[0]
|
|
933
|
+
n = dot_join(self.name, subpackage_name, setup_name)
|
|
934
|
+
setup_module = exec_mod_from_location(
|
|
935
|
+
'_'.join(n.split('.')), setup_py)
|
|
936
|
+
if not hasattr(setup_module, 'configuration'):
|
|
937
|
+
if not self.options['assume_default_configuration']:
|
|
938
|
+
self.warn('Assuming default configuration '\
|
|
939
|
+
'(%s does not define configuration())'\
|
|
940
|
+
% (setup_module))
|
|
941
|
+
config = Configuration(subpackage_name, parent_name,
|
|
942
|
+
self.top_path, subpackage_path,
|
|
943
|
+
caller_level = caller_level + 1)
|
|
944
|
+
else:
|
|
945
|
+
pn = dot_join(*([parent_name] + subpackage_name.split('.')[:-1]))
|
|
946
|
+
args = (pn,)
|
|
947
|
+
if setup_module.configuration.__code__.co_argcount > 1:
|
|
948
|
+
args = args + (self.top_path,)
|
|
949
|
+
config = setup_module.configuration(*args)
|
|
950
|
+
if config.name!=dot_join(parent_name, subpackage_name):
|
|
951
|
+
self.warn('Subpackage %r configuration returned as %r' % \
|
|
952
|
+
(dot_join(parent_name, subpackage_name), config.name))
|
|
953
|
+
finally:
|
|
954
|
+
del sys.path[0]
|
|
955
|
+
return config
|
|
956
|
+
|
|
957
|
+
def get_subpackage(self,subpackage_name,
|
|
958
|
+
subpackage_path=None,
|
|
959
|
+
parent_name=None,
|
|
960
|
+
caller_level = 1):
|
|
961
|
+
"""Return list of subpackage configurations.
|
|
962
|
+
|
|
963
|
+
Parameters
|
|
964
|
+
----------
|
|
965
|
+
subpackage_name : str or None
|
|
966
|
+
Name of the subpackage to get the configuration. '*' in
|
|
967
|
+
subpackage_name is handled as a wildcard.
|
|
968
|
+
subpackage_path : str
|
|
969
|
+
If None, then the path is assumed to be the local path plus the
|
|
970
|
+
subpackage_name. If a setup.py file is not found in the
|
|
971
|
+
subpackage_path, then a default configuration is used.
|
|
972
|
+
parent_name : str
|
|
973
|
+
Parent name.
|
|
974
|
+
"""
|
|
975
|
+
if subpackage_name is None:
|
|
976
|
+
if subpackage_path is None:
|
|
977
|
+
raise ValueError(
|
|
978
|
+
"either subpackage_name or subpackage_path must be specified")
|
|
979
|
+
subpackage_name = os.path.basename(subpackage_path)
|
|
980
|
+
|
|
981
|
+
# handle wildcards
|
|
982
|
+
l = subpackage_name.split('.')
|
|
983
|
+
if subpackage_path is None and '*' in subpackage_name:
|
|
984
|
+
return self._wildcard_get_subpackage(subpackage_name,
|
|
985
|
+
parent_name,
|
|
986
|
+
caller_level = caller_level+1)
|
|
987
|
+
assert '*' not in subpackage_name, repr((subpackage_name, subpackage_path, parent_name))
|
|
988
|
+
if subpackage_path is None:
|
|
989
|
+
subpackage_path = njoin([self.local_path] + l)
|
|
990
|
+
else:
|
|
991
|
+
subpackage_path = njoin([subpackage_path] + l[:-1])
|
|
992
|
+
subpackage_path = self.paths([subpackage_path])[0]
|
|
993
|
+
setup_py = njoin(subpackage_path, self.setup_name)
|
|
994
|
+
if not self.options['ignore_setup_xxx_py']:
|
|
995
|
+
if not os.path.isfile(setup_py):
|
|
996
|
+
setup_py = njoin(subpackage_path,
|
|
997
|
+
'setup_%s.py' % (subpackage_name))
|
|
998
|
+
if not os.path.isfile(setup_py):
|
|
999
|
+
if not self.options['assume_default_configuration']:
|
|
1000
|
+
self.warn('Assuming default configuration '\
|
|
1001
|
+
'(%s/{setup_%s,setup}.py was not found)' \
|
|
1002
|
+
% (os.path.dirname(setup_py), subpackage_name))
|
|
1003
|
+
config = Configuration(subpackage_name, parent_name,
|
|
1004
|
+
self.top_path, subpackage_path,
|
|
1005
|
+
caller_level = caller_level+1)
|
|
1006
|
+
else:
|
|
1007
|
+
config = self._get_configuration_from_setup_py(
|
|
1008
|
+
setup_py,
|
|
1009
|
+
subpackage_name,
|
|
1010
|
+
subpackage_path,
|
|
1011
|
+
parent_name,
|
|
1012
|
+
caller_level = caller_level + 1)
|
|
1013
|
+
if config:
|
|
1014
|
+
return [config]
|
|
1015
|
+
else:
|
|
1016
|
+
return []
|
|
1017
|
+
|
|
1018
|
+
def add_subpackage(self,subpackage_name,
|
|
1019
|
+
subpackage_path=None,
|
|
1020
|
+
standalone = False):
|
|
1021
|
+
"""Add a sub-package to the current Configuration instance.
|
|
1022
|
+
|
|
1023
|
+
This is useful in a setup.py script for adding sub-packages to a
|
|
1024
|
+
package.
|
|
1025
|
+
|
|
1026
|
+
Parameters
|
|
1027
|
+
----------
|
|
1028
|
+
subpackage_name : str
|
|
1029
|
+
name of the subpackage
|
|
1030
|
+
subpackage_path : str
|
|
1031
|
+
if given, the subpackage path such as the subpackage is in
|
|
1032
|
+
subpackage_path / subpackage_name. If None,the subpackage is
|
|
1033
|
+
assumed to be located in the local path / subpackage_name.
|
|
1034
|
+
standalone : bool
|
|
1035
|
+
"""
|
|
1036
|
+
|
|
1037
|
+
if standalone:
|
|
1038
|
+
parent_name = None
|
|
1039
|
+
else:
|
|
1040
|
+
parent_name = self.name
|
|
1041
|
+
config_list = self.get_subpackage(subpackage_name, subpackage_path,
|
|
1042
|
+
parent_name = parent_name,
|
|
1043
|
+
caller_level = 2)
|
|
1044
|
+
if not config_list:
|
|
1045
|
+
self.warn('No configuration returned, assuming unavailable.')
|
|
1046
|
+
for config in config_list:
|
|
1047
|
+
d = config
|
|
1048
|
+
if isinstance(config, Configuration):
|
|
1049
|
+
d = config.todict()
|
|
1050
|
+
assert isinstance(d, dict), repr(type(d))
|
|
1051
|
+
|
|
1052
|
+
self.info('Appending %s configuration to %s' \
|
|
1053
|
+
% (d.get('name'), self.name))
|
|
1054
|
+
self.dict_append(**d)
|
|
1055
|
+
|
|
1056
|
+
dist = self.get_distribution()
|
|
1057
|
+
if dist is not None:
|
|
1058
|
+
self.warn('distutils distribution has been initialized,'\
|
|
1059
|
+
' it may be too late to add a subpackage '+ subpackage_name)
|
|
1060
|
+
|
|
1061
|
+
def add_data_dir(self, data_path):
|
|
1062
|
+
"""Recursively add files under data_path to data_files list.
|
|
1063
|
+
|
|
1064
|
+
Recursively add files under data_path to the list of data_files to be
|
|
1065
|
+
installed (and distributed). The data_path can be either a relative
|
|
1066
|
+
path-name, or an absolute path-name, or a 2-tuple where the first
|
|
1067
|
+
argument shows where in the install directory the data directory
|
|
1068
|
+
should be installed to.
|
|
1069
|
+
|
|
1070
|
+
Parameters
|
|
1071
|
+
----------
|
|
1072
|
+
data_path : seq or str
|
|
1073
|
+
Argument can be either
|
|
1074
|
+
|
|
1075
|
+
* 2-sequence (<datadir suffix>, <path to data directory>)
|
|
1076
|
+
* path to data directory where python datadir suffix defaults
|
|
1077
|
+
to package dir.
|
|
1078
|
+
|
|
1079
|
+
Notes
|
|
1080
|
+
-----
|
|
1081
|
+
Rules for installation paths::
|
|
1082
|
+
|
|
1083
|
+
foo/bar -> (foo/bar, foo/bar) -> parent/foo/bar
|
|
1084
|
+
(gun, foo/bar) -> parent/gun
|
|
1085
|
+
foo/* -> (foo/a, foo/a), (foo/b, foo/b) -> parent/foo/a, parent/foo/b
|
|
1086
|
+
(gun, foo/*) -> (gun, foo/a), (gun, foo/b) -> gun
|
|
1087
|
+
(gun/*, foo/*) -> parent/gun/a, parent/gun/b
|
|
1088
|
+
/foo/bar -> (bar, /foo/bar) -> parent/bar
|
|
1089
|
+
(gun, /foo/bar) -> parent/gun
|
|
1090
|
+
(fun/*/gun/*, sun/foo/bar) -> parent/fun/foo/gun/bar
|
|
1091
|
+
|
|
1092
|
+
Examples
|
|
1093
|
+
--------
|
|
1094
|
+
For example suppose the source directory contains fun/foo.dat and
|
|
1095
|
+
fun/bar/car.dat:
|
|
1096
|
+
|
|
1097
|
+
>>> self.add_data_dir('fun') #doctest: +SKIP
|
|
1098
|
+
>>> self.add_data_dir(('sun', 'fun')) #doctest: +SKIP
|
|
1099
|
+
>>> self.add_data_dir(('gun', '/full/path/to/fun'))#doctest: +SKIP
|
|
1100
|
+
|
|
1101
|
+
Will install data-files to the locations::
|
|
1102
|
+
|
|
1103
|
+
<package install directory>/
|
|
1104
|
+
fun/
|
|
1105
|
+
foo.dat
|
|
1106
|
+
bar/
|
|
1107
|
+
car.dat
|
|
1108
|
+
sun/
|
|
1109
|
+
foo.dat
|
|
1110
|
+
bar/
|
|
1111
|
+
car.dat
|
|
1112
|
+
gun/
|
|
1113
|
+
foo.dat
|
|
1114
|
+
car.dat
|
|
1115
|
+
|
|
1116
|
+
"""
|
|
1117
|
+
if is_sequence(data_path):
|
|
1118
|
+
d, data_path = data_path
|
|
1119
|
+
else:
|
|
1120
|
+
d = None
|
|
1121
|
+
if is_sequence(data_path):
|
|
1122
|
+
[self.add_data_dir((d, p)) for p in data_path]
|
|
1123
|
+
return
|
|
1124
|
+
if not is_string(data_path):
|
|
1125
|
+
raise TypeError("not a string: %r" % (data_path,))
|
|
1126
|
+
if d is None:
|
|
1127
|
+
if os.path.isabs(data_path):
|
|
1128
|
+
return self.add_data_dir((os.path.basename(data_path), data_path))
|
|
1129
|
+
return self.add_data_dir((data_path, data_path))
|
|
1130
|
+
paths = self.paths(data_path, include_non_existing=False)
|
|
1131
|
+
if is_glob_pattern(data_path):
|
|
1132
|
+
if is_glob_pattern(d):
|
|
1133
|
+
pattern_list = allpath(d).split(os.sep)
|
|
1134
|
+
pattern_list.reverse()
|
|
1135
|
+
# /a/*//b/ -> /a/*/b
|
|
1136
|
+
rl = list(range(len(pattern_list)-1)); rl.reverse()
|
|
1137
|
+
for i in rl:
|
|
1138
|
+
if not pattern_list[i]:
|
|
1139
|
+
del pattern_list[i]
|
|
1140
|
+
#
|
|
1141
|
+
for path in paths:
|
|
1142
|
+
if not os.path.isdir(path):
|
|
1143
|
+
print('Not a directory, skipping', path)
|
|
1144
|
+
continue
|
|
1145
|
+
rpath = rel_path(path, self.local_path)
|
|
1146
|
+
path_list = rpath.split(os.sep)
|
|
1147
|
+
path_list.reverse()
|
|
1148
|
+
target_list = []
|
|
1149
|
+
i = 0
|
|
1150
|
+
for s in pattern_list:
|
|
1151
|
+
if is_glob_pattern(s):
|
|
1152
|
+
if i>=len(path_list):
|
|
1153
|
+
raise ValueError('cannot fill pattern %r with %r' \
|
|
1154
|
+
% (d, path))
|
|
1155
|
+
target_list.append(path_list[i])
|
|
1156
|
+
else:
|
|
1157
|
+
assert s==path_list[i], repr((s, path_list[i], data_path, d, path, rpath))
|
|
1158
|
+
target_list.append(s)
|
|
1159
|
+
i += 1
|
|
1160
|
+
if path_list[i:]:
|
|
1161
|
+
self.warn('mismatch of pattern_list=%s and path_list=%s'\
|
|
1162
|
+
% (pattern_list, path_list))
|
|
1163
|
+
target_list.reverse()
|
|
1164
|
+
self.add_data_dir((os.sep.join(target_list), path))
|
|
1165
|
+
else:
|
|
1166
|
+
for path in paths:
|
|
1167
|
+
self.add_data_dir((d, path))
|
|
1168
|
+
return
|
|
1169
|
+
assert not is_glob_pattern(d), repr(d)
|
|
1170
|
+
|
|
1171
|
+
dist = self.get_distribution()
|
|
1172
|
+
if dist is not None and dist.data_files is not None:
|
|
1173
|
+
data_files = dist.data_files
|
|
1174
|
+
else:
|
|
1175
|
+
data_files = self.data_files
|
|
1176
|
+
|
|
1177
|
+
for path in paths:
|
|
1178
|
+
for d1, f in list(general_source_directories_files(path)):
|
|
1179
|
+
target_path = os.path.join(self.path_in_package, d, d1)
|
|
1180
|
+
data_files.append((target_path, f))
|
|
1181
|
+
|
|
1182
|
+
def _optimize_data_files(self):
|
|
1183
|
+
data_dict = {}
|
|
1184
|
+
for p, files in self.data_files:
|
|
1185
|
+
if p not in data_dict:
|
|
1186
|
+
data_dict[p] = set()
|
|
1187
|
+
for f in files:
|
|
1188
|
+
data_dict[p].add(f)
|
|
1189
|
+
self.data_files[:] = [(p, list(files)) for p, files in data_dict.items()]
|
|
1190
|
+
|
|
1191
|
+
def add_data_files(self,*files):
|
|
1192
|
+
"""Add data files to configuration data_files.
|
|
1193
|
+
|
|
1194
|
+
Parameters
|
|
1195
|
+
----------
|
|
1196
|
+
files : sequence
|
|
1197
|
+
Argument(s) can be either
|
|
1198
|
+
|
|
1199
|
+
* 2-sequence (<datadir prefix>,<path to data file(s)>)
|
|
1200
|
+
* paths to data files where python datadir prefix defaults
|
|
1201
|
+
to package dir.
|
|
1202
|
+
|
|
1203
|
+
Notes
|
|
1204
|
+
-----
|
|
1205
|
+
The form of each element of the files sequence is very flexible
|
|
1206
|
+
allowing many combinations of where to get the files from the package
|
|
1207
|
+
and where they should ultimately be installed on the system. The most
|
|
1208
|
+
basic usage is for an element of the files argument sequence to be a
|
|
1209
|
+
simple filename. This will cause that file from the local path to be
|
|
1210
|
+
installed to the installation path of the self.name package (package
|
|
1211
|
+
path). The file argument can also be a relative path in which case the
|
|
1212
|
+
entire relative path will be installed into the package directory.
|
|
1213
|
+
Finally, the file can be an absolute path name in which case the file
|
|
1214
|
+
will be found at the absolute path name but installed to the package
|
|
1215
|
+
path.
|
|
1216
|
+
|
|
1217
|
+
This basic behavior can be augmented by passing a 2-tuple in as the
|
|
1218
|
+
file argument. The first element of the tuple should specify the
|
|
1219
|
+
relative path (under the package install directory) where the
|
|
1220
|
+
remaining sequence of files should be installed to (it has nothing to
|
|
1221
|
+
do with the file-names in the source distribution). The second element
|
|
1222
|
+
of the tuple is the sequence of files that should be installed. The
|
|
1223
|
+
files in this sequence can be filenames, relative paths, or absolute
|
|
1224
|
+
paths. For absolute paths the file will be installed in the top-level
|
|
1225
|
+
package installation directory (regardless of the first argument).
|
|
1226
|
+
Filenames and relative path names will be installed in the package
|
|
1227
|
+
install directory under the path name given as the first element of
|
|
1228
|
+
the tuple.
|
|
1229
|
+
|
|
1230
|
+
Rules for installation paths:
|
|
1231
|
+
|
|
1232
|
+
#. file.txt -> (., file.txt)-> parent/file.txt
|
|
1233
|
+
#. foo/file.txt -> (foo, foo/file.txt) -> parent/foo/file.txt
|
|
1234
|
+
#. /foo/bar/file.txt -> (., /foo/bar/file.txt) -> parent/file.txt
|
|
1235
|
+
#. ``*``.txt -> parent/a.txt, parent/b.txt
|
|
1236
|
+
#. foo/``*``.txt`` -> parent/foo/a.txt, parent/foo/b.txt
|
|
1237
|
+
#. ``*/*.txt`` -> (``*``, ``*``/``*``.txt) -> parent/c/a.txt, parent/d/b.txt
|
|
1238
|
+
#. (sun, file.txt) -> parent/sun/file.txt
|
|
1239
|
+
#. (sun, bar/file.txt) -> parent/sun/file.txt
|
|
1240
|
+
#. (sun, /foo/bar/file.txt) -> parent/sun/file.txt
|
|
1241
|
+
#. (sun, ``*``.txt) -> parent/sun/a.txt, parent/sun/b.txt
|
|
1242
|
+
#. (sun, bar/``*``.txt) -> parent/sun/a.txt, parent/sun/b.txt
|
|
1243
|
+
#. (sun/``*``, ``*``/``*``.txt) -> parent/sun/c/a.txt, parent/d/b.txt
|
|
1244
|
+
|
|
1245
|
+
An additional feature is that the path to a data-file can actually be
|
|
1246
|
+
a function that takes no arguments and returns the actual path(s) to
|
|
1247
|
+
the data-files. This is useful when the data files are generated while
|
|
1248
|
+
building the package.
|
|
1249
|
+
|
|
1250
|
+
Examples
|
|
1251
|
+
--------
|
|
1252
|
+
Add files to the list of data_files to be included with the package.
|
|
1253
|
+
|
|
1254
|
+
>>> self.add_data_files('foo.dat',
|
|
1255
|
+
... ('fun', ['gun.dat', 'nun/pun.dat', '/tmp/sun.dat']),
|
|
1256
|
+
... 'bar/cat.dat',
|
|
1257
|
+
... '/full/path/to/can.dat') #doctest: +SKIP
|
|
1258
|
+
|
|
1259
|
+
will install these data files to::
|
|
1260
|
+
|
|
1261
|
+
<package install directory>/
|
|
1262
|
+
foo.dat
|
|
1263
|
+
fun/
|
|
1264
|
+
gun.dat
|
|
1265
|
+
nun/
|
|
1266
|
+
pun.dat
|
|
1267
|
+
sun.dat
|
|
1268
|
+
bar/
|
|
1269
|
+
car.dat
|
|
1270
|
+
can.dat
|
|
1271
|
+
|
|
1272
|
+
where <package install directory> is the package (or sub-package)
|
|
1273
|
+
directory such as '/usr/lib/python2.4/site-packages/mypackage' ('C:
|
|
1274
|
+
\\Python2.4 \\Lib \\site-packages \\mypackage') or
|
|
1275
|
+
'/usr/lib/python2.4/site- packages/mypackage/mysubpackage' ('C:
|
|
1276
|
+
\\Python2.4 \\Lib \\site-packages \\mypackage \\mysubpackage').
|
|
1277
|
+
"""
|
|
1278
|
+
|
|
1279
|
+
if len(files)>1:
|
|
1280
|
+
for f in files:
|
|
1281
|
+
self.add_data_files(f)
|
|
1282
|
+
return
|
|
1283
|
+
assert len(files)==1
|
|
1284
|
+
if is_sequence(files[0]):
|
|
1285
|
+
d, files = files[0]
|
|
1286
|
+
else:
|
|
1287
|
+
d = None
|
|
1288
|
+
if is_string(files):
|
|
1289
|
+
filepat = files
|
|
1290
|
+
elif is_sequence(files):
|
|
1291
|
+
if len(files)==1:
|
|
1292
|
+
filepat = files[0]
|
|
1293
|
+
else:
|
|
1294
|
+
for f in files:
|
|
1295
|
+
self.add_data_files((d, f))
|
|
1296
|
+
return
|
|
1297
|
+
else:
|
|
1298
|
+
raise TypeError(repr(type(files)))
|
|
1299
|
+
|
|
1300
|
+
if d is None:
|
|
1301
|
+
if hasattr(filepat, '__call__'):
|
|
1302
|
+
d = ''
|
|
1303
|
+
elif os.path.isabs(filepat):
|
|
1304
|
+
d = ''
|
|
1305
|
+
else:
|
|
1306
|
+
d = os.path.dirname(filepat)
|
|
1307
|
+
self.add_data_files((d, files))
|
|
1308
|
+
return
|
|
1309
|
+
|
|
1310
|
+
paths = self.paths(filepat, include_non_existing=False)
|
|
1311
|
+
if is_glob_pattern(filepat):
|
|
1312
|
+
if is_glob_pattern(d):
|
|
1313
|
+
pattern_list = d.split(os.sep)
|
|
1314
|
+
pattern_list.reverse()
|
|
1315
|
+
for path in paths:
|
|
1316
|
+
path_list = path.split(os.sep)
|
|
1317
|
+
path_list.reverse()
|
|
1318
|
+
path_list.pop() # filename
|
|
1319
|
+
target_list = []
|
|
1320
|
+
i = 0
|
|
1321
|
+
for s in pattern_list:
|
|
1322
|
+
if is_glob_pattern(s):
|
|
1323
|
+
target_list.append(path_list[i])
|
|
1324
|
+
i += 1
|
|
1325
|
+
else:
|
|
1326
|
+
target_list.append(s)
|
|
1327
|
+
target_list.reverse()
|
|
1328
|
+
self.add_data_files((os.sep.join(target_list), path))
|
|
1329
|
+
else:
|
|
1330
|
+
self.add_data_files((d, paths))
|
|
1331
|
+
return
|
|
1332
|
+
assert not is_glob_pattern(d), repr((d, filepat))
|
|
1333
|
+
|
|
1334
|
+
dist = self.get_distribution()
|
|
1335
|
+
if dist is not None and dist.data_files is not None:
|
|
1336
|
+
data_files = dist.data_files
|
|
1337
|
+
else:
|
|
1338
|
+
data_files = self.data_files
|
|
1339
|
+
|
|
1340
|
+
data_files.append((os.path.join(self.path_in_package, d), paths))
|
|
1341
|
+
|
|
1342
|
+
### XXX Implement add_py_modules
|
|
1343
|
+
|
|
1344
|
+
def add_define_macros(self, macros):
|
|
1345
|
+
"""Add define macros to configuration
|
|
1346
|
+
|
|
1347
|
+
Add the given sequence of macro name and value duples to the beginning
|
|
1348
|
+
of the define_macros list This list will be visible to all extension
|
|
1349
|
+
modules of the current package.
|
|
1350
|
+
"""
|
|
1351
|
+
dist = self.get_distribution()
|
|
1352
|
+
if dist is not None:
|
|
1353
|
+
if not hasattr(dist, 'define_macros'):
|
|
1354
|
+
dist.define_macros = []
|
|
1355
|
+
dist.define_macros.extend(macros)
|
|
1356
|
+
else:
|
|
1357
|
+
self.define_macros.extend(macros)
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
def add_include_dirs(self,*paths):
|
|
1361
|
+
"""Add paths to configuration include directories.
|
|
1362
|
+
|
|
1363
|
+
Add the given sequence of paths to the beginning of the include_dirs
|
|
1364
|
+
list. This list will be visible to all extension modules of the
|
|
1365
|
+
current package.
|
|
1366
|
+
"""
|
|
1367
|
+
include_dirs = self.paths(paths)
|
|
1368
|
+
dist = self.get_distribution()
|
|
1369
|
+
if dist is not None:
|
|
1370
|
+
if dist.include_dirs is None:
|
|
1371
|
+
dist.include_dirs = []
|
|
1372
|
+
dist.include_dirs.extend(include_dirs)
|
|
1373
|
+
else:
|
|
1374
|
+
self.include_dirs.extend(include_dirs)
|
|
1375
|
+
|
|
1376
|
+
def add_headers(self,*files):
|
|
1377
|
+
"""Add installable headers to configuration.
|
|
1378
|
+
|
|
1379
|
+
Add the given sequence of files to the beginning of the headers list.
|
|
1380
|
+
By default, headers will be installed under <python-
|
|
1381
|
+
include>/<self.name.replace('.','/')>/ directory. If an item of files
|
|
1382
|
+
is a tuple, then its first argument specifies the actual installation
|
|
1383
|
+
location relative to the <python-include> path.
|
|
1384
|
+
|
|
1385
|
+
Parameters
|
|
1386
|
+
----------
|
|
1387
|
+
files : str or seq
|
|
1388
|
+
Argument(s) can be either:
|
|
1389
|
+
|
|
1390
|
+
* 2-sequence (<includedir suffix>,<path to header file(s)>)
|
|
1391
|
+
* path(s) to header file(s) where python includedir suffix will
|
|
1392
|
+
default to package name.
|
|
1393
|
+
"""
|
|
1394
|
+
headers = []
|
|
1395
|
+
for path in files:
|
|
1396
|
+
if is_string(path):
|
|
1397
|
+
[headers.append((self.name, p)) for p in self.paths(path)]
|
|
1398
|
+
else:
|
|
1399
|
+
if not isinstance(path, (tuple, list)) or len(path) != 2:
|
|
1400
|
+
raise TypeError(repr(path))
|
|
1401
|
+
[headers.append((path[0], p)) for p in self.paths(path[1])]
|
|
1402
|
+
dist = self.get_distribution()
|
|
1403
|
+
if dist is not None:
|
|
1404
|
+
if dist.headers is None:
|
|
1405
|
+
dist.headers = []
|
|
1406
|
+
dist.headers.extend(headers)
|
|
1407
|
+
else:
|
|
1408
|
+
self.headers.extend(headers)
|
|
1409
|
+
|
|
1410
|
+
def paths(self,*paths,**kws):
|
|
1411
|
+
"""Apply glob to paths and prepend local_path if needed.
|
|
1412
|
+
|
|
1413
|
+
Applies glob.glob(...) to each path in the sequence (if needed) and
|
|
1414
|
+
prepends the local_path if needed. Because this is called on all
|
|
1415
|
+
source lists, this allows wildcard characters to be specified in lists
|
|
1416
|
+
of sources for extension modules and libraries and scripts and allows
|
|
1417
|
+
path-names be relative to the source directory.
|
|
1418
|
+
|
|
1419
|
+
"""
|
|
1420
|
+
include_non_existing = kws.get('include_non_existing', True)
|
|
1421
|
+
return gpaths(paths,
|
|
1422
|
+
local_path = self.local_path,
|
|
1423
|
+
include_non_existing=include_non_existing)
|
|
1424
|
+
|
|
1425
|
+
def _fix_paths_dict(self, kw):
|
|
1426
|
+
for k in kw.keys():
|
|
1427
|
+
v = kw[k]
|
|
1428
|
+
if k in ['sources', 'depends', 'include_dirs', 'library_dirs',
|
|
1429
|
+
'module_dirs', 'extra_objects']:
|
|
1430
|
+
new_v = self.paths(v)
|
|
1431
|
+
kw[k] = new_v
|
|
1432
|
+
|
|
1433
|
+
def add_extension(self,name,sources,**kw):
|
|
1434
|
+
"""Add extension to configuration.
|
|
1435
|
+
|
|
1436
|
+
Create and add an Extension instance to the ext_modules list. This
|
|
1437
|
+
method also takes the following optional keyword arguments that are
|
|
1438
|
+
passed on to the Extension constructor.
|
|
1439
|
+
|
|
1440
|
+
Parameters
|
|
1441
|
+
----------
|
|
1442
|
+
name : str
|
|
1443
|
+
name of the extension
|
|
1444
|
+
sources : seq
|
|
1445
|
+
list of the sources. The list of sources may contain functions
|
|
1446
|
+
(called source generators) which must take an extension instance
|
|
1447
|
+
and a build directory as inputs and return a source file or list of
|
|
1448
|
+
source files or None. If None is returned then no sources are
|
|
1449
|
+
generated. If the Extension instance has no sources after
|
|
1450
|
+
processing all source generators, then no extension module is
|
|
1451
|
+
built.
|
|
1452
|
+
include_dirs :
|
|
1453
|
+
define_macros :
|
|
1454
|
+
undef_macros :
|
|
1455
|
+
library_dirs :
|
|
1456
|
+
libraries :
|
|
1457
|
+
runtime_library_dirs :
|
|
1458
|
+
extra_objects :
|
|
1459
|
+
extra_compile_args :
|
|
1460
|
+
extra_link_args :
|
|
1461
|
+
extra_f77_compile_args :
|
|
1462
|
+
extra_f90_compile_args :
|
|
1463
|
+
export_symbols :
|
|
1464
|
+
swig_opts :
|
|
1465
|
+
depends :
|
|
1466
|
+
The depends list contains paths to files or directories that the
|
|
1467
|
+
sources of the extension module depend on. If any path in the
|
|
1468
|
+
depends list is newer than the extension module, then the module
|
|
1469
|
+
will be rebuilt.
|
|
1470
|
+
language :
|
|
1471
|
+
f2py_options :
|
|
1472
|
+
module_dirs :
|
|
1473
|
+
extra_info : dict or list
|
|
1474
|
+
dict or list of dict of keywords to be appended to keywords.
|
|
1475
|
+
|
|
1476
|
+
Notes
|
|
1477
|
+
-----
|
|
1478
|
+
The self.paths(...) method is applied to all lists that may contain
|
|
1479
|
+
paths.
|
|
1480
|
+
"""
|
|
1481
|
+
ext_args = copy.copy(kw)
|
|
1482
|
+
ext_args['name'] = dot_join(self.name, name)
|
|
1483
|
+
ext_args['sources'] = sources
|
|
1484
|
+
|
|
1485
|
+
if 'extra_info' in ext_args:
|
|
1486
|
+
extra_info = ext_args['extra_info']
|
|
1487
|
+
del ext_args['extra_info']
|
|
1488
|
+
if isinstance(extra_info, dict):
|
|
1489
|
+
extra_info = [extra_info]
|
|
1490
|
+
for info in extra_info:
|
|
1491
|
+
assert isinstance(info, dict), repr(info)
|
|
1492
|
+
dict_append(ext_args,**info)
|
|
1493
|
+
|
|
1494
|
+
self._fix_paths_dict(ext_args)
|
|
1495
|
+
|
|
1496
|
+
# Resolve out-of-tree dependencies
|
|
1497
|
+
libraries = ext_args.get('libraries', [])
|
|
1498
|
+
libnames = []
|
|
1499
|
+
ext_args['libraries'] = []
|
|
1500
|
+
for libname in libraries:
|
|
1501
|
+
if isinstance(libname, tuple):
|
|
1502
|
+
self._fix_paths_dict(libname[1])
|
|
1503
|
+
|
|
1504
|
+
# Handle library names of the form libname@relative/path/to/library
|
|
1505
|
+
if '@' in libname:
|
|
1506
|
+
lname, lpath = libname.split('@', 1)
|
|
1507
|
+
lpath = os.path.abspath(njoin(self.local_path, lpath))
|
|
1508
|
+
if os.path.isdir(lpath):
|
|
1509
|
+
c = self.get_subpackage(None, lpath,
|
|
1510
|
+
caller_level = 2)
|
|
1511
|
+
if isinstance(c, Configuration):
|
|
1512
|
+
c = c.todict()
|
|
1513
|
+
for l in [l[0] for l in c.get('libraries', [])]:
|
|
1514
|
+
llname = l.split('__OF__', 1)[0]
|
|
1515
|
+
if llname == lname:
|
|
1516
|
+
c.pop('name', None)
|
|
1517
|
+
dict_append(ext_args,**c)
|
|
1518
|
+
break
|
|
1519
|
+
continue
|
|
1520
|
+
libnames.append(libname)
|
|
1521
|
+
|
|
1522
|
+
ext_args['libraries'] = libnames + ext_args['libraries']
|
|
1523
|
+
ext_args['define_macros'] = \
|
|
1524
|
+
self.define_macros + ext_args.get('define_macros', [])
|
|
1525
|
+
|
|
1526
|
+
from numpy.distutils.core import Extension
|
|
1527
|
+
ext = Extension(**ext_args)
|
|
1528
|
+
self.ext_modules.append(ext)
|
|
1529
|
+
|
|
1530
|
+
dist = self.get_distribution()
|
|
1531
|
+
if dist is not None:
|
|
1532
|
+
self.warn('distutils distribution has been initialized,'\
|
|
1533
|
+
' it may be too late to add an extension '+name)
|
|
1534
|
+
return ext
|
|
1535
|
+
|
|
1536
|
+
def add_library(self,name,sources,**build_info):
|
|
1537
|
+
"""
|
|
1538
|
+
Add library to configuration.
|
|
1539
|
+
|
|
1540
|
+
Parameters
|
|
1541
|
+
----------
|
|
1542
|
+
name : str
|
|
1543
|
+
Name of the extension.
|
|
1544
|
+
sources : sequence
|
|
1545
|
+
List of the sources. The list of sources may contain functions
|
|
1546
|
+
(called source generators) which must take an extension instance
|
|
1547
|
+
and a build directory as inputs and return a source file or list of
|
|
1548
|
+
source files or None. If None is returned then no sources are
|
|
1549
|
+
generated. If the Extension instance has no sources after
|
|
1550
|
+
processing all source generators, then no extension module is
|
|
1551
|
+
built.
|
|
1552
|
+
build_info : dict, optional
|
|
1553
|
+
The following keys are allowed:
|
|
1554
|
+
|
|
1555
|
+
* depends
|
|
1556
|
+
* macros
|
|
1557
|
+
* include_dirs
|
|
1558
|
+
* extra_compiler_args
|
|
1559
|
+
* extra_f77_compile_args
|
|
1560
|
+
* extra_f90_compile_args
|
|
1561
|
+
* f2py_options
|
|
1562
|
+
* language
|
|
1563
|
+
|
|
1564
|
+
"""
|
|
1565
|
+
self._add_library(name, sources, None, build_info)
|
|
1566
|
+
|
|
1567
|
+
dist = self.get_distribution()
|
|
1568
|
+
if dist is not None:
|
|
1569
|
+
self.warn('distutils distribution has been initialized,'\
|
|
1570
|
+
' it may be too late to add a library '+ name)
|
|
1571
|
+
|
|
1572
|
+
def _add_library(self, name, sources, install_dir, build_info):
|
|
1573
|
+
"""Common implementation for add_library and add_installed_library. Do
|
|
1574
|
+
not use directly"""
|
|
1575
|
+
build_info = copy.copy(build_info)
|
|
1576
|
+
build_info['sources'] = sources
|
|
1577
|
+
|
|
1578
|
+
# Sometimes, depends is not set up to an empty list by default, and if
|
|
1579
|
+
# depends is not given to add_library, distutils barfs (#1134)
|
|
1580
|
+
if not 'depends' in build_info:
|
|
1581
|
+
build_info['depends'] = []
|
|
1582
|
+
|
|
1583
|
+
self._fix_paths_dict(build_info)
|
|
1584
|
+
|
|
1585
|
+
# Add to libraries list so that it is build with build_clib
|
|
1586
|
+
self.libraries.append((name, build_info))
|
|
1587
|
+
|
|
1588
|
+
def add_installed_library(self, name, sources, install_dir, build_info=None):
|
|
1589
|
+
"""
|
|
1590
|
+
Similar to add_library, but the specified library is installed.
|
|
1591
|
+
|
|
1592
|
+
Most C libraries used with ``distutils`` are only used to build python
|
|
1593
|
+
extensions, but libraries built through this method will be installed
|
|
1594
|
+
so that they can be reused by third-party packages.
|
|
1595
|
+
|
|
1596
|
+
Parameters
|
|
1597
|
+
----------
|
|
1598
|
+
name : str
|
|
1599
|
+
Name of the installed library.
|
|
1600
|
+
sources : sequence
|
|
1601
|
+
List of the library's source files. See `add_library` for details.
|
|
1602
|
+
install_dir : str
|
|
1603
|
+
Path to install the library, relative to the current sub-package.
|
|
1604
|
+
build_info : dict, optional
|
|
1605
|
+
The following keys are allowed:
|
|
1606
|
+
|
|
1607
|
+
* depends
|
|
1608
|
+
* macros
|
|
1609
|
+
* include_dirs
|
|
1610
|
+
* extra_compiler_args
|
|
1611
|
+
* extra_f77_compile_args
|
|
1612
|
+
* extra_f90_compile_args
|
|
1613
|
+
* f2py_options
|
|
1614
|
+
* language
|
|
1615
|
+
|
|
1616
|
+
Returns
|
|
1617
|
+
-------
|
|
1618
|
+
None
|
|
1619
|
+
|
|
1620
|
+
See Also
|
|
1621
|
+
--------
|
|
1622
|
+
add_library, add_npy_pkg_config, get_info
|
|
1623
|
+
|
|
1624
|
+
Notes
|
|
1625
|
+
-----
|
|
1626
|
+
The best way to encode the options required to link against the specified
|
|
1627
|
+
C libraries is to use a "libname.ini" file, and use `get_info` to
|
|
1628
|
+
retrieve the required options (see `add_npy_pkg_config` for more
|
|
1629
|
+
information).
|
|
1630
|
+
|
|
1631
|
+
"""
|
|
1632
|
+
if not build_info:
|
|
1633
|
+
build_info = {}
|
|
1634
|
+
|
|
1635
|
+
install_dir = os.path.join(self.package_path, install_dir)
|
|
1636
|
+
self._add_library(name, sources, install_dir, build_info)
|
|
1637
|
+
self.installed_libraries.append(InstallableLib(name, build_info, install_dir))
|
|
1638
|
+
|
|
1639
|
+
def add_npy_pkg_config(self, template, install_dir, subst_dict=None):
|
|
1640
|
+
"""
|
|
1641
|
+
Generate and install a npy-pkg config file from a template.
|
|
1642
|
+
|
|
1643
|
+
The config file generated from `template` is installed in the
|
|
1644
|
+
given install directory, using `subst_dict` for variable substitution.
|
|
1645
|
+
|
|
1646
|
+
Parameters
|
|
1647
|
+
----------
|
|
1648
|
+
template : str
|
|
1649
|
+
The path of the template, relatively to the current package path.
|
|
1650
|
+
install_dir : str
|
|
1651
|
+
Where to install the npy-pkg config file, relatively to the current
|
|
1652
|
+
package path.
|
|
1653
|
+
subst_dict : dict, optional
|
|
1654
|
+
If given, any string of the form ``@key@`` will be replaced by
|
|
1655
|
+
``subst_dict[key]`` in the template file when installed. The install
|
|
1656
|
+
prefix is always available through the variable ``@prefix@``, since the
|
|
1657
|
+
install prefix is not easy to get reliably from setup.py.
|
|
1658
|
+
|
|
1659
|
+
See also
|
|
1660
|
+
--------
|
|
1661
|
+
add_installed_library, get_info
|
|
1662
|
+
|
|
1663
|
+
Notes
|
|
1664
|
+
-----
|
|
1665
|
+
This works for both standard installs and in-place builds, i.e. the
|
|
1666
|
+
``@prefix@`` refer to the source directory for in-place builds.
|
|
1667
|
+
|
|
1668
|
+
Examples
|
|
1669
|
+
--------
|
|
1670
|
+
::
|
|
1671
|
+
|
|
1672
|
+
config.add_npy_pkg_config('foo.ini.in', 'lib', {'foo': bar})
|
|
1673
|
+
|
|
1674
|
+
Assuming the foo.ini.in file has the following content::
|
|
1675
|
+
|
|
1676
|
+
[meta]
|
|
1677
|
+
Name=@foo@
|
|
1678
|
+
Version=1.0
|
|
1679
|
+
Description=dummy description
|
|
1680
|
+
|
|
1681
|
+
[default]
|
|
1682
|
+
Cflags=-I@prefix@/include
|
|
1683
|
+
Libs=
|
|
1684
|
+
|
|
1685
|
+
The generated file will have the following content::
|
|
1686
|
+
|
|
1687
|
+
[meta]
|
|
1688
|
+
Name=bar
|
|
1689
|
+
Version=1.0
|
|
1690
|
+
Description=dummy description
|
|
1691
|
+
|
|
1692
|
+
[default]
|
|
1693
|
+
Cflags=-Iprefix_dir/include
|
|
1694
|
+
Libs=
|
|
1695
|
+
|
|
1696
|
+
and will be installed as foo.ini in the 'lib' subpath.
|
|
1697
|
+
|
|
1698
|
+
When cross-compiling with numpy distutils, it might be necessary to
|
|
1699
|
+
use modified npy-pkg-config files. Using the default/generated files
|
|
1700
|
+
will link with the host libraries (i.e. libnpymath.a). For
|
|
1701
|
+
cross-compilation you of-course need to link with target libraries,
|
|
1702
|
+
while using the host Python installation.
|
|
1703
|
+
|
|
1704
|
+
You can copy out the numpy/_core/lib/npy-pkg-config directory, add a
|
|
1705
|
+
pkgdir value to the .ini files and set NPY_PKG_CONFIG_PATH environment
|
|
1706
|
+
variable to point to the directory with the modified npy-pkg-config
|
|
1707
|
+
files.
|
|
1708
|
+
|
|
1709
|
+
Example npymath.ini modified for cross-compilation::
|
|
1710
|
+
|
|
1711
|
+
[meta]
|
|
1712
|
+
Name=npymath
|
|
1713
|
+
Description=Portable, core math library implementing C99 standard
|
|
1714
|
+
Version=0.1
|
|
1715
|
+
|
|
1716
|
+
[variables]
|
|
1717
|
+
pkgname=numpy._core
|
|
1718
|
+
pkgdir=/build/arm-linux-gnueabi/sysroot/usr/lib/python3.7/site-packages/numpy/_core
|
|
1719
|
+
prefix=${pkgdir}
|
|
1720
|
+
libdir=${prefix}/lib
|
|
1721
|
+
includedir=${prefix}/include
|
|
1722
|
+
|
|
1723
|
+
[default]
|
|
1724
|
+
Libs=-L${libdir} -lnpymath
|
|
1725
|
+
Cflags=-I${includedir}
|
|
1726
|
+
Requires=mlib
|
|
1727
|
+
|
|
1728
|
+
[msvc]
|
|
1729
|
+
Libs=/LIBPATH:${libdir} npymath.lib
|
|
1730
|
+
Cflags=/INCLUDE:${includedir}
|
|
1731
|
+
Requires=mlib
|
|
1732
|
+
|
|
1733
|
+
"""
|
|
1734
|
+
if subst_dict is None:
|
|
1735
|
+
subst_dict = {}
|
|
1736
|
+
template = os.path.join(self.package_path, template)
|
|
1737
|
+
|
|
1738
|
+
if self.name in self.installed_pkg_config:
|
|
1739
|
+
self.installed_pkg_config[self.name].append((template, install_dir,
|
|
1740
|
+
subst_dict))
|
|
1741
|
+
else:
|
|
1742
|
+
self.installed_pkg_config[self.name] = [(template, install_dir,
|
|
1743
|
+
subst_dict)]
|
|
1744
|
+
|
|
1745
|
+
|
|
1746
|
+
def add_scripts(self,*files):
|
|
1747
|
+
"""Add scripts to configuration.
|
|
1748
|
+
|
|
1749
|
+
Add the sequence of files to the beginning of the scripts list.
|
|
1750
|
+
Scripts will be installed under the <prefix>/bin/ directory.
|
|
1751
|
+
|
|
1752
|
+
"""
|
|
1753
|
+
scripts = self.paths(files)
|
|
1754
|
+
dist = self.get_distribution()
|
|
1755
|
+
if dist is not None:
|
|
1756
|
+
if dist.scripts is None:
|
|
1757
|
+
dist.scripts = []
|
|
1758
|
+
dist.scripts.extend(scripts)
|
|
1759
|
+
else:
|
|
1760
|
+
self.scripts.extend(scripts)
|
|
1761
|
+
|
|
1762
|
+
def dict_append(self,**dict):
|
|
1763
|
+
for key in self.list_keys:
|
|
1764
|
+
a = getattr(self, key)
|
|
1765
|
+
a.extend(dict.get(key, []))
|
|
1766
|
+
for key in self.dict_keys:
|
|
1767
|
+
a = getattr(self, key)
|
|
1768
|
+
a.update(dict.get(key, {}))
|
|
1769
|
+
known_keys = self.list_keys + self.dict_keys + self.extra_keys
|
|
1770
|
+
for key in dict.keys():
|
|
1771
|
+
if key not in known_keys:
|
|
1772
|
+
a = getattr(self, key, None)
|
|
1773
|
+
if a and a==dict[key]: continue
|
|
1774
|
+
self.warn('Inheriting attribute %r=%r from %r' \
|
|
1775
|
+
% (key, dict[key], dict.get('name', '?')))
|
|
1776
|
+
setattr(self, key, dict[key])
|
|
1777
|
+
self.extra_keys.append(key)
|
|
1778
|
+
elif key in self.extra_keys:
|
|
1779
|
+
self.info('Ignoring attempt to set %r (from %r to %r)' \
|
|
1780
|
+
% (key, getattr(self, key), dict[key]))
|
|
1781
|
+
elif key in known_keys:
|
|
1782
|
+
# key is already processed above
|
|
1783
|
+
pass
|
|
1784
|
+
else:
|
|
1785
|
+
raise ValueError("Don't know about key=%r" % (key))
|
|
1786
|
+
|
|
1787
|
+
def __str__(self):
|
|
1788
|
+
from pprint import pformat
|
|
1789
|
+
known_keys = self.list_keys + self.dict_keys + self.extra_keys
|
|
1790
|
+
s = '<'+5*'-' + '\n'
|
|
1791
|
+
s += 'Configuration of '+self.name+':\n'
|
|
1792
|
+
known_keys.sort()
|
|
1793
|
+
for k in known_keys:
|
|
1794
|
+
a = getattr(self, k, None)
|
|
1795
|
+
if a:
|
|
1796
|
+
s += '%s = %s\n' % (k, pformat(a))
|
|
1797
|
+
s += 5*'-' + '>'
|
|
1798
|
+
return s
|
|
1799
|
+
|
|
1800
|
+
def get_config_cmd(self):
|
|
1801
|
+
"""
|
|
1802
|
+
Returns the numpy.distutils config command instance.
|
|
1803
|
+
"""
|
|
1804
|
+
cmd = get_cmd('config')
|
|
1805
|
+
cmd.ensure_finalized()
|
|
1806
|
+
cmd.dump_source = 0
|
|
1807
|
+
cmd.noisy = 0
|
|
1808
|
+
old_path = os.environ.get('PATH')
|
|
1809
|
+
if old_path:
|
|
1810
|
+
path = os.pathsep.join(['.', old_path])
|
|
1811
|
+
os.environ['PATH'] = path
|
|
1812
|
+
return cmd
|
|
1813
|
+
|
|
1814
|
+
def get_build_temp_dir(self):
|
|
1815
|
+
"""
|
|
1816
|
+
Return a path to a temporary directory where temporary files should be
|
|
1817
|
+
placed.
|
|
1818
|
+
"""
|
|
1819
|
+
cmd = get_cmd('build')
|
|
1820
|
+
cmd.ensure_finalized()
|
|
1821
|
+
return cmd.build_temp
|
|
1822
|
+
|
|
1823
|
+
def have_f77c(self):
|
|
1824
|
+
"""Check for availability of Fortran 77 compiler.
|
|
1825
|
+
|
|
1826
|
+
Use it inside source generating function to ensure that
|
|
1827
|
+
setup distribution instance has been initialized.
|
|
1828
|
+
|
|
1829
|
+
Notes
|
|
1830
|
+
-----
|
|
1831
|
+
True if a Fortran 77 compiler is available (because a simple Fortran 77
|
|
1832
|
+
code was able to be compiled successfully).
|
|
1833
|
+
"""
|
|
1834
|
+
simple_fortran_subroutine = '''
|
|
1835
|
+
subroutine simple
|
|
1836
|
+
end
|
|
1837
|
+
'''
|
|
1838
|
+
config_cmd = self.get_config_cmd()
|
|
1839
|
+
flag = config_cmd.try_compile(simple_fortran_subroutine, lang='f77')
|
|
1840
|
+
return flag
|
|
1841
|
+
|
|
1842
|
+
def have_f90c(self):
|
|
1843
|
+
"""Check for availability of Fortran 90 compiler.
|
|
1844
|
+
|
|
1845
|
+
Use it inside source generating function to ensure that
|
|
1846
|
+
setup distribution instance has been initialized.
|
|
1847
|
+
|
|
1848
|
+
Notes
|
|
1849
|
+
-----
|
|
1850
|
+
True if a Fortran 90 compiler is available (because a simple Fortran
|
|
1851
|
+
90 code was able to be compiled successfully)
|
|
1852
|
+
"""
|
|
1853
|
+
simple_fortran_subroutine = '''
|
|
1854
|
+
subroutine simple
|
|
1855
|
+
end
|
|
1856
|
+
'''
|
|
1857
|
+
config_cmd = self.get_config_cmd()
|
|
1858
|
+
flag = config_cmd.try_compile(simple_fortran_subroutine, lang='f90')
|
|
1859
|
+
return flag
|
|
1860
|
+
|
|
1861
|
+
def append_to(self, extlib):
|
|
1862
|
+
"""Append libraries, include_dirs to extension or library item.
|
|
1863
|
+
"""
|
|
1864
|
+
if is_sequence(extlib):
|
|
1865
|
+
lib_name, build_info = extlib
|
|
1866
|
+
dict_append(build_info,
|
|
1867
|
+
libraries=self.libraries,
|
|
1868
|
+
include_dirs=self.include_dirs)
|
|
1869
|
+
else:
|
|
1870
|
+
from numpy.distutils.core import Extension
|
|
1871
|
+
assert isinstance(extlib, Extension), repr(extlib)
|
|
1872
|
+
extlib.libraries.extend(self.libraries)
|
|
1873
|
+
extlib.include_dirs.extend(self.include_dirs)
|
|
1874
|
+
|
|
1875
|
+
def _get_svn_revision(self, path):
|
|
1876
|
+
"""Return path's SVN revision number.
|
|
1877
|
+
"""
|
|
1878
|
+
try:
|
|
1879
|
+
output = subprocess.check_output(['svnversion'], cwd=path)
|
|
1880
|
+
except (subprocess.CalledProcessError, OSError):
|
|
1881
|
+
pass
|
|
1882
|
+
else:
|
|
1883
|
+
m = re.match(rb'(?P<revision>\d+)', output)
|
|
1884
|
+
if m:
|
|
1885
|
+
return int(m.group('revision'))
|
|
1886
|
+
|
|
1887
|
+
if sys.platform=='win32' and os.environ.get('SVN_ASP_DOT_NET_HACK', None):
|
|
1888
|
+
entries = njoin(path, '_svn', 'entries')
|
|
1889
|
+
else:
|
|
1890
|
+
entries = njoin(path, '.svn', 'entries')
|
|
1891
|
+
if os.path.isfile(entries):
|
|
1892
|
+
with open(entries) as f:
|
|
1893
|
+
fstr = f.read()
|
|
1894
|
+
if fstr[:5] == '<?xml': # pre 1.4
|
|
1895
|
+
m = re.search(r'revision="(?P<revision>\d+)"', fstr)
|
|
1896
|
+
if m:
|
|
1897
|
+
return int(m.group('revision'))
|
|
1898
|
+
else: # non-xml entries file --- check to be sure that
|
|
1899
|
+
m = re.search(r'dir[\n\r]+(?P<revision>\d+)', fstr)
|
|
1900
|
+
if m:
|
|
1901
|
+
return int(m.group('revision'))
|
|
1902
|
+
return None
|
|
1903
|
+
|
|
1904
|
+
def _get_hg_revision(self, path):
|
|
1905
|
+
"""Return path's Mercurial revision number.
|
|
1906
|
+
"""
|
|
1907
|
+
try:
|
|
1908
|
+
output = subprocess.check_output(
|
|
1909
|
+
['hg', 'identify', '--num'], cwd=path)
|
|
1910
|
+
except (subprocess.CalledProcessError, OSError):
|
|
1911
|
+
pass
|
|
1912
|
+
else:
|
|
1913
|
+
m = re.match(rb'(?P<revision>\d+)', output)
|
|
1914
|
+
if m:
|
|
1915
|
+
return int(m.group('revision'))
|
|
1916
|
+
|
|
1917
|
+
branch_fn = njoin(path, '.hg', 'branch')
|
|
1918
|
+
branch_cache_fn = njoin(path, '.hg', 'branch.cache')
|
|
1919
|
+
|
|
1920
|
+
if os.path.isfile(branch_fn):
|
|
1921
|
+
branch0 = None
|
|
1922
|
+
with open(branch_fn) as f:
|
|
1923
|
+
revision0 = f.read().strip()
|
|
1924
|
+
|
|
1925
|
+
branch_map = {}
|
|
1926
|
+
with open(branch_cache_fn) as f:
|
|
1927
|
+
for line in f:
|
|
1928
|
+
branch1, revision1 = line.split()[:2]
|
|
1929
|
+
if revision1==revision0:
|
|
1930
|
+
branch0 = branch1
|
|
1931
|
+
try:
|
|
1932
|
+
revision1 = int(revision1)
|
|
1933
|
+
except ValueError:
|
|
1934
|
+
continue
|
|
1935
|
+
branch_map[branch1] = revision1
|
|
1936
|
+
|
|
1937
|
+
return branch_map.get(branch0)
|
|
1938
|
+
|
|
1939
|
+
return None
|
|
1940
|
+
|
|
1941
|
+
|
|
1942
|
+
def get_version(self, version_file=None, version_variable=None):
|
|
1943
|
+
"""Try to get version string of a package.
|
|
1944
|
+
|
|
1945
|
+
Return a version string of the current package or None if the version
|
|
1946
|
+
information could not be detected.
|
|
1947
|
+
|
|
1948
|
+
Notes
|
|
1949
|
+
-----
|
|
1950
|
+
This method scans files named
|
|
1951
|
+
__version__.py, <packagename>_version.py, version.py, and
|
|
1952
|
+
__svn_version__.py for string variables version, __version__, and
|
|
1953
|
+
<packagename>_version, until a version number is found.
|
|
1954
|
+
"""
|
|
1955
|
+
version = getattr(self, 'version', None)
|
|
1956
|
+
if version is not None:
|
|
1957
|
+
return version
|
|
1958
|
+
|
|
1959
|
+
# Get version from version file.
|
|
1960
|
+
if version_file is None:
|
|
1961
|
+
files = ['__version__.py',
|
|
1962
|
+
self.name.split('.')[-1]+'_version.py',
|
|
1963
|
+
'version.py',
|
|
1964
|
+
'__svn_version__.py',
|
|
1965
|
+
'__hg_version__.py']
|
|
1966
|
+
else:
|
|
1967
|
+
files = [version_file]
|
|
1968
|
+
if version_variable is None:
|
|
1969
|
+
version_vars = ['version',
|
|
1970
|
+
'__version__',
|
|
1971
|
+
self.name.split('.')[-1]+'_version']
|
|
1972
|
+
else:
|
|
1973
|
+
version_vars = [version_variable]
|
|
1974
|
+
for f in files:
|
|
1975
|
+
fn = njoin(self.local_path, f)
|
|
1976
|
+
if os.path.isfile(fn):
|
|
1977
|
+
info = ('.py', 'U', 1)
|
|
1978
|
+
name = os.path.splitext(os.path.basename(fn))[0]
|
|
1979
|
+
n = dot_join(self.name, name)
|
|
1980
|
+
try:
|
|
1981
|
+
version_module = exec_mod_from_location(
|
|
1982
|
+
'_'.join(n.split('.')), fn)
|
|
1983
|
+
except ImportError as e:
|
|
1984
|
+
self.warn(str(e))
|
|
1985
|
+
version_module = None
|
|
1986
|
+
if version_module is None:
|
|
1987
|
+
continue
|
|
1988
|
+
|
|
1989
|
+
for a in version_vars:
|
|
1990
|
+
version = getattr(version_module, a, None)
|
|
1991
|
+
if version is not None:
|
|
1992
|
+
break
|
|
1993
|
+
|
|
1994
|
+
# Try if versioneer module
|
|
1995
|
+
try:
|
|
1996
|
+
version = version_module.get_versions()['version']
|
|
1997
|
+
except AttributeError:
|
|
1998
|
+
pass
|
|
1999
|
+
|
|
2000
|
+
if version is not None:
|
|
2001
|
+
break
|
|
2002
|
+
|
|
2003
|
+
if version is not None:
|
|
2004
|
+
self.version = version
|
|
2005
|
+
return version
|
|
2006
|
+
|
|
2007
|
+
# Get version as SVN or Mercurial revision number
|
|
2008
|
+
revision = self._get_svn_revision(self.local_path)
|
|
2009
|
+
if revision is None:
|
|
2010
|
+
revision = self._get_hg_revision(self.local_path)
|
|
2011
|
+
|
|
2012
|
+
if revision is not None:
|
|
2013
|
+
version = str(revision)
|
|
2014
|
+
self.version = version
|
|
2015
|
+
|
|
2016
|
+
return version
|
|
2017
|
+
|
|
2018
|
+
def make_svn_version_py(self, delete=True):
|
|
2019
|
+
"""Appends a data function to the data_files list that will generate
|
|
2020
|
+
__svn_version__.py file to the current package directory.
|
|
2021
|
+
|
|
2022
|
+
Generate package __svn_version__.py file from SVN revision number,
|
|
2023
|
+
it will be removed after python exits but will be available
|
|
2024
|
+
when sdist, etc commands are executed.
|
|
2025
|
+
|
|
2026
|
+
Notes
|
|
2027
|
+
-----
|
|
2028
|
+
If __svn_version__.py existed before, nothing is done.
|
|
2029
|
+
|
|
2030
|
+
This is
|
|
2031
|
+
intended for working with source directories that are in an SVN
|
|
2032
|
+
repository.
|
|
2033
|
+
"""
|
|
2034
|
+
target = njoin(self.local_path, '__svn_version__.py')
|
|
2035
|
+
revision = self._get_svn_revision(self.local_path)
|
|
2036
|
+
if os.path.isfile(target) or revision is None:
|
|
2037
|
+
return
|
|
2038
|
+
else:
|
|
2039
|
+
def generate_svn_version_py():
|
|
2040
|
+
if not os.path.isfile(target):
|
|
2041
|
+
version = str(revision)
|
|
2042
|
+
self.info('Creating %s (version=%r)' % (target, version))
|
|
2043
|
+
with open(target, 'w') as f:
|
|
2044
|
+
f.write('version = %r\n' % (version))
|
|
2045
|
+
|
|
2046
|
+
def rm_file(f=target,p=self.info):
|
|
2047
|
+
if delete:
|
|
2048
|
+
try: os.remove(f); p('removed '+f)
|
|
2049
|
+
except OSError: pass
|
|
2050
|
+
try: os.remove(f+'c'); p('removed '+f+'c')
|
|
2051
|
+
except OSError: pass
|
|
2052
|
+
|
|
2053
|
+
atexit.register(rm_file)
|
|
2054
|
+
|
|
2055
|
+
return target
|
|
2056
|
+
|
|
2057
|
+
self.add_data_files(('', generate_svn_version_py()))
|
|
2058
|
+
|
|
2059
|
+
def make_hg_version_py(self, delete=True):
|
|
2060
|
+
"""Appends a data function to the data_files list that will generate
|
|
2061
|
+
__hg_version__.py file to the current package directory.
|
|
2062
|
+
|
|
2063
|
+
Generate package __hg_version__.py file from Mercurial revision,
|
|
2064
|
+
it will be removed after python exits but will be available
|
|
2065
|
+
when sdist, etc commands are executed.
|
|
2066
|
+
|
|
2067
|
+
Notes
|
|
2068
|
+
-----
|
|
2069
|
+
If __hg_version__.py existed before, nothing is done.
|
|
2070
|
+
|
|
2071
|
+
This is intended for working with source directories that are
|
|
2072
|
+
in a Mercurial repository.
|
|
2073
|
+
"""
|
|
2074
|
+
target = njoin(self.local_path, '__hg_version__.py')
|
|
2075
|
+
revision = self._get_hg_revision(self.local_path)
|
|
2076
|
+
if os.path.isfile(target) or revision is None:
|
|
2077
|
+
return
|
|
2078
|
+
else:
|
|
2079
|
+
def generate_hg_version_py():
|
|
2080
|
+
if not os.path.isfile(target):
|
|
2081
|
+
version = str(revision)
|
|
2082
|
+
self.info('Creating %s (version=%r)' % (target, version))
|
|
2083
|
+
with open(target, 'w') as f:
|
|
2084
|
+
f.write('version = %r\n' % (version))
|
|
2085
|
+
|
|
2086
|
+
def rm_file(f=target,p=self.info):
|
|
2087
|
+
if delete:
|
|
2088
|
+
try: os.remove(f); p('removed '+f)
|
|
2089
|
+
except OSError: pass
|
|
2090
|
+
try: os.remove(f+'c'); p('removed '+f+'c')
|
|
2091
|
+
except OSError: pass
|
|
2092
|
+
|
|
2093
|
+
atexit.register(rm_file)
|
|
2094
|
+
|
|
2095
|
+
return target
|
|
2096
|
+
|
|
2097
|
+
self.add_data_files(('', generate_hg_version_py()))
|
|
2098
|
+
|
|
2099
|
+
def make_config_py(self,name='__config__'):
|
|
2100
|
+
"""Generate package __config__.py file containing system_info
|
|
2101
|
+
information used during building the package.
|
|
2102
|
+
|
|
2103
|
+
This file is installed to the
|
|
2104
|
+
package installation directory.
|
|
2105
|
+
|
|
2106
|
+
"""
|
|
2107
|
+
self.py_modules.append((self.name, name, generate_config_py))
|
|
2108
|
+
|
|
2109
|
+
def get_info(self,*names):
|
|
2110
|
+
"""Get resources information.
|
|
2111
|
+
|
|
2112
|
+
Return information (from system_info.get_info) for all of the names in
|
|
2113
|
+
the argument list in a single dictionary.
|
|
2114
|
+
"""
|
|
2115
|
+
from .system_info import get_info, dict_append
|
|
2116
|
+
info_dict = {}
|
|
2117
|
+
for a in names:
|
|
2118
|
+
dict_append(info_dict,**get_info(a))
|
|
2119
|
+
return info_dict
|
|
2120
|
+
|
|
2121
|
+
|
|
2122
|
+
def get_cmd(cmdname, _cache={}):
|
|
2123
|
+
if cmdname not in _cache:
|
|
2124
|
+
import distutils.core
|
|
2125
|
+
dist = distutils.core._setup_distribution
|
|
2126
|
+
if dist is None:
|
|
2127
|
+
from distutils.errors import DistutilsInternalError
|
|
2128
|
+
raise DistutilsInternalError(
|
|
2129
|
+
'setup distribution instance not initialized')
|
|
2130
|
+
cmd = dist.get_command_obj(cmdname)
|
|
2131
|
+
_cache[cmdname] = cmd
|
|
2132
|
+
return _cache[cmdname]
|
|
2133
|
+
|
|
2134
|
+
def get_numpy_include_dirs():
|
|
2135
|
+
# numpy_include_dirs are set by numpy/_core/setup.py, otherwise []
|
|
2136
|
+
include_dirs = Configuration.numpy_include_dirs[:]
|
|
2137
|
+
if not include_dirs:
|
|
2138
|
+
import numpy
|
|
2139
|
+
include_dirs = [ numpy.get_include() ]
|
|
2140
|
+
# else running numpy/_core/setup.py
|
|
2141
|
+
return include_dirs
|
|
2142
|
+
|
|
2143
|
+
def get_npy_pkg_dir():
|
|
2144
|
+
"""Return the path where to find the npy-pkg-config directory.
|
|
2145
|
+
|
|
2146
|
+
If the NPY_PKG_CONFIG_PATH environment variable is set, the value of that
|
|
2147
|
+
is returned. Otherwise, a path inside the location of the numpy module is
|
|
2148
|
+
returned.
|
|
2149
|
+
|
|
2150
|
+
The NPY_PKG_CONFIG_PATH can be useful when cross-compiling, maintaining
|
|
2151
|
+
customized npy-pkg-config .ini files for the cross-compilation
|
|
2152
|
+
environment, and using them when cross-compiling.
|
|
2153
|
+
|
|
2154
|
+
"""
|
|
2155
|
+
d = os.environ.get('NPY_PKG_CONFIG_PATH')
|
|
2156
|
+
if d is not None:
|
|
2157
|
+
return d
|
|
2158
|
+
spec = importlib.util.find_spec('numpy')
|
|
2159
|
+
d = os.path.join(os.path.dirname(spec.origin),
|
|
2160
|
+
'_core', 'lib', 'npy-pkg-config')
|
|
2161
|
+
return d
|
|
2162
|
+
|
|
2163
|
+
def get_pkg_info(pkgname, dirs=None):
|
|
2164
|
+
"""
|
|
2165
|
+
Return library info for the given package.
|
|
2166
|
+
|
|
2167
|
+
Parameters
|
|
2168
|
+
----------
|
|
2169
|
+
pkgname : str
|
|
2170
|
+
Name of the package (should match the name of the .ini file, without
|
|
2171
|
+
the extension, e.g. foo for the file foo.ini).
|
|
2172
|
+
dirs : sequence, optional
|
|
2173
|
+
If given, should be a sequence of additional directories where to look
|
|
2174
|
+
for npy-pkg-config files. Those directories are searched prior to the
|
|
2175
|
+
NumPy directory.
|
|
2176
|
+
|
|
2177
|
+
Returns
|
|
2178
|
+
-------
|
|
2179
|
+
pkginfo : class instance
|
|
2180
|
+
The `LibraryInfo` instance containing the build information.
|
|
2181
|
+
|
|
2182
|
+
Raises
|
|
2183
|
+
------
|
|
2184
|
+
PkgNotFound
|
|
2185
|
+
If the package is not found.
|
|
2186
|
+
|
|
2187
|
+
See Also
|
|
2188
|
+
--------
|
|
2189
|
+
Configuration.add_npy_pkg_config, Configuration.add_installed_library,
|
|
2190
|
+
get_info
|
|
2191
|
+
|
|
2192
|
+
"""
|
|
2193
|
+
from numpy.distutils.npy_pkg_config import read_config
|
|
2194
|
+
|
|
2195
|
+
if dirs:
|
|
2196
|
+
dirs.append(get_npy_pkg_dir())
|
|
2197
|
+
else:
|
|
2198
|
+
dirs = [get_npy_pkg_dir()]
|
|
2199
|
+
return read_config(pkgname, dirs)
|
|
2200
|
+
|
|
2201
|
+
def get_info(pkgname, dirs=None):
|
|
2202
|
+
"""
|
|
2203
|
+
Return an info dict for a given C library.
|
|
2204
|
+
|
|
2205
|
+
The info dict contains the necessary options to use the C library.
|
|
2206
|
+
|
|
2207
|
+
Parameters
|
|
2208
|
+
----------
|
|
2209
|
+
pkgname : str
|
|
2210
|
+
Name of the package (should match the name of the .ini file, without
|
|
2211
|
+
the extension, e.g. foo for the file foo.ini).
|
|
2212
|
+
dirs : sequence, optional
|
|
2213
|
+
If given, should be a sequence of additional directories where to look
|
|
2214
|
+
for npy-pkg-config files. Those directories are searched prior to the
|
|
2215
|
+
NumPy directory.
|
|
2216
|
+
|
|
2217
|
+
Returns
|
|
2218
|
+
-------
|
|
2219
|
+
info : dict
|
|
2220
|
+
The dictionary with build information.
|
|
2221
|
+
|
|
2222
|
+
Raises
|
|
2223
|
+
------
|
|
2224
|
+
PkgNotFound
|
|
2225
|
+
If the package is not found.
|
|
2226
|
+
|
|
2227
|
+
See Also
|
|
2228
|
+
--------
|
|
2229
|
+
Configuration.add_npy_pkg_config, Configuration.add_installed_library,
|
|
2230
|
+
get_pkg_info
|
|
2231
|
+
|
|
2232
|
+
Examples
|
|
2233
|
+
--------
|
|
2234
|
+
To get the necessary information for the npymath library from NumPy:
|
|
2235
|
+
|
|
2236
|
+
>>> npymath_info = np.distutils.misc_util.get_info('npymath')
|
|
2237
|
+
>>> npymath_info #doctest: +SKIP
|
|
2238
|
+
{'define_macros': [], 'libraries': ['npymath'], 'library_dirs':
|
|
2239
|
+
['.../numpy/_core/lib'], 'include_dirs': ['.../numpy/_core/include']}
|
|
2240
|
+
|
|
2241
|
+
This info dict can then be used as input to a `Configuration` instance::
|
|
2242
|
+
|
|
2243
|
+
config.add_extension('foo', sources=['foo.c'], extra_info=npymath_info)
|
|
2244
|
+
|
|
2245
|
+
"""
|
|
2246
|
+
from numpy.distutils.npy_pkg_config import parse_flags
|
|
2247
|
+
pkg_info = get_pkg_info(pkgname, dirs)
|
|
2248
|
+
|
|
2249
|
+
# Translate LibraryInfo instance into a build_info dict
|
|
2250
|
+
info = parse_flags(pkg_info.cflags())
|
|
2251
|
+
for k, v in parse_flags(pkg_info.libs()).items():
|
|
2252
|
+
info[k].extend(v)
|
|
2253
|
+
|
|
2254
|
+
# add_extension extra_info argument is ANAL
|
|
2255
|
+
info['define_macros'] = info['macros']
|
|
2256
|
+
del info['macros']
|
|
2257
|
+
del info['ignored']
|
|
2258
|
+
|
|
2259
|
+
return info
|
|
2260
|
+
|
|
2261
|
+
def is_bootstrapping():
|
|
2262
|
+
import builtins
|
|
2263
|
+
|
|
2264
|
+
try:
|
|
2265
|
+
builtins.__NUMPY_SETUP__
|
|
2266
|
+
return True
|
|
2267
|
+
except AttributeError:
|
|
2268
|
+
return False
|
|
2269
|
+
|
|
2270
|
+
|
|
2271
|
+
#########################
|
|
2272
|
+
|
|
2273
|
+
def default_config_dict(name = None, parent_name = None, local_path=None):
|
|
2274
|
+
"""Return a configuration dictionary for usage in
|
|
2275
|
+
configuration() function defined in file setup_<name>.py.
|
|
2276
|
+
"""
|
|
2277
|
+
import warnings
|
|
2278
|
+
warnings.warn('Use Configuration(%r,%r,top_path=%r) instead of '\
|
|
2279
|
+
'deprecated default_config_dict(%r,%r,%r)'
|
|
2280
|
+
% (name, parent_name, local_path,
|
|
2281
|
+
name, parent_name, local_path,
|
|
2282
|
+
), stacklevel=2)
|
|
2283
|
+
c = Configuration(name, parent_name, local_path)
|
|
2284
|
+
return c.todict()
|
|
2285
|
+
|
|
2286
|
+
|
|
2287
|
+
def dict_append(d, **kws):
|
|
2288
|
+
for k, v in kws.items():
|
|
2289
|
+
if k in d:
|
|
2290
|
+
ov = d[k]
|
|
2291
|
+
if isinstance(ov, str):
|
|
2292
|
+
d[k] = v
|
|
2293
|
+
else:
|
|
2294
|
+
d[k].extend(v)
|
|
2295
|
+
else:
|
|
2296
|
+
d[k] = v
|
|
2297
|
+
|
|
2298
|
+
def appendpath(prefix, path):
|
|
2299
|
+
if os.path.sep != '/':
|
|
2300
|
+
prefix = prefix.replace('/', os.path.sep)
|
|
2301
|
+
path = path.replace('/', os.path.sep)
|
|
2302
|
+
drive = ''
|
|
2303
|
+
if os.path.isabs(path):
|
|
2304
|
+
drive = os.path.splitdrive(prefix)[0]
|
|
2305
|
+
absprefix = os.path.splitdrive(os.path.abspath(prefix))[1]
|
|
2306
|
+
pathdrive, path = os.path.splitdrive(path)
|
|
2307
|
+
d = os.path.commonprefix([absprefix, path])
|
|
2308
|
+
if os.path.join(absprefix[:len(d)], absprefix[len(d):]) != absprefix \
|
|
2309
|
+
or os.path.join(path[:len(d)], path[len(d):]) != path:
|
|
2310
|
+
# Handle invalid paths
|
|
2311
|
+
d = os.path.dirname(d)
|
|
2312
|
+
subpath = path[len(d):]
|
|
2313
|
+
if os.path.isabs(subpath):
|
|
2314
|
+
subpath = subpath[1:]
|
|
2315
|
+
else:
|
|
2316
|
+
subpath = path
|
|
2317
|
+
return os.path.normpath(njoin(drive + prefix, subpath))
|
|
2318
|
+
|
|
2319
|
+
def generate_config_py(target):
|
|
2320
|
+
"""Generate config.py file containing system_info information
|
|
2321
|
+
used during building the package.
|
|
2322
|
+
|
|
2323
|
+
Usage:
|
|
2324
|
+
config['py_modules'].append((packagename, '__config__',generate_config_py))
|
|
2325
|
+
"""
|
|
2326
|
+
from numpy.distutils.system_info import system_info
|
|
2327
|
+
from distutils.dir_util import mkpath
|
|
2328
|
+
mkpath(os.path.dirname(target))
|
|
2329
|
+
with open(target, 'w') as f:
|
|
2330
|
+
f.write('# This file is generated by numpy\'s %s\n' % (os.path.basename(sys.argv[0])))
|
|
2331
|
+
f.write('# It contains system_info results at the time of building this package.\n')
|
|
2332
|
+
f.write('__all__ = ["get_info","show"]\n\n')
|
|
2333
|
+
|
|
2334
|
+
# For gfortran+msvc combination, extra shared libraries may exist
|
|
2335
|
+
f.write(textwrap.dedent("""
|
|
2336
|
+
import os
|
|
2337
|
+
import sys
|
|
2338
|
+
|
|
2339
|
+
extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs')
|
|
2340
|
+
|
|
2341
|
+
if sys.platform == 'win32' and os.path.isdir(extra_dll_dir):
|
|
2342
|
+
os.add_dll_directory(extra_dll_dir)
|
|
2343
|
+
|
|
2344
|
+
"""))
|
|
2345
|
+
|
|
2346
|
+
for k, i in system_info.saved_results.items():
|
|
2347
|
+
f.write('%s=%r\n' % (k, i))
|
|
2348
|
+
f.write(textwrap.dedent(r'''
|
|
2349
|
+
def get_info(name):
|
|
2350
|
+
g = globals()
|
|
2351
|
+
return g.get(name, g.get(name + "_info", {}))
|
|
2352
|
+
|
|
2353
|
+
def show():
|
|
2354
|
+
"""
|
|
2355
|
+
Show libraries in the system on which NumPy was built.
|
|
2356
|
+
|
|
2357
|
+
Print information about various resources (libraries, library
|
|
2358
|
+
directories, include directories, etc.) in the system on which
|
|
2359
|
+
NumPy was built.
|
|
2360
|
+
|
|
2361
|
+
See Also
|
|
2362
|
+
--------
|
|
2363
|
+
get_include : Returns the directory containing NumPy C
|
|
2364
|
+
header files.
|
|
2365
|
+
|
|
2366
|
+
Notes
|
|
2367
|
+
-----
|
|
2368
|
+
1. Classes specifying the information to be printed are defined
|
|
2369
|
+
in the `numpy.distutils.system_info` module.
|
|
2370
|
+
|
|
2371
|
+
Information may include:
|
|
2372
|
+
|
|
2373
|
+
* ``language``: language used to write the libraries (mostly
|
|
2374
|
+
C or f77)
|
|
2375
|
+
* ``libraries``: names of libraries found in the system
|
|
2376
|
+
* ``library_dirs``: directories containing the libraries
|
|
2377
|
+
* ``include_dirs``: directories containing library header files
|
|
2378
|
+
* ``src_dirs``: directories containing library source files
|
|
2379
|
+
* ``define_macros``: preprocessor macros used by
|
|
2380
|
+
``distutils.setup``
|
|
2381
|
+
* ``baseline``: minimum CPU features required
|
|
2382
|
+
* ``found``: dispatched features supported in the system
|
|
2383
|
+
* ``not found``: dispatched features that are not supported
|
|
2384
|
+
in the system
|
|
2385
|
+
|
|
2386
|
+
2. NumPy BLAS/LAPACK Installation Notes
|
|
2387
|
+
|
|
2388
|
+
Installing a numpy wheel (``pip install numpy`` or force it
|
|
2389
|
+
via ``pip install numpy --only-binary :numpy: numpy``) includes
|
|
2390
|
+
an OpenBLAS implementation of the BLAS and LAPACK linear algebra
|
|
2391
|
+
APIs. In this case, ``library_dirs`` reports the original build
|
|
2392
|
+
time configuration as compiled with gcc/gfortran; at run time
|
|
2393
|
+
the OpenBLAS library is in
|
|
2394
|
+
``site-packages/numpy.libs/`` (linux), or
|
|
2395
|
+
``site-packages/numpy/.dylibs/`` (macOS), or
|
|
2396
|
+
``site-packages/numpy/.libs/`` (windows).
|
|
2397
|
+
|
|
2398
|
+
Installing numpy from source
|
|
2399
|
+
(``pip install numpy --no-binary numpy``) searches for BLAS and
|
|
2400
|
+
LAPACK dynamic link libraries at build time as influenced by
|
|
2401
|
+
environment variables NPY_BLAS_LIBS, NPY_CBLAS_LIBS, and
|
|
2402
|
+
NPY_LAPACK_LIBS; or NPY_BLAS_ORDER and NPY_LAPACK_ORDER;
|
|
2403
|
+
or the optional file ``~/.numpy-site.cfg``.
|
|
2404
|
+
NumPy remembers those locations and expects to load the same
|
|
2405
|
+
libraries at run-time.
|
|
2406
|
+
In NumPy 1.21+ on macOS, 'accelerate' (Apple's Accelerate BLAS
|
|
2407
|
+
library) is in the default build-time search order after
|
|
2408
|
+
'openblas'.
|
|
2409
|
+
|
|
2410
|
+
Examples
|
|
2411
|
+
--------
|
|
2412
|
+
>>> import numpy as np
|
|
2413
|
+
>>> np.show_config()
|
|
2414
|
+
blas_opt_info:
|
|
2415
|
+
language = c
|
|
2416
|
+
define_macros = [('HAVE_CBLAS', None)]
|
|
2417
|
+
libraries = ['openblas', 'openblas']
|
|
2418
|
+
library_dirs = ['/usr/local/lib']
|
|
2419
|
+
"""
|
|
2420
|
+
from numpy._core._multiarray_umath import (
|
|
2421
|
+
__cpu_features__, __cpu_baseline__, __cpu_dispatch__
|
|
2422
|
+
)
|
|
2423
|
+
for name,info_dict in globals().items():
|
|
2424
|
+
if name[0] == "_" or type(info_dict) is not type({}): continue
|
|
2425
|
+
print(name + ":")
|
|
2426
|
+
if not info_dict:
|
|
2427
|
+
print(" NOT AVAILABLE")
|
|
2428
|
+
for k,v in info_dict.items():
|
|
2429
|
+
v = str(v)
|
|
2430
|
+
if k == "sources" and len(v) > 200:
|
|
2431
|
+
v = v[:60] + " ...\n... " + v[-60:]
|
|
2432
|
+
print(" %s = %s" % (k,v))
|
|
2433
|
+
|
|
2434
|
+
features_found, features_not_found = [], []
|
|
2435
|
+
for feature in __cpu_dispatch__:
|
|
2436
|
+
if __cpu_features__[feature]:
|
|
2437
|
+
features_found.append(feature)
|
|
2438
|
+
else:
|
|
2439
|
+
features_not_found.append(feature)
|
|
2440
|
+
|
|
2441
|
+
print("Supported SIMD extensions in this NumPy install:")
|
|
2442
|
+
print(" baseline = %s" % (','.join(__cpu_baseline__)))
|
|
2443
|
+
print(" found = %s" % (','.join(features_found)))
|
|
2444
|
+
print(" not found = %s" % (','.join(features_not_found)))
|
|
2445
|
+
|
|
2446
|
+
'''))
|
|
2447
|
+
|
|
2448
|
+
return target
|
|
2449
|
+
|
|
2450
|
+
def msvc_version(compiler):
|
|
2451
|
+
"""Return version major and minor of compiler instance if it is
|
|
2452
|
+
MSVC, raise an exception otherwise."""
|
|
2453
|
+
if not compiler.compiler_type == "msvc":
|
|
2454
|
+
raise ValueError("Compiler instance is not msvc (%s)"\
|
|
2455
|
+
% compiler.compiler_type)
|
|
2456
|
+
return compiler._MSVCCompiler__version
|
|
2457
|
+
|
|
2458
|
+
def get_build_architecture():
|
|
2459
|
+
# Importing distutils.msvccompiler triggers a warning on non-Windows
|
|
2460
|
+
# systems, so delay the import to here.
|
|
2461
|
+
from distutils.msvccompiler import get_build_architecture
|
|
2462
|
+
return get_build_architecture()
|
|
2463
|
+
|
|
2464
|
+
|
|
2465
|
+
_cxx_ignore_flags = {'-Werror=implicit-function-declaration', '-std=c99'}
|
|
2466
|
+
|
|
2467
|
+
|
|
2468
|
+
def sanitize_cxx_flags(cxxflags):
|
|
2469
|
+
'''
|
|
2470
|
+
Some flags are valid for C but not C++. Prune them.
|
|
2471
|
+
'''
|
|
2472
|
+
return [flag for flag in cxxflags if flag not in _cxx_ignore_flags]
|
|
2473
|
+
|
|
2474
|
+
|
|
2475
|
+
def exec_mod_from_location(modname, modfile):
|
|
2476
|
+
'''
|
|
2477
|
+
Use importlib machinery to import a module `modname` from the file
|
|
2478
|
+
`modfile`. Depending on the `spec.loader`, the module may not be
|
|
2479
|
+
registered in sys.modules.
|
|
2480
|
+
'''
|
|
2481
|
+
spec = importlib.util.spec_from_file_location(modname, modfile)
|
|
2482
|
+
foo = importlib.util.module_from_spec(spec)
|
|
2483
|
+
spec.loader.exec_module(foo)
|
|
2484
|
+
return foo
|