forked from abs-tudelft/fletcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·158 lines (145 loc) · 4.97 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
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env python3
# Copyright 2018 Delft University of Technology
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from distutils.command.bdist import bdist as _bdist
from distutils.command.build import build as _build
from distutils.command.clean import clean as _clean
from distutils.command.sdist import sdist as _sdist
from setuptools.command.egg_info import egg_info as _egg_info
from setuptools import setup, Extension, find_packages
import os, platform, shutil, glob
import numpy as np
import pyarrow as pa
def read(fname):
with open(os.path.join(os.path.dirname(__file__), fname)) as f:
return f.read()
target_dir = os.getcwd() + "/build"
output_dir = target_dir + "/install"
include_dir = output_dir + "/include"
lib_dirs = [output_dir + "/lib", output_dir + "/lib64"]
py_target_dir = target_dir + "/python"
py_build_dir = py_target_dir + "/build"
py_dist_dir = target_dir + "/dist"
class clean(_clean):
def run(self):
_clean.run(self)
try:
[os.remove('pyfletcher/lib' + x) for x in ['.cpp', '.h', '_api.h']]
except:
pass
shutil.rmtree(target_dir)
class build(_build):
def initialize_options(self):
_build.initialize_options(self)
from plumbum import FG
from plumbum.cmd import mkdir
mkdir['-p'][py_build_dir] & FG
self.build_base = py_build_dir
def run(self):
from plumbum import local, FG
with local.cwd(target_dir):
try:
from plumbum.cmd import cmake, make
except ImportError:
# TODO: download cmake 3.14 and extract in build dir
raise ImportError('CMake or make not found')
cmake['../../..']\
['-DFLETCHER_BUILD_ECHO=ON']\
['-DCMAKE_BUILD_TYPE=Release']\
['-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0']\
['-DCMAKE_INSTALL_PREFIX={}'.format(output_dir)] & FG
make['-j4'] & FG
make['install'] & FG
_build.run(self)
class bdist(_bdist):
def finalize_options(self):
_bdist.finalize_options(self)
self.dist_dir = py_dist_dir
class sdist(_sdist):
def finalize_options(self):
_sdist.finalize_options(self)
self.dist_dir = py_dist_dir
class egg_info(_egg_info):
def initialize_options(self):
_egg_info.initialize_options(self)
self.egg_base = os.path.relpath(py_target_dir)
setup(
name="pyfletcher",
version="0.0.10",
author="Accelerated Big Data Systems, Delft University of Technology",
packages=find_packages(),
description="A Python wrapper for the Fletcher runtime library",
long_description=read('README.md'),
long_description_content_type='text/markdown',
url="https://github.com/abs-tudelft/fletcher",
project_urls = {
"Bug Tracker": "https://github.com/abs-tudelft/fletcher/issues",
"Documentation": "https://abs-tudelft.github.io/fletcher/",
"Source Code": "https://github.com/abs-tudelft/fletcher/",
},
ext_modules=[
Extension(
"pyfletcher.lib",
["pyfletcher/lib.pyx"],
language="c++",
define_macros=[
("_GLIBCXX_USE_CXX11_ABI", "0")
],
include_dirs=[
np.get_include(),
pa.get_include(),
include_dir
],
libraries=pa.get_libraries() + ["fletcher"],
library_dirs=pa.get_library_dirs() + lib_dirs,
runtime_library_dirs=pa.get_library_dirs() + lib_dirs,
extra_compile_args=["-std=c++11", "-O3"],
extra_link_args=["-std=c++11"]
)
],
install_requires=[
'numpy >= 1.14',
'pandas',
'pyarrow == 0.15.1',
],
setup_requires=[
'cython',
'numpy',
'pyarrow == 0.15.1',
'plumbum',
'pytest-runner'
],
tests_require=[
'pytest'
],
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Cython",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux"
],
cmdclass = {
'bdist': bdist,
'build': build,
'clean': clean,
'egg_info': egg_info,
'sdist': sdist,
},
license='Apache License, Version 2.0',
zip_safe = False,
data_files= [
('lib', glob.glob('build/install/lib*/libfletcher_echo.so')),
],
)