~ubuntu-branches/debian/sid/python-feather-format/sid

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Package Import Robot
  • Author(s): ChangZhuo Chen (陳昌倬)
  • Date: 2016-03-30 19:01:30 UTC
  • Revision ID: package-import@ubuntu.com-20160330190130-b7o770i7o2drepi1
Tags: upstream-0.1.0
Import upstream version 0.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# Copyright 2016 Feather Developers
 
4
#
 
5
# Licensed under the Apache License, Version 2.0 (the "License");
 
6
# you may not use this file except in compliance with the License.
 
7
# You may obtain a copy of the License at
 
8
#
 
9
# http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
# Unless required by applicable law or agreed to in writing, software
 
12
# distributed under the License is distributed on an "AS IS" BASIS,
 
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
# See the License for the specific language governing permissions and
 
15
# limitations under the License.
 
16
 
 
17
# Bits here from Apache Kudu (incubating), ASL 2.0
 
18
 
 
19
from Cython.Distutils import build_ext
 
20
from Cython.Build import cythonize
 
21
import Cython
 
22
 
 
23
import numpy as np
 
24
 
 
25
import sys
 
26
from setuptools import setup
 
27
from distutils.command.clean import clean as _clean
 
28
from distutils.extension import Extension
 
29
import os
 
30
import platform
 
31
 
 
32
if Cython.__version__ < '0.19.1':
 
33
    raise Exception('Please upgrade to Cython 0.19.1 or newer')
 
34
 
 
35
MAJOR = 0
 
36
MINOR = 1
 
37
MICRO = 0
 
38
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
 
39
ISRELEASED = True
 
40
 
 
41
setup_dir = os.path.abspath(os.path.dirname(__file__))
 
42
 
 
43
 
 
44
def write_version_py(filename=os.path.join(setup_dir, 'feather/version.py')):
 
45
    version = VERSION
 
46
    if not ISRELEASED:
 
47
        version += '.dev'
 
48
 
 
49
    a = open(filename, 'w')
 
50
    file_content = "\n".join(["",
 
51
                              "# THIS FILE IS GENERATED FROM SETUP.PY",
 
52
                              "version = '%(version)s'",
 
53
                              "isrelease = '%(isrelease)s'"])
 
54
 
 
55
    a.write(file_content % {'version': VERSION,
 
56
                            'isrelease': str(ISRELEASED)})
 
57
    a.close()
 
58
 
 
59
 
 
60
class clean(_clean):
 
61
    def run(self):
 
62
        _clean.run(self)
 
63
        for x in ['feather/ext.cpp']:
 
64
            try:
 
65
                os.remove(x)
 
66
            except OSError:
 
67
                pass
 
68
 
 
69
FEATHER_SOURCES = ['feather/ext.pyx']
 
70
 
 
71
INCLUDE_PATHS = ['feather', np.get_include()]
 
72
LIBRARIES = []
 
73
EXTRA_LINK_ARGS = []
 
74
 
 
75
FEATHER_STATIC_BUILD = True
 
76
 
 
77
if FEATHER_STATIC_BUILD:
 
78
    INCLUDE_PATHS.append(os.path.join(setup_dir, 'src'))
 
79
 
 
80
    FEATHER_SOURCES.extend([
 
81
        'src/feather/buffer.cc',
 
82
        'src/feather/io.cc',
 
83
        'src/feather/metadata.cc',
 
84
        'src/feather/reader.cc',
 
85
        'src/feather/status.cc',
 
86
        'src/feather/types.cc',
 
87
        'src/feather/writer.cc'
 
88
    ])
 
89
 
 
90
    LIBRARY_DIRS = []
 
91
else:
 
92
    # Library build
 
93
    if 'FEATHER_HOME' in os.environ:
 
94
        prefix = os.environ['FEATHER_HOME']
 
95
        sys.stderr.write("Building from configured libfeather prefix {0}\n"
 
96
                         .format(prefix))
 
97
    else:
 
98
        if os.path.exists("/usr/local/include/feather"):
 
99
            prefix = "/usr/local"
 
100
        elif os.path.exists("/usr/include/feather"):
 
101
            prefix = "/usr"
 
102
        else:
 
103
            sys.stderr.write("Cannot find installed libfeather "
 
104
                             "core library.\n")
 
105
            sys.exit(1)
 
106
        sys.stderr.write("Building from system prefix {0}\n".format(prefix))
 
107
 
 
108
    feather_include_dir = os.path.join(prefix, 'include')
 
109
    feather_lib_dir = os.path.join(prefix, 'lib')
 
110
 
 
111
    INCLUDE_PATHS.append(feather_include_dir)
 
112
 
 
113
    LIBRARIES.append('feather')
 
114
    LIBRARY_DIRS = [feather_lib_dir]
 
115
 
 
116
    if platform.system() == 'Darwin':
 
117
        EXTRA_LINK_ARGS.append('-Wl,-rpath,' + feather_lib_dir)
 
118
 
 
119
 
 
120
RT_LIBRARY_DIRS = LIBRARY_DIRS
 
121
 
 
122
ext = Extension('feather.ext',
 
123
                FEATHER_SOURCES,
 
124
                language='c++',
 
125
                libraries=LIBRARIES,
 
126
                include_dirs=INCLUDE_PATHS,
 
127
                library_dirs=LIBRARY_DIRS,
 
128
                runtime_library_dirs=RT_LIBRARY_DIRS,
 
129
                extra_compile_args=['-std=c++11', '-O3'],
 
130
                extra_link_args=EXTRA_LINK_ARGS)
 
131
extensions = [ext]
 
132
extensions = cythonize(extensions)
 
133
 
 
134
write_version_py()
 
135
 
 
136
LONG_DESCRIPTION = open(os.path.join(setup_dir, "README.md")).read()
 
137
DESCRIPTION = "Python interface to the Apache Arrow-based Feather File Format"
 
138
 
 
139
CLASSIFIERS = [
 
140
    'Development Status :: 3 - Alpha',
 
141
    'Environment :: Console',
 
142
    'Programming Language :: Python',
 
143
    'Programming Language :: Python :: 2',
 
144
    'Programming Language :: Python :: 3',
 
145
    'Programming Language :: Python :: 2.7',
 
146
    'Programming Language :: Python :: 3.4',
 
147
    'Programming Language :: Python :: 3.5',
 
148
    'Programming Language :: Cython'
 
149
]
 
150
 
 
151
URL = 'http://github.com/wesm/feather'
 
152
 
 
153
setup(
 
154
    name="feather-format",
 
155
    packages=['feather', 'feather.tests'],
 
156
    version=VERSION,
 
157
    package_data={'feather': ['*.pxd', '*.pyx']},
 
158
    ext_modules=extensions,
 
159
    cmdclass={
 
160
        'clean': clean,
 
161
        'build_ext': build_ext
 
162
    },
 
163
    install_requires=['cython >= 0.21'],
 
164
    description=DESCRIPTION,
 
165
    long_description=LONG_DESCRIPTION,
 
166
    license='Apache License, Version 2.0',
 
167
    classifiers=CLASSIFIERS,
 
168
    author="Wes McKinney",
 
169
    author_email="wesm@apache.org",
 
170
    url=URL,
 
171
    test_suite="feather.tests"
 
172
)