Beispiel #1
0
def get_ext_modules():
    ext = ".pyx" if HAVE_CYTHON else ".c"
    src_files = glob.glob(
        os.path.join(os.path.dirname(__file__), "pairtools", "lib", "*" + ext)
    )

    ext_modules = []
    for src_file in src_files:
        name = "pairtools.lib." + os.path.splitext(os.path.basename(src_file))[0]
        if not "pysam" in name and not "regions" in name:
            ext_modules.append(Extension(name, [src_file]))
        elif "regions" in name:
            ext_modules.append(Extension(
                name, [src_file],
                language="c++",
            ))
        else:
            import pysam

            ext_modules.append(
                Extension(
                    name,
                    [src_file],
                    extra_link_args=pysam.get_libraries(),
                    include_dirs=pysam.get_include(),
                    define_macros=pysam.get_defines(),
                )
            )

    if HAVE_CYTHON:
        # .pyx to .c
        ext_modules = cythonize(ext_modules)  # , annotate=True

    return ext_modules
Beispiel #2
0
    def test_package_tests_pass_if_ld_library_path_set(self):

        pysam_libraries = pysam.get_libraries()
        pysam_libdirs, pysam_libs = zip(
            *[os.path.split(x) for x in pysam_libraries])
        pysam_libdir = pysam_libdirs[0]

        self.assertTrue(
            check_tests_pass(
                "export LD_LIBRARY_PATH={}:$PATH && cd {} && python test_module.py"
                .format(pysam_libdir, os.path.join(self.workdir, "tests"))))
Beispiel #3
0
    def test_package_tests_pass_if_ld_library_path_set(self):

        pysam_libraries = pysam.get_libraries()
        pysam_libdirs, pysam_libs = zip(
            *[os.path.split(x) for x in pysam_libraries])
        pysam_libdir = pysam_libdirs[0]

        self.assertTrue(check_pass(
            "export LD_LIBRARY_PATH={}:$PATH && cd {} && python test_module.py".format(
                pysam_libdir,
                os.path.join(self.workdir, "tests"))))
Beispiel #4
0
License :: OSI Approved
Programming Language :: Python
Topic :: Software Development
Topic :: Scientific/Engineering
Operating System :: POSIX
Operating System :: Unix
Operating System :: MacOS
"""

##########################################################
# Cython Extensions
conda_includes = [os.path.dirname(sysconfig.get_paths()["include"])]
conda_libdirs = [os.path.dirname(sysconfig.get_paths()["stdlib"])]

# Connected components cython extension
pysam_libraries = pysam.get_libraries()
pysam_libdirs = list(set(os.path.dirname(x)
                         for x in pysam_libraries)) + conda_libdirs

# remove lib and .so and add htslib
pysam_libs = ["hts"] + list(
    [os.path.basename(x)[3:-3] for x in pysam_libraries])

pysam_dirname = os.path.dirname(pysam.__file__)
if IS_OSX:
    # linking against bundles does no work (and apparently is not needed)
    # within OS X
    extra_link_args = []
else:
    extra_link_args = [
        os.path.join(pysam_dirname, x) for x in pysam.get_libraries()
Beispiel #5
0
import os
import glob
import numpy
from setuptools import setup, Extension
import pysam

src_list = glob.glob("src/*.c")
pyx_list = glob.glob("dnaUtilsPy/*.pyx")
include_dirs = pysam.get_include() + ["src", numpy.get_include()]
extra_link_args = pysam.get_libraries()

extensions = []
for pyx in pyx_list:
    assert pyx.endswith(".pyx")
    submodule = os.path.basename(pyx)[:-len(".pyx")]
    extensions.append(
        Extension("dnaUtilsPy." + submodule,
                  sources=[pyx] + src_list,
                  include_dirs=include_dirs,
                  extra_link_args=extra_link_args))

setup(name="dnaUtilsPy",
      packages=["dnaUtilsPy"],
      ext_modules=extensions,
      install_requires=['numpy', 'pysam'],
      setup_requires=['numpy', 'pysam', 'cython'])
Beispiel #6
0
import glob
import sys
import os

from setuptools import setup, find_packages, Extension
from Cython.Distutils import build_ext

import pysam

test_module_suffix = os.path.dirname(os.path.abspath(__file__)).split(
    os.sep)[-1]
test_module_name = "PysamTestModule_{}".format(test_module_suffix)

pysam_libraries = pysam.get_libraries()
pysam_libdirs, pysam_libs = zip(*[os.path.split(x) for x in pysam_libraries])
pysam_libdir = pysam_libdirs[0]
# remove lib and .so
pysam_libs = [x[3:-3] for x in pysam_libs]

TestModule = Extension(
    "{}.BuildRead".format(test_module_name),
    ["{}/BuildRead.pyx".format(test_module_name)],
    include_dirs=pysam.get_include(),
    library_dirs=[pysam_libdir],
    libraries=pysam_libs,
    language="C",
)

setup(
    name=test_module_name,
    version='0.1',
Beispiel #7
0
              language="c++",
              extra_compile_args=compile_options,
              extra_link_args=link_options),
    # Extension("epic2.src.differential",
    #           ["epic2/src/differential.pyx"], language="c++",
    #           extra_compile_args=compile_options),
    Extension("epic2.src.find_islands", ["epic2/src/find_islands.pyx"],
              language="c++",
              extra_compile_args=compile_options,
              extra_link_args=link_options),
    Extension("epic2.src.read_bam", ["epic2/src/read_bam.pyx"],
              language="c++",
              include_dirs=conda_include + pysam.get_include(),
              library_dirs=conda_lib,
              extra_compile_args=compile_options,
              extra_link_args=link_options + pysam.get_libraries(),
              define_macros=pysam.get_defines(),
              libraries=["z"]),
    Extension("epic2.src.genome_info", ["epic2/src/genome_info.pyx"],
              language="c++",
              extra_compile_args=compile_options,
              extra_link_args=link_options)
]

setup(
    name="epic2",
    packages=find_packages(),
    ext_modules=cythonize(extensions, annotate=True, language_level='2'),
    scripts=["bin/epic2", "bin/epic2-df", "bin/epic2-bw"],
    package_data={
        'epic2': [
Beispiel #8
0
    language="c",
)

# automatically build pyximport script extensions
pyx_files = glob.glob("scripts/*.pyx")
script_extensions = []
pysam_dirname = os.path.dirname(pysam.__file__)
include_dirs = [numpy.get_include()] + pysam.get_include()

if IS_OSX:
    # linking against bundles does no work (and apparently is not needed)
    # within OS X
    extra_link_args = []
else:
    extra_link_args = [os.path.join(pysam_dirname, x) for x in 
                       pysam.get_libraries()]

for pyx_file in pyx_files:
    script_name = os.path.basename(pyx_file)
    script_prefix = script_name[:-4]
    script_extensions.append(
        Extension("CGAT.%s" % (script_prefix),
                  sources=[pyx_file],
                  extra_link_args=extra_link_args,
                  include_dirs=include_dirs,
                  define_macros=pysam.get_defines())
    )


ext_modules = [Components, NCL, Timeseries] + script_extensions
Beispiel #9
0
import glob
import sys
import os

from setuptools import setup, find_packages, Extension
from cy_build import CyExtension as Extension, cy_build_ext as build_ext

import pysam

test_module_suffix = os.path.dirname(os.path.abspath(__file__)).split(os.sep)[-1]
test_module_name = "PysamTestModule_{}".format(test_module_suffix)

TestModule = Extension(
    "{}.BuildRead".format(test_module_name),
    ["{}/BuildRead.pyx".format(test_module_name)],
    include_dirs=pysam.get_include(),
    extra_link_args=pysam.get_libraries(),
    define_macros=pysam.get_defines(),
)

setup(
    name=test_module_name,
    version='0.1',
    packages=find_packages(),
    package_dir={test_module_name: test_module_name},
    ext_modules=[TestModule],
    cmdclass={'build_ext': build_ext},
)
Beispiel #10
0
import glob
import sys
import os

from setuptools import setup, find_packages, Extension
from Cython.Distutils import build_ext

import pysam

test_module_suffix = os.path.dirname(os.path.abspath(__file__)).split(os.sep)[-1]
test_module_name = "PysamTestModule_{}".format(test_module_suffix)

pysam_libraries = pysam.get_libraries()
pysam_libdirs, pysam_libs = zip(*[os.path.split(x) for x in pysam_libraries])
pysam_libdir = pysam_libdirs[0]
# remove lib and .so
pysam_libs = [x[3:-3] for x in pysam_libs]

TestModule = Extension(
    "{}.BuildRead".format(test_module_name),
    ["{}/BuildRead.pyx".format(test_module_name)],
    include_dirs=pysam.get_include(),
    library_dirs=[pysam_libdir],
    libraries=pysam_libs,
    language="C",
)

setup(
    name=test_module_name,
    version='0.1',
    packages=find_packages(),