forked from amcdavid/PySnpTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
134 lines (118 loc) · 5.17 KB
/
setup.py
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
import platform
import os
import sys
import shutil
from setuptools import setup, Extension
from distutils.command.clean import clean as Clean
import numpy
# Version number
version = '0.3.13'
def readme():
with open('README.md') as f:
return f.read()
try:
from Cython.Distutils import build_ext
except ImportError:
use_cython = False
else:
use_cython = True
#use_cython=False
class CleanCommand(Clean):
description = "Remove build directories, and compiled files (including .pyc)"
def run(self):
Clean.run(self)
if os.path.exists('build'):
shutil.rmtree('build')
for dirpath, dirnames, filenames in os.walk('.'):
for filename in filenames:
if ( filename.endswith('.so')
or filename.endswith('.pyd')
#or filename.find("wrap_plink_parser.cpp") != -1 # remove automatically generated source file
#or filename.find("wrap_matrix_subset.cpp") != -1 # remove automatically generated source file
or filename.endswith('.pyc')
):
tmp_fn = os.path.join(dirpath, filename)
print "removing", tmp_fn
os.unlink(tmp_fn)
# set up macro
if platform.system() == "Darwin":
macros = [("__APPLE__", "1")]
elif "win" in platform.system().lower():
macros = [("_WIN32", "1")]
else:
macros = [("_UNIX", "1")]
#see http://stackoverflow.com/questions/4505747/how-should-i-structure-a-python-package-that-contains-cython-code
if use_cython:
ext_modules = [Extension(name="pysnptools.snpreader.wrap_plink_parser",
language="c++",
sources=["pysnptools/snpreader/wrap_plink_parser.pyx", "pysnptools/snpreader/CPlinkBedFile.cpp"],
include_dirs = [numpy.get_include()],
define_macros=macros),
Extension(name="pysnptools.snpreader.wrap_matrix_subset",
language="c++",
sources=["pysnptools/snpreader/wrap_matrix_subset.pyx", "pysnptools/snpreader/MatrixSubset.cpp"],
include_dirs = [numpy.get_include()],
define_macros=macros)]
cmdclass = {'build_ext': build_ext, 'clean': CleanCommand}
else:
ext_modules = [Extension(name="pysnptools.snpreader.wrap_plink_parser",
language="c++",
sources=["pysnptools/snpreader/wrap_plink_parser.cpp", "pysnptools/snpreader/CPlinkBedFile.cpp"],
include_dirs = [numpy.get_include()],
define_macros=macros),
Extension(name="pysnptools.snpreader.wrap_matrix_subset",
language="c++",
sources=["pysnptools/snpreader/wrap_matrix_subset.cpp", "pysnptools/snpreader/MatrixSubset.cpp"],
include_dirs = [numpy.get_include()],
define_macros=macros)]
cmdclass = {}
class CleanCommand(Clean):
description = "Remove build directories, and compiled files (including .pyc)"
def run(self):
Clean.run(self)
if os.path.exists('build'):
shutil.rmtree('build')
for dirpath, dirnames, filenames in os.walk('.'):
for filename in filenames:
if ( filename.endswith('.so')
or filename.endswith('.pyd')
or filename.find("wrap_plink_parser.cpp") != -1 # remove automatically generated source file
or filename.find("wrap_matrix_subset.cpp") != -1 # remove automatically generated source file
or filename.endswith('.pyc')
):
tmp_fn = os.path.join(dirpath, filename)
print "removing", tmp_fn
os.unlink(tmp_fn)
#python setup.py sdist bdist_wininst upload
setup(
name='pysnptools',
version=version,
description='PySnpTools',
long_description=readme(),
keywords='gwas bioinformatics sets intervals ranges regions',
url="http://research.microsoft.com/en-us/um/redmond/projects/mscompbio/",
author='MSR',
author_email='[email protected]',
license='Apache 2.0',
packages=[
"pysnptools/snpreader",
"pysnptools/kernelreader",
"pysnptools/pstreader",
"pysnptools/standardizer",
"pysnptools/kernelstandardizer",
"pysnptools/util",
"pysnptools"
],
package_data={"pysnptools" : [
"test/datasets/all_chr.maf0.001.N300.bed",
"test/datasets/all_chr.maf0.001.N300.bim",
"test/datasets/all_chr.maf0.001.N300.fam",
"test/datasets/phenSynthFrom22.23.N300.randcidorder.txt",
"tests/datasets/all_chr.maf0.001.covariates.N300.txt"
]
},
install_requires = ['scipy>=0.15.1', 'numpy>=1.9.2', 'pandas>=0.16.2'],
# extensions
cmdclass = cmdclass,
ext_modules = ext_modules
)