distutils.misc_util¶
- numpy.distutils.misc_util.all_strings(lst)[source]¶
Return True if all items in lst are string objects.
- numpy.distutils.misc_util.allpath(name)[source]¶
Convert a /-separated pathname to one using the OS’s path separator.
- numpy.distutils.misc_util.cyg2win32(path: str) str [source]¶
Convert a path from Cygwin-native to Windows-native.
Uses the cygpath utility (part of the Base install) to do the actual conversion. Falls back to returning the original path if this fails.
Handles the default
/cygdrive
mount prefix as well as the/proc/cygdrive
portable prefix, custom cygdrive prefixes such as/
or/mnt
, and absolute paths such as/usr/src/
or/home/username
- Parameters
- pathstr
The path to convert
- Returns
- converted_pathstr
The converted path
Notes
Documentation for cygpath utility: https://cygwin.com/cygwin-ug-net/cygpath.html Documentation for the C function it wraps: https://cygwin.com/cygwin-api/func-cygwin-conv-path.html
- numpy.distutils.misc_util.default_config_dict(name=None, parent_name=None, local_path=None)[source]¶
Return a configuration dictionary for usage in configuration() function defined in file setup_<name>.py.
- numpy.distutils.misc_util.exec_mod_from_location(modname, modfile)[source]¶
Use importlib machinery to import a module modname from the file modfile. Depending on the spec.loader, the module may not be registered in sys.modules.
- numpy.distutils.misc_util.filter_sources(sources)[source]¶
Return four lists of filenames containing C, C++, Fortran, and Fortran 90 module sources, respectively.
- numpy.distutils.misc_util.generate_config_py(target)[source]¶
Generate config.py file containing system_info information used during building the package.
- Usage:
config[‘py_modules’].append((packagename, ‘__config__’,generate_config_py))
- numpy.distutils.misc_util.get_frame(level=0)[source]¶
Return frame object from call stack with given level.
- numpy.distutils.misc_util.get_info(pkgname, dirs=None)[source]¶
Return an info dict for a given C library.
The info dict contains the necessary options to use the C library.
- Parameters
- pkgnamestr
Name of the package (should match the name of the .ini file, without the extension, e.g. foo for the file foo.ini).
- dirssequence, optional
If given, should be a sequence of additional directories where to look for npy-pkg-config files. Those directories are searched prior to the NumPy directory.
- Returns
- infodict
The dictionary with build information.
- Raises
- PkgNotFound
If the package is not found.
Examples
To get the necessary information for the npymath library from NumPy:
>>> npymath_info = np.distutils.misc_util.get_info('npymath') >>> npymath_info {'define_macros': [], 'libraries': ['npymath'], 'library_dirs': ['.../numpy/core/lib'], 'include_dirs': ['.../numpy/core/include']}
This info dict can then be used as input to a
Configuration
instance:config.add_extension('foo', sources=['foo.c'], extra_info=npymath_info)
- numpy.distutils.misc_util.get_language(sources)[source]¶
Determine language value (c,f77,f90) from sources
- numpy.distutils.misc_util.get_mathlibs(path=None)[source]¶
Return the MATHLIB line from numpyconfig.h
- numpy.distutils.misc_util.get_num_build_jobs()[source]¶
Get number of parallel build jobs set by the –parallel command line argument of setup.py If the command did not receive a setting the environment variable NPY_NUM_BUILD_JOBS is checked. If that is unset, return the number of processors on the system, with a maximum of 8 (to prevent overloading the system if there a lot of CPUs).
- Returns
- outint
number of parallel jobs that can be run
- numpy.distutils.misc_util.get_pkg_info(pkgname, dirs=None)[source]¶
Return library info for the given package.
- Parameters
- pkgnamestr
Name of the package (should match the name of the .ini file, without the extension, e.g. foo for the file foo.ini).
- dirssequence, optional
If given, should be a sequence of additional directories where to look for npy-pkg-config files. Those directories are searched prior to the NumPy directory.
- Returns
- pkginfoclass instance
The LibraryInfo instance containing the build information.
- Raises
- PkgNotFound
If the package is not found.
- numpy.distutils.misc_util.gpaths(paths, local_path='', include_non_existing=True)[source]¶
Apply glob to paths and prepend local_path if needed.
- numpy.distutils.misc_util.has_cxx_sources(sources)[source]¶
Return True if sources contains C++ files
- numpy.distutils.misc_util.has_f_sources(sources)[source]¶
Return True if sources contains Fortran files
- numpy.distutils.misc_util.is_local_src_dir(directory)[source]¶
Return true if directory is local directory.
- numpy.distutils.misc_util.njoin(*path)[source]¶
Join two or more pathname components + - convert a /-separated pathname to one using the OS’s path separator. - resolve and from path.
Either passing n arguments as in njoin(‘a’,’b’), or a sequence of n names as in njoin([‘a’,’b’]) is handled, or a mixture of such arguments.