Commit d1e47321 by Eric Coissac

New version of setup.py script taking into account pyrex file and corresponding…

New version of setup.py script taking into account pyrex file and corresponding c file generation in the source directory
parent ef46d424
#! /usr/bin/env python
from distutils.core import setup
from distutils.extension import Extension
try:
from Cython.Distutils import build_ext
from Cython.Compiler import Main
has_cython=True
except ImportError:
from distutils.cmd.Command import build_ext
has_cython=False
import re, sys
import glob
......@@ -16,17 +26,54 @@ def findPackage(root,base=None):
modules.extend(findPackage(path.join(root,module),base+[module]))
return modules
def findCython(root,base=None,pyrexs=None):
modules=[]
pyrexs=[]
#o=dict(Main.default_options)
pyopt=Main.CompilationOptions(Main.default_options)
Main.__dict__['context'] = Main.Context(pyopt.include_path, pyopt.pragma_overrides)
if base is None:
base=[]
for module in (path.basename(path.dirname(x))
for x in glob.glob(path.join(root,'*','__init__.py'))):
for pyrex in glob.glob(path.join(root,module,'*.pyx')):
pyrexs.append(Extension('.'.join(base+[module,path.splitext(path.basename(pyrex))[0]]),[pyrex]))
Main.compile([pyrex],timestamps=True,recursion=True)
pyrexs.extend(findCython(path.join(root,module),base+[module]))
return pyrexs
def findC(root,base=None,pyrexs=None):
modules=[]
pyrexs=[]
if base is None:
base=[]
for module in (path.basename(path.dirname(x))
for x in glob.glob(path.join(root,'*','__init__.py'))):
for pyrex in glob.glob(path.join(root,module,'*.c')):
pyrexs.append(Extension('.'.join(base+[module,path.splitext(path.basename(pyrex))[0]]),[pyrex]))
pyrexs.extend(findCython(path.join(root,module),base+[module]))
return pyrexs
VERSION = '0.1.0'
VERSION = '0.1.1'
AUTHOR = 'Eric Coissac'
EMAIL = 'eric.coissac@inrialpes.fr'
URL = 'www.grenoble.prabi.fr/trac/OBITools'
EMAIL = 'eric@coissac.eu'
URL = 'www.grenoble.prabi.fr/trac/OBITools'
LICENSE = 'CeCILL-V2'
SRC = 'src'
SCRIPTS = glob.glob('%s/*.py' % SRC)
if has_cython:
EXTENTION=findCython(SRC)
else:
EXTENTION=findC(SRC)
#SCRIPTS.append('src/fastaComplement')
setup(name="OBITools",
......@@ -38,5 +85,7 @@ setup(name="OBITools",
url=URL,
scripts=SCRIPTS,
package_dir = {'': SRC},
packages=findPackage(SRC))
packages=findPackage(SRC),
cmdclass = {'build_ext': build_ext},
ext_modules=EXTENTION)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment