-
Notifications
You must be signed in to change notification settings - Fork 23
/
setup.py
148 lines (123 loc) · 4.41 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import os
import sys
import glob
import tarfile
import zipfile
import urllib.request
from setuptools import setup, Extension
root_dir = os.path.dirname(os.path.abspath(__file__))
sources = glob.glob(os.path.join(root_dir, 'src', '*.c'))
link_args = []
comp_args = []
include_dirs = []
def prepare_zlib():
global include_dirs
global sources
zlib_dir = os.path.join(root_dir, "zlib-1.2.13")
zlib_file = os.path.join(root_dir, "zlib-1.2.13.zip")
url = "https://github.com/madler/zlib/releases/download/v1.2.13/zlib1213.zip"
if not os.path.exists(zlib_dir):
urllib.request.urlretrieve(url, zlib_file)
with zipfile.ZipFile(zlib_file) as _zip:
_zip.extractall()
include_dirs.append(zlib_dir)
sources.extend(glob.glob(os.path.join(zlib_dir, '*.c')))
def prepare_sqlite3():
global include_dirs
global sources
sqlite_dir = os.path.join(root_dir, "sqlite-amalgamation-3400100")
sqlite_file = os.path.join(root_dir, "sqlite-amalgamation-3400100.zip")
url = "https://www.sqlite.org/2022/sqlite-amalgamation-3400100.zip"
if not os.path.exists(sqlite_dir):
urllib.request.urlretrieve(url, sqlite_file)
with zipfile.ZipFile(sqlite_file) as _zip:
_zip.extractall()
include_dirs.append(sqlite_dir)
sources.append(os.path.join(sqlite_dir, 'sqlite3.c'))
def prepare_indexed_gzip():
global include_dirs
global sources
igzip_dir = os.path.join(root_dir, "indexed_gzip-1.7.0", "indexed_gzip")
igzip_file = os.path.join(root_dir, "indexed_gzip-1.7.0.zip")
url = "https://github.com/pauldmccarthy/indexed_gzip/archive/refs/tags/v1.7.0.zip"
if not os.path.exists(igzip_dir):
urllib.request.urlretrieve(url, igzip_file)
with zipfile.ZipFile(igzip_file) as _zip:
_zip.extractall()
include_dirs.append(igzip_dir)
sources.extend(glob.glob(os.path.join(igzip_dir, 'zran*.c')))
if sys.platform.startswith('win'):
comp_args.extend([
'/D_LFS64_LARGEFILE',
'/D_LARGEFILE64_SOURCE',
'/D_FILE_OFFSET_BITS=64'
])
else:
comp_args.extend([
'-Wno-unused-result',
'-D_FILE_OFFSET_BITS=64'
])
if sys.platform.startswith('linux'):
link_args.extend(['-lsqlite3'])
comp_args.extend([
'-D_LFS64_LARGEFILE',
'-D_LARGEFILE64_SOURCE',
])
elif sys.platform.startswith('darwin'):
comp_args.append('-DHAVE_UNISTD_H')
if not sys.platform.startswith('linux'):
prepare_sqlite3()
prepare_zlib()
prepare_indexed_gzip()
extension = Extension('pyfastx',
sources = sources,
include_dirs = include_dirs,
extra_compile_args = comp_args,
extra_link_args = link_args
)
description = (
"pyfastx is a python module for fast random "
"access to sequences from plain and gzipped "
"FASTA/Q file"
)
with open(os.path.join(root_dir, 'README.rst')) as fh:
long_description = fh.read()
with open(os.path.join(root_dir, 'src', 'version.h')) as fh:
version = fh.read().split()[2].strip('"')
setup(
name = 'pyfastx',
version = version,
ext_modules = [extension],
description = description,
long_description = long_description,
#long_description_content_type = 'text/x-rst',
author = 'Lianming Du',
author_email = '[email protected]',
url = 'https://github.com/lmdu/pyfastx',
license = 'MIT',
keywords = 'fasta fastq sequence bioinformatics',
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"Natural Language :: English",
"License :: OSI Approved :: MIT License",
"Programming Language :: C",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: Unix",
"Topic :: Scientific/Engineering :: Bio-Informatics"
],
entry_points = {
'console_scripts': ['pyfastx = pyfastxcli:main']
},
py_modules = ["pyfastxcli"],
test_suite = "tests"
)