示例#1
0
def setup(log='fwrap_setup.log', *args, **kwargs):
    if log:
        _old_stdout, _old_stderr = sys.stdout, sys.stderr
        log = open(log, 'w')
        sys.stdout = log
        sys.stderr = log
    try:
        np_setup(*args, **kwargs)
    finally:
        if log:
            log.flush()
            log.close()
            sys.stdout, sys.stderr = _old_stdout, _old_stderr
示例#2
0
文件: setup.py 项目: grollins/calm
import os
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
# update it when the contents of directories change.
if os.path.exists('MANIFEST'):
    os.remove('MANIFEST')

from numpy.distutils.misc_util import Configuration

def configuration(parent_package='', top_path=None):
    config = Configuration('calm', parent_package, top_path)
    config.add_subpackage('test')
    config.add_data_dir('test_data')
    return config

if __name__ == '__main__':
    from numpy.distutils.core import setup as np_setup
    np_setup(**configuration(top_path='').todict())
    extension_name = ".".join(["bgd", source_file])
    extension_name = os.path.splitext(extension_name)[0]
    print(extension_name, sources)
    extensions.append(
        Extension(extension_name,
                  sources,
                  language="c",
                  include_dirs=[np.get_include()],
                  extra_compile_args=['-fopenmp', '-O3'],
                  extra_link_args=['-fopenmp']))
    extensions[-1].cython_directives = {'embedsignature': True}

build_cmds = {'install', 'build', 'build_ext'}
GOT_BUILD_CMD = len(set(sys.argv) & build_cmds) != 0
if USE_CYTHON and GOT_BUILD_CMD:
    # Setting "bgd" as the root package
    # This is to prevent cython from generating inappropriate variable names
    # (because it is based on a relative path)
    init_path = os.path.join(os.path.realpath(__file__), "../__init__.py")
    if os.path.isfile(init_path):
        os.remove(init_path)
        print("__init__.py file removed")
    # Generates the C files, but does not compile them
    print('\t\tCYTHONINZING')
    extensions = cythonize(extensions,
                           language="c",
                           compiler_directives={'embedsignature': True})

if GOT_BUILD_CMD:
    np_setup(**setup_args)
示例#4
0
    '-msse',
    '-msse2',
    '-mfma',
    '-mfpmath=sse',
]

LIBRARIES = ["m"] if os.name == "posix" else list()
INCLUDE_DIRS = [np.get_include()]

CONFIG = Configuration(SRC_FOLDER, "", "")
for sub_package in SUB_PACKAGES:
    CONFIG.add_subpackage(sub_package)
for sources, extension_name in SRC_FILES:
    sources = [os.path.join(SRC_FOLDER, source) for source in sources]
    #extension_name = os.path.splitext(extension_name)[0]
    print(extension_name, sources)
    CONFIG.add_extension(extension_name,
                         sources=sources,
                         include_dirs=INCLUDE_DIRS + [os.curdir],
                         libraries=LIBRARIES,
                         extra_compile_args=COMPILE_ARGS,
                         extra_link_args=['-fopenmp'])

np_setup(**CONFIG.todict())

if DELETE_GENERATED_C_FILES:
    for source_file in SRC_FILES:
        filepath = os.path.join(SRC_FOLDER, source_file[0][0])
        if os.path.isfile(filepath) and os.path.splitext(filepath)[1] == '.c':
            os.remove(filepath)
示例#5
0
    (["math.c"], "math"), (["maxent.py"], "maxent"), (["stats.c"], "stats"),
    (["ann/layers.py"], "ann.layers"), (["ann/model.py"], "ann.model"),
    (["ann/subnetworks.py"], "ann.subnetworks"),
    (["estimation/clustering.c",
      "estimation/cmeans_.c"], "estimation.clustering"),
    (["estimation/cpd.c", "estimation/kernel_.c",
      "estimation/queue_.c"], "estimation.cpd"),
    (["misc/check_data.py"], "check_data"),
    (["misc/exceptions.py"], "exceptions"), (["misc/topology.py"], "topology"),
    (["misc/utils.py"], "utils")
]

extra_compile_args = list()

libraries = ["m"] if os.name == "posix" else list()
include_dirs = [np.get_include()]

config = Configuration(source_folder, "", "")
for sub_package in sub_packages:
    config.add_subpackage(sub_package)
for sources, extension_name in source_files:
    sources = [os.path.join(source_folder, source) for source in sources]
    print(extension_name, sources)
    config.add_extension(extension_name,
                         sources=sources,
                         include_dirs=include_dirs + [os.curdir],
                         libraries=libraries,
                         extra_compile_args=extra_compile_args)

np_setup(**config.todict())
示例#6
0
文件: setup.py 项目: doctaphred/palm
import os
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
# update it when the contents of directories change.
if os.path.exists('MANIFEST'):
    os.remove('MANIFEST')

from numpy.distutils.misc_util import Configuration

def configuration(parent_package='', top_path=None):
    config = Configuration('palm', parent_package, top_path)
    config.add_subpackage('base')
    config.add_subpackage('test')
    config.add_data_dir('data')
    config.add_data_dir('test/test_data')
    config.add_data_dir('scripts')
    return config

if __name__ == '__main__':
    from numpy.distutils.core import setup as np_setup
    np_setup(**configuration(top_path='').todict())