Imported Upstream version 0.2
[pysam.git] / setup.py
1 #!/usr/bin/python
2 '''
3
4 pysam
5 *****
6
7 '''
8
9 import os, sys, glob, shutil
10
11 name = "pysam"
12 version = "0.2"
13
14 samtools_exclude = ( "bamtk.c", "razip.c", "bgzip.c" )
15 samtools_dest = os.path.abspath( "samtools" )
16
17 # copy samtools source
18 if len(sys.argv) >= 2 and sys.argv[1] == "import":
19    if len(sys.argv) < 3: raise ValueError("missing PATH to samtools source directory")
20    samtools_src = os.path.abspath( sys.argv[2] )
21    if not os.path.exists( samtools_src ): raise IOError( "samtools src dir `%s` does not exist." % samtools_src )
22
23    cfiles = glob.glob( os.path.join( samtools_src, "*.c" ) )
24    hfiles = glob.glob( os.path.join( samtools_src, "*.h" ) )
25    ncopied = 0
26    for p in cfiles + hfiles:
27       f = os.path.basename(p)
28       if f in samtools_exclude: continue
29       if os.path.exists( os.path.join( samtools_dest, f )): continue
30       shutil.copy( p, samtools_dest )
31       ncopied += 1
32    print "installed latest source code from %s: %i files copied" % (samtools_src, ncopied)
33    sys.exit(0)
34
35 from distutils.core import setup, Extension
36 from Pyrex.Distutils import build_ext
37
38 classifiers = """
39 Development Status :: 2 - Alpha
40 Operating System :: MacOS :: MacOS X
41 Operating System :: Microsoft :: Windows :: Windows NT/2000
42 Operating System :: OS Independent
43 Operating System :: POSIX
44 Operating System :: POSIX :: Linux
45 Operating System :: Unix
46 Programming Language :: Python
47 Topic :: Scientific/Engineering
48 Topic :: Scientific/Engineering :: Bioinformatics
49 """
50
51 pysam = Extension(
52     "pysam/csamtools",                   # name of extension
53     [ "pysam/csamtools.pyx" ]  +\
54        [ "pysam/%s" % x for x in (
55              "pysam_util.c", )] +\
56        glob.glob( os.path.join( "samtools", "*.c" ) ),
57     library_dirs=[],
58     include_dirs=[ "samtools", ],
59     libraries=[ "z", ],
60     language="c",
61     )
62
63 metadata = {
64     'name': name,
65     'version': version,
66     'description': "pysam", 
67     'long_description': __doc__,
68     'author': "Andreas Heger",
69     'author_email': "andreas.heger@gmail.com",
70     'license': "MIT",
71     'platforms': "ALL",
72     'url': "http://code.google.com/p/pysam/",
73     'py_modules': [
74       "pysam/__init__", "pysam/Pileup", "pysam/namedtuple" ],
75     'ext_modules': [pysam,],
76     'cmdclass' : {'build_ext': build_ext} }
77
78 if __name__=='__main__':
79    dist = setup(**metadata)