python类get_include()的实例源码

utils.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_include():
    """
    Return the directory that contains the NumPy \\*.h header files.

    Extension modules that need to compile against NumPy should use this
    function to locate the appropriate include directory.

    Notes
    -----
    When using ``distutils``, for example in ``setup.py``.
    ::

        import numpy as np
        ...
        Extension('extension_name', ...
                include_dirs=[np.get_include()])
        ...

    """
    import numpy
    if numpy.show_config is None:
        # running from numpy source directory
        d = os.path.join(os.path.dirname(numpy.__file__), 'core', 'include')
    else:
        # using installed numpy core headers
        import numpy.core as core
        d = os.path.join(os.path.dirname(core.__file__), 'include')
    return d
misc_util.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_numpy_include_dirs():
    # numpy_include_dirs are set by numpy/core/setup.py, otherwise []
    include_dirs = Configuration.numpy_include_dirs[:]
    if not include_dirs:
        import numpy
        include_dirs = [ numpy.get_include() ]
    # else running numpy/core/setup.py
    return include_dirs
modelutils.py 文件源码 项目:hydpy 作者: tyralla 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def compile_(self):
        """Translate cython code to C code and compile it."""
        from Cython import Build
        argv = copy.deepcopy(sys.argv)
        sys.argv = [sys.argv[0], 'build_ext', '--build-lib='+self.buildpath]
        exc_modules = [
                distutils.extension.Extension(
                        'hydpy.cythons.autogen.'+self.cyname,
                        [self.cyfilepath], extra_compile_args=['-O2'])]
        distutils.core.setup(ext_modules=Build.cythonize(exc_modules),
                             include_dirs=[numpy.get_include()])
        sys.argv = argv
setup.py 文件源码 项目:yt 作者: yt-project 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def finalize_options(self):
        try:
            import cython
            import numpy
        except ImportError:
            raise ImportError(
"""Could not import cython or numpy. Building yt from source requires
cython and numpy to be installed. Please install these packages using
the appropriate package manager for your python environment.""")
        if LooseVersion(cython.__version__) < LooseVersion('0.24'):
            raise RuntimeError(
"""Building yt from source requires Cython 0.24 or newer but
Cython %s is installed. Please update Cython using the appropriate
package manager for your python environment.""" %
                cython.__version__)
        if LooseVersion(numpy.__version__) < LooseVersion('1.10.4'):
            raise RuntimeError(
"""Building yt from source requires NumPy 1.10.4 or newer but
NumPy %s is installed. Please update NumPy using the appropriate
package manager for your python environment.""" %
                numpy.__version__)
        from Cython.Build import cythonize
        self.distribution.ext_modules[:] = cythonize(
                self.distribution.ext_modules)
        _build_ext.finalize_options(self)
        # Prevent numpy from thinking it is still in its setup process
        # see http://stackoverflow.com/a/21621493/1382869
        if isinstance(__builtins__, dict):
            # sometimes this is a dict so we need to check for that
            # https://docs.python.org/3/library/builtins.html
            __builtins__["__NUMPY_SETUP__"] = False
        else:
            __builtins__.__NUMPY_SETUP__ = False
        self.include_dirs.append(numpy.get_include())
setup.py 文件源码 项目:modl 作者: arthurmensch 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def configuration(parent_package='', top_path=None):
    from numpy.distutils.misc_util import Configuration

    config = Configuration('randomkit', parent_package, top_path)
    libs = []
    if sys.platform == 'win32':
        libs.append('Advapi32')

    extensions = [Extension('modl.utils.randomkit.random_fast',
                            sources=['modl/utils/randomkit/random_fast.pyx',
                                     'modl/utils/randomkit/randomkit.c',
                                     'modl/utils/randomkit/distributions.c',
                                     ],
                            language="c++",
                            include_dirs=[numpy.get_include(),
                                          'modl/utils/randomkit'],
                            ),
                  Extension('modl.utils.randomkit.sampler',
                            sources=['modl/utils/randomkit/sampler.pyx'],
                            language="c++",
                            include_dirs=[numpy.get_include()]
                            )]
    config.ext_modules += extensions

    config.add_subpackage('tests')

    return config
setup.py 文件源码 项目:modl 作者: arthurmensch 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def configuration(parent_package='', top_path=None):
    from numpy.distutils.misc_util import Configuration

    config = Configuration('math', parent_package, top_path)

    extensions = [Extension('modl.utils.math.enet',
                            sources=['modl/utils/math/enet.pyx'],
                            include_dirs=[numpy.get_include()],
                            ),
                  ]
    config.ext_modules += extensions

    config.add_subpackage('tests')

    return config
setup.py 文件源码 项目:xtensor-python-cookiecutter 作者: QuantStack 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __str__(self):
        import pybind11
        return pybind11.get_include(self.user)
setup.py 文件源码 项目:xtensor-python-cookiecutter 作者: QuantStack 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __str__(self):
        import numpy as np
        return np.get_include()
