-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
112 lines (97 loc) · 3.76 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
#!/usr/bin/env python
import os, subprocess, sys
from distutils.command.build_ext import build_ext
from distutils.sysconfig import get_config_var
from distutils.version import LooseVersion
from setuptools import Extension, setup
import numpy
import platform
long_description = """
libgetar is a library to read and write GEneric Trajectory ARchives, a
binary data format designed for efficient, extensible storage of
trajectory data.
For more details, consult the documentation at https://libgetar.readthedocs.io .
"""
# From https://github.com/pandas-dev/pandas/pull/24274:
# For mac, ensure extensions are built for macos 10.9 when compiling on a
# 10.9 system or above, overriding distuitls behaviour which is to target
# the version that python was built for. This may be overridden by setting
# MACOSX_DEPLOYMENT_TARGET before calling setup.py
if sys.platform == 'darwin':
if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ:
current_system = LooseVersion(platform.mac_ver()[0])
python_target = LooseVersion(get_config_var('MACOSX_DEPLOYMENT_TARGET'))
if python_target < '10.9' and current_system >= '10.9':
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
with open('gtar/version.py') as version_file:
exec(version_file.read())
macros = []
extra_args = []
include_dirs = [numpy.get_include(), 'lz4', 'miniz', 'sqlite3']
sources = [
'src/Archive.cpp',
'src/DirArchive.cpp',
'src/GTAR.cpp',
'src/Record.cpp',
'src/SqliteArchive.cpp',
'src/TarArchive.cpp',
'src/ZipArchive.cpp',
'lz4/lz4.c',
'lz4/lz4hc.c',
'miniz/miniz.cpp',
'sqlite3/sqlite3.c',
]
# prefix module to avoid collisions with builtin versions of libgetar
macros.append(('GTAR_NAMESPACE_PARENT', 'gtar_pymodule'))
# set max length manually
macros.append(('SQLITE_MAX_LENGTH', '1000000000'))
if '--disable-read-check' in sys.argv:
macros.append(('MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS', None))
sys.argv.remove('--disable-read-check')
if '--debug' in sys.argv:
extra_args.extend(['-O0', '-g'])
sys.argv.remove('--debug')
if '--cython' in sys.argv:
from Cython.Build import cythonize
sys.argv.remove('--cython')
def myCythonize(macros, *args, **kwargs):
result = cythonize(*args, **kwargs)
for r in result:
r.define_macros.extend(macros)
r.include_dirs.extend(include_dirs)
r.extra_compile_args.extend(extra_args)
r.extra_link_args.extend(extra_args)
r.sources.extend(sources)
return result
modules = myCythonize(macros, 'gtar/_gtar.pyx')
else:
sources.append('gtar/_gtar.cpp')
modules = [Extension('gtar._gtar', sources=sources,
define_macros=macros, extra_compile_args=extra_args,
extra_link_args=extra_args, include_dirs=include_dirs)]
setup(name='gtar',
version=__version__,
description='Read and write archive-based trajectory formats',
author='Matthew Spellings',
author_email='[email protected]',
classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: System :: Archiving',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Chemistry',
'Topic :: Scientific/Engineering :: Physics',
],
ext_modules=modules,
license='MIT',
long_description=long_description,
packages=['gtar'],
project_urls={
'Documentation': 'http://libgetar.readthedocs.io/',
'Source': 'https://github.com/glotzerlab/libgetar'
},
install_requires=['numpy'],
url='http://libgetar.readthedocs.io/',
)