File: setup.py

package info (click to toggle)
obitools 3.0.1~b26%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,788 kB
  • sloc: ansic: 24,299; python: 657; sh: 27; makefile: 20
file content (178 lines) | stat: -rwxr-xr-x 5,445 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import glob
import os
import sys
import re
import subprocess

from distutils import log
#from distutils.core import setup
from setuptools import setup    # to work with pip

from distutils.core import Extension
from distutils.sysconfig import get_python_lib

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

from distutils.dist import Distribution as ori_Distribution

from python.obitools3.version import version


class Distribution(ori_Distribution):
    
    def __init__(self,attrs=None):
        self.cobitools3=attrs['cobitools3']
        
        ori_Distribution.__init__(self, attrs)
        
        self.global_options.insert(0,('cobitools3', None, "install location of the C library"
                                     ))

from distutils.command.build import build as build_ori
from setuptools.command.bdist_egg import bdist_egg as bdist_egg_ori
from distutils.core import Command


class build_clib(Command):
    user_options=[]
    
    def initialize_options(self):
        self.clib_dir=self.distribution.cobitools3
    
    def finalize_options(self):
        if self.clib_dir is None:
            self.clib_dir=get_python_lib()
    
    def run(self):
        log.info("Build the build/cobject directory")
        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'" % oldwd
        log.info("Run CMake")
        subprocess.call(['cmake', install_clibdir_option, "-DCMAKE_BUILD_TYPE=None", "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON", "-DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF", "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON", "-DFETCHCONTENT_FULLY_DISCONNECTED=ON", "-GUnix Makefiles", "-DCMAKE_VERBOSE_MAKEFILE=ON", '../../src'])
        log.info("Compile the shared C library")
        subprocess.call(['make','install'])   # temporary fix but should be in src
        os.chdir(oldwd)


class build(build_ori):
    def run(self):
        self.run_command("build_clib")
        build_ori.run(self)


class bdist_egg(bdist_egg_ori):
    def run(self):
        self.run_command('build_clib')
        bdist_egg_ori.run(self)


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


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
  

PACKAGE     = "OBITools3"
VERSION     = version
AUTHOR      = 'Celine Mercier'
EMAIL       = 'celine.mercier@metabarcoding.org'
URL         = "https://metabarcoding.org/obitools3"
PLATFORMS   = "posix"
LICENSE     = "CeCILL-V2"
DESCRIPTION = "A package for the management of analyses and data in DNA metabarcoding."
PYTHONMIN   = '3.5'

SRC       = 'python'
CSRC      = 'src'

REQUIRES  = ['Cython>=0.24',
             'Sphinx>=1.2.0',
             'ipython>=3.0.0',
             'breathe>=4.0.0'
            ]

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


from Cython.Build import cythonize

cython_src  = [x for x in glob.iglob('python/obitools3/**/*.pyx', 
                                     recursive=True
                                    )
              ]
      

cython_ext  = [Extension('.'.join([os.path.dirname(x).replace("python/",""),
                                   os.path.splitext(os.path.basename(x))[0]]).replace('/','.'),
                         [x],
                         library_dirs=[get_python_lib(), os.getcwd()],
                         include_dirs=["src","src/libecoPCR","src/libjson"],
                         libraries=["cobitools3"],
                         extra_compile_args=['-w',
                                          '-fPIC'
                                         ],
                        )
                for x in cython_src
              ]              

xx = cythonize(cython_ext,
               language_level=3,
               annotate=True,
               build_dir="build")

classifiers=['Development Status :: 4 - Beta',
             'Environment :: Console',
             'Intended Audience :: Science/Research',
             'License :: Other/Proprietary License',
             'Operating System :: Unix',
             'Programming Language :: Python :: 3',
             'Programming Language :: C',
             'Topic :: Scientific/Engineering :: Bio-Informatics',
             'Topic :: Utilities',
             ]

with open("README.md", "r") as fh:
    long_description = fh.read()

setup(name=PACKAGE,
      description=DESCRIPTION,
      long_description=long_description,
      long_description_content_type="text/markdown",
      classifiers=classifiers,
      version=VERSION,
      author=AUTHOR,
      author_email=EMAIL,
      platforms=PLATFORMS,
      license=LICENSE,
      url=URL,
      ext_modules=xx,
      distclass=Distribution,
      cmdclass={'build': build,
                'bdist_egg': bdist_egg,
                'build_clib': build_clib},
      cobitools3=get_python_lib(),
      packages = findPackage('python'),
      package_dir = {"" : "python"},
      scripts = ['scripts/obi']
)