X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=pysam.git;a=blobdiff_plain;f=setup.py;h=979b9369ae38d0aa49a7e8f98aad08dc75c43baa;hp=4f9b15a8dfa6e3b46ffa3141fc9fd7b0a9d7d305;hb=HEAD;hpb=d02fe5283ed7a93a2f76a5d6dc6e37b40c11b9b1 diff --git a/setup.py b/setup.py index 4f9b15a..979b936 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,6 @@ import version version = version.__version__ samtools_exclude = ( "bamtk.c", "razip.c", "bgzip.c", - "bam_reheader.c", "main.c", "calDepth.c", "bam2bed.c", "wgsim.c", "md5fa.c", "maq2sam.c",) samtools_dest = os.path.abspath( "samtools" ) @@ -33,15 +32,16 @@ def locate(pattern, root=os.curdir): yield os.path.join(path, filename) def _update_pysam_files(cf, destdir): - for filename in cf: - if not filename: continue - dest = filename + ".pysam.c" - with open( filename ) as infile: - with open( dest, "w" ) as outfile: - outfile.write( '#include "pysam.h"\n\n' ) - outfile.write( re.sub( "stderr", "pysamerr", "".join(infile.readlines()) ) ) - with open( os.path.join( destdir, "pysam.h" ), "w" )as outfile: - outfile.write ("""#ifndef PYSAM_H + '''update pysam files applying redirection of ouput''' + for filename in cf: + if not filename: continue + dest = filename + ".pysam.c" + with open( filename ) as infile: + with open( dest, "w" ) as outfile: + outfile.write( '#include "pysam.h"\n\n' ) + outfile.write( re.sub( "stderr", "pysamerr", "".join(infile.readlines()) ) ) + with open( os.path.join( destdir, "pysam.h" ), "w" )as outfile: + outfile.write ("""#ifndef PYSAM_H #define PYSAM_H #include "stdio.h" extern FILE * pysamerr; @@ -93,9 +93,9 @@ if len(sys.argv) >= 2 and sys.argv[1] == "import": cf.append( _compareAndCopy( src_file, srcdir, destdir, exclude ) ) ncopied += 1 - print "installed latest source code from %s: %i files copied" % (srcdir, ncopied) + sys.stdout.write("installed latest source code from %s: %i files copied" % (srcdir, ncopied)) # redirect stderr to pysamerr and replace bam.h with a stub. - print "applying stderr redirection" + sys.stdout.write("applying stderr redirection") _update_pysam_files(cf, destdir) @@ -103,9 +103,9 @@ if len(sys.argv) >= 2 and sys.argv[1] == "import": sys.exit(0) if len(sys.argv) >= 2 and sys.argv[1] == "refresh": - print "refreshing latest source code from .c to .pysam.c" + sys.stdout.write("refreshing latest source code from .c to .pysam.c") # redirect stderr to pysamerr and replace bam.h with a stub. - print "applying stderr redirection" + sys.stdout.write("applying stderr redirection") for destdir in ('samtools', 'tabix'): pysamcfiles = locate( "*.pysam.c", destdir ) for f in pysamcfiles: os.remove(f) @@ -116,19 +116,11 @@ if len(sys.argv) >= 2 and sys.argv[1] == "refresh": -from ez_setup import use_setuptools +from distribute_setup import use_setuptools use_setuptools() from setuptools import Extension, setup - -## note that for automatic cythoning, -## both pyrex and cython need to be installed. -## see http://mail.python.org/pipermail/distutils-sig/2007-September/008204.html - -try: - from Cython.Distutils import build_ext -except: - from setuptools.command.build_ext import build_ext +from Cython.Distutils import build_ext classifiers = """ Development Status :: 2 - Alpha @@ -176,6 +168,8 @@ tabix = Extension( include_dirs=[ "tabix", "pysam" ] + include_os, libraries=[ "z", ], language="c", + define_macros = [('_FILE_OFFSET_BITS','64'), + ('_USE_KNETFILE','')], ) tabproxies = Extension( @@ -209,15 +203,19 @@ metadata = { 'py_modules': [ "pysam/__init__", "pysam/Pileup", - "pysam/namedtuple", "pysam/version" ], - 'requires' : ['cython (>=0.12)'], + # cython larger that 0.16 for yield support + 'requires' : ['cython (>=0.16)'], 'ext_modules': [samtools, tabix, tabproxies, cvcf ], 'cmdclass' : {'build_ext': build_ext}, 'install_requires' : ['cython>=0.12.1',], # do not pack in order to permit linking to csamtools.so 'zip_safe' :False, + 'use_2to3': True, } +if sys.version_info[0] < 3: + metadata['py_modules'].append("pysam/namedtuple") + if __name__=='__main__': dist = setup(**metadata)