setup.py 3.94 KB
Newer Older
1 2
import glob
import os
3
import sys
4 5 6 7 8 9 10 11 12 13 14 15 16
import re
import subprocess

from distutils.core import setup,Extension
from distutils.sysconfig import get_python_lib
from Cython.Build import cythonize

import os.path
from distutils import log
from distutils.extension import Extension

sys.path.append(os.path.abspath("python"))

17 18
dependencies = ['sphinx',"Cython"]

19 20 21 22 23 24 25 26 27 28 29

def findPackage(root,base=None):
    modules=[]
    if base is None:
        base=[]
    for module in (os.path.basename(os.path.dirname(x)) 
                   for x in glob.glob(os.path.join(root,'*','__init__.py'))):
        modules.append('.'.join(base+[module]))
        modules.extend(findPackage(os.path.join(root,module),base+[module]))
    return modules

30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
def RunMake():
    try:
        os.mkdir("build")
    except OSError:
        pass
    try:
        os.mkdir("build/cobject")
    except OSError:
        pass
    
    oldwd = os.getcwd()
    os.chdir("build/cobject")
    install_clibdir_option="-DPYTHONLIB:STRING='%s'" % get_python_lib()
    subprocess.call(['cmake', install_clibdir_option, '../../src'])
    subprocess.call(['make','install'])   # temporary fix but should be in src
    os.chdir(oldwd)
    
47 48 49 50

PACKAGE     = "OBITools3"
VERSION     = "0.0.0"
AUTHOR      = 'Eric Coissac'
51 52 53 54
EMAIL       = 'eric@metabarcoding.org'
URL         = "metabarcoding.org/obitools3"
LICENSE     = "CeCILL-V2"
DESCRIPTION = "Tools and library for DNA metabarcoding",
Eric Coissac committed
55
PYTHONMIN   = '3.7'
56 57 58 59

SRC       = 'python'
CSRC      = 'src'

60 61 62 63 64 65 66 67
REQUIRES  = ['Cython>=0.24',
             'Sphinx>=1.2.0',
             'ipython>=3.0.0',
             'breathe>=4.0.0'
            ]

os.environ['CFLAGS'] = '-O3 -Wall -I "src" -I "src/libecoPCR" -I "src/libjson"'

68 69

RunMake()
70 71 72 73 74

cython_src  = [x for x in glob.iglob('python/obitools3/**/*.pyx', 
                                     recursive=True
                                    )
              ]
75
      
76 77 78
#with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:
#    readme = f.read()
    
79 80 81

cython_ext  = [Extension('.'.join([os.path.dirname(x).replace("python/",""),
                                   os.path.splitext(os.path.basename(x))[0]]).replace('/','.'),
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
                         [x],
                         library_dirs=[get_python_lib()],
                         include_dirs=["src","src/libecoPCR","src/libjson"],
                         libraries=["cobitools3"],
                         runtime_library_dirs=[get_python_lib()],
                         extra_compile_args=['-msse2',
                                          '-Wno-unused-function',
                                          '-Wmissing-braces',
                                          '-Wchar-subscripts',
                                          '-fPIC'
                                         ],
                         extra_link_args=["-Wl,-rpath,"+get_python_lib(), 
                                          "-L"+get_python_lib()
                                         ]
                        )
                for x in cython_src
              ]              

xx = cythonize(cython_ext,
               language_level=3,
102 103
               annotate=True,
               build_dir="build")
104 105 106

#,              include_path=["src","src/libecoPCR","src/libjson"]

107 108 109 110 111 112
classifiers=['Development Status :: 1 - Planning',
             'Environment :: Console',
             'Intended Audience :: Science/Research',
             'License :: Other/Proprietary License',
             'Operating System :: Unix',
             'Programming Language :: Python :: 3',
113
             'Programming Language :: C',
114 115 116 117
             'Topic :: Scientific/Engineering :: Bio-Informatics',
             'Topic :: Utilities',
             ]

118 119 120 121 122 123 124 125 126 127 128
setup(name=PACKAGE,
      description=DESCRIPTION,
      classifiers=classifiers,
      version=VERSION,
      author=AUTHOR,
      author_email=EMAIL,
      license=LICENSE,
      url=URL,
      ext_modules=xx,
      packages = findPackage('python'),
      package_dir = {"" : "python"},
129
      scripts = ['scripts/obi']
130
)
131