setup_helpers.py 文件源码 项目:bezier 作者: dhermes 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def extension_modules():
    import numpy as np

    libraries, library_dirs = BuildFortranThenExt.get_library_dirs()
    extensions = []
    for name, dependencies in FORTRAN_MODULES.items():
        if name in ('types', 'status'):  # No speedup.
            continue

        mod_name = 'bezier._{}_speedup'.format(name)
        path = SPEEDUP_FILENAME.format(name)
        if BuildFortranThenExt.USE_SHARED_LIBRARY:
            # Here we don't depend on object files since the functionality
            # is contained in the shared library.
            extra_objects = []
        else:
            # NOTE: These may be treated as relative paths and replaced
            #       before the extension is actually built.
            extra_objects = [
                OBJECT_FILENAME.format(dependency)
                for dependency in dependencies
            ]
        # NOTE: Copy ``libraries`` and ``library_dirs`` so they
        #       aren't shared (and mutable) between extensions.
        extension = setuptools.Extension(
            mod_name,
            [path],
            extra_objects=extra_objects,
            include_dirs=[
                np.get_include(),
                os.path.join('src', 'bezier', 'include'),
            ],
            libraries=copy.deepcopy(libraries),
            library_dirs=copy.deepcopy(library_dirs),
        )
        extensions.append(extension)

    return extensions
setup.py 文件源码 项目:robotpy-cscore 作者: robotpy 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def __str__(self):
        import pybind11
        return pybind11.get_include(self.user)
setup.py 文件源码 项目:robotpy-cscore 作者: robotpy 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
def __str__(self):
        import numpy as np
        return np.get_include()

# As of Python 3.6, CCompiler has a `has_flag` method.
# cf http://bugs.python.org/issue26689
setup.py 文件源码 项目:numpythia 作者: scikit-hep 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def finalize_options(self):
        global libnumpythia
        #global external_fastjet
        _build_ext.finalize_options(self)
        # Prevent numpy from thinking it is still in its setup process
        try:
            del builtins.__NUMPY_SETUP__
        except AttributeError:
            pass
        import numpy
        libnumpythia.include_dirs.append(numpy.get_include())
setup.py 文件源码 项目:pohmm 作者: vmonaco 项目源码 文件源码 阅读 66 收藏 0 点赞 0 评论 0
def get_include():
            return os.path.join(sys.prefix, 'include')
misc_util.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def get_numpy_include_dirs():
    # numpy_include_dirs are set by numpy/core/setup.py, otherwise []
    include_dirs = Configuration.numpy_include_dirs[:]
    if not include_dirs:
        import numpy
        include_dirs = [ numpy.get_include() ]
    # else running numpy/core/setup.py
    return include_dirs
setup.py 文件源码 项目:Python-Wrapper-for-World-Vocoder 作者: JeremyCCHsu 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def finalize_options(self):
        _build_ext.finalize_options(self)
        # Prevent numpy from thinking it is still in its setup process:
        __builtins__.__NUMPY_SETUP__ = False
        import numpy
        self.include_dirs.append(numpy.get_include())

# # This can be loosen probably, though it's fine I think
# min_cython_ver = '0.24.0'
# try:
#     import Cython
#     ver = Cython.__version__
#     _CYTHON_INSTALLED = ver >= LooseVersion(min_cython_ver)
# except ImportError:
#     _CYTHON_INSTALLED = False

# try:
#     if not _CYTHON_INSTALLED:
#         raise ImportError('No supported version of Cython installed.')
#     from Cython.Distutils import build_ext
#     cython = True
# except ImportError:
#     cython = False

# if cython:
#     ext = '.pyx'
#     cmdclass = {'build_ext': build_ext}
# else:
#     ext = '.cpp'
#     cmdclass = {}
#     if not os.path.exists(join("pyworld", "pyworld" + ext)):
#         raise RuntimeError("Cython is required to generate C++ wrapper")
test_regression.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_include_dirs(self):
        # As a sanity check, just test that get_include
        # includes something reasonable.  Somewhat
        # related to ticket #1405.
        include_dirs = [np.get_include()]
        for path in include_dirs:
            assert_(isinstance(path, (str, unicode)))
            assert_(path != '')
utils.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_include():
    """
    Return the directory that contains the NumPy \\*.h header files.

    Extension modules that need to compile against NumPy should use this
    function to locate the appropriate include directory.

    Notes
    -----
    When using ``distutils``, for example in ``setup.py``.
    ::

        import numpy as np
        ...
        Extension('extension_name', ...
                include_dirs=[np.get_include()])
        ...

    """
    import numpy
    if numpy.show_config is None:
        # running from numpy source directory
        d = os.path.join(os.path.dirname(numpy.__file__), 'core', 'include')
    else:
        # using installed numpy core headers
        import numpy.core as core
        d = os.path.join(os.path.dirname(core.__file__), 'include')
    return d
misc_util.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_numpy_include_dirs():
    # numpy_include_dirs are set by numpy/core/setup.py, otherwise []
    include_dirs = Configuration.numpy_include_dirs[:]
    if not include_dirs:
        import numpy
        include_dirs = [ numpy.get_include() ]
    # else running numpy/core/setup.py
    return include_dirs
setup.py 文件源码 项目:soft-dtw 作者: mblondel 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def configuration(parent_package='', top_path=None):
    from numpy.distutils.misc_util import Configuration

    config = Configuration('sdtw', parent_package, top_path)

    config.add_extension('soft_dtw_fast', sources=['soft_dtw_fast.c'],
                         include_dirs=[numpy.get_include()])

    config.add_subpackage('tests')

    return config
setup.py 文件源码 项目:preconditioned_GPs 作者: mauriziofilippone 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

# cos_module_np = Extension('cos_module_np',
#                      sources=['PcgComp/kernels/cos_module_np.c'],
#                      include_dirs=[numpy.get_include()])


问题


面经


文章

微信
公众号

扫码关注公众号