First version of the simplified setup.py script
This commit is contained in:
165
setup.py
165
setup.py
@ -1,87 +1,122 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
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"))
|
||||
|
||||
print(sys.path)
|
||||
|
||||
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 = "0.0.0"
|
||||
AUTHOR = 'Eric Coissac'
|
||||
EMAIL = 'eric@coissac.eu'
|
||||
URL = 'metabarcoding.org/obitools3'
|
||||
LICENSE = 'CeCILL-V2'
|
||||
DESCRIPTION ="Scripts and library for DNA metabarcoding",
|
||||
EMAIL = 'eric@metabarcoding.org'
|
||||
URL = "metabarcoding.org/obitools3"
|
||||
LICENSE = "CeCILL-V2"
|
||||
DESCRIPTION = "Tools and library for DNA metabarcoding",
|
||||
PYTHONMIN = '3.6'
|
||||
|
||||
SRC = 'python'
|
||||
CSRC = 'src'
|
||||
|
||||
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"'
|
||||
|
||||
#sys.path.append("/Users/coissac/git/obitools3/python")
|
||||
|
||||
cython_src = [x for x in glob.iglob('python/obitools3/**/*.pyx',
|
||||
recursive=True
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
|
||||
#with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:
|
||||
# readme = f.read()
|
||||
|
||||
install_clibdir_option="-DPYTHONLIB:STRING='%s'" % get_python_lib()
|
||||
|
||||
subprocess.call(['cmake', install_clibdir_option, 'src'])
|
||||
subprocess.call(['make', '-C', 'src','install'])
|
||||
|
||||
|
||||
cython_ext = [Extension('.'.join(["obitools3",
|
||||
os.path.basename(os.path.dirname(x)),
|
||||
os.path.splitext(os.path.basename(x))[0]]),
|
||||
[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,
|
||||
annotate=True)
|
||||
|
||||
#, include_path=["src","src/libecoPCR","src/libjson"]
|
||||
|
||||
classifiers=['Development Status :: 1 - Planning',
|
||||
'Environment :: Console',
|
||||
'Intended Audience :: Science/Research',
|
||||
'License :: Other/Proprietary License',
|
||||
'Operating System :: Unix',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: C',
|
||||
'Topic :: Scientific/Engineering :: Bio-Informatics',
|
||||
'Topic :: Utilities',
|
||||
]
|
||||
|
||||
|
||||
PYTHONMIN='3.4'
|
||||
|
||||
|
||||
sys.path.append('distutils.ext')
|
||||
sys.path.append(SRC)
|
||||
|
||||
if __name__=="__main__":
|
||||
|
||||
import sys
|
||||
|
||||
print("----------------")
|
||||
print(" ".join(sys.argv))
|
||||
print("----------------")
|
||||
|
||||
#
|
||||
# Horrible hack
|
||||
#
|
||||
|
||||
if sys.argv[0]=="-c":
|
||||
sys.argv[0]="setup.py"
|
||||
|
||||
#
|
||||
# End of the horrible hack
|
||||
#
|
||||
|
||||
|
||||
|
||||
try:
|
||||
from obitools3 import version
|
||||
VERSION = version.version
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from obidistutils.serenity import serenity_mode
|
||||
|
||||
serenity=serenity_mode(PACKAGE,VERSION)
|
||||
|
||||
from obidistutils.core import setup
|
||||
from obidistutils.core import CTOOLS
|
||||
from obidistutils.core import CEXES
|
||||
from obidistutils.core import FILES
|
||||
|
||||
# Produce annotated html files
|
||||
import Cython.Compiler.Options
|
||||
Cython.Compiler.Options.annotate = True
|
||||
|
||||
|
||||
setup(name=PACKAGE,
|
||||
description=DESCRIPTION,
|
||||
classifiers=classifiers,
|
||||
version=VERSION,
|
||||
author=AUTHOR,
|
||||
author_email=EMAIL,
|
||||
license=LICENSE,
|
||||
url=URL,
|
||||
python_src=SRC,
|
||||
sse='sse2',
|
||||
serenity=serenity,
|
||||
pythonmin=PYTHONMIN)
|
||||
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"},
|
||||
scripts = ['python/obi.py']
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user