-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
132 lines (111 loc) · 4.01 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""The setup script."""
from setuptools import setup, find_packages, Extension
from distutils.command import build as build_module
from setuptools.command.install import install
from setuptools.command.develop import develop
from setuptools.command.egg_info import egg_info
import subprocess
import sys
import os
import errno
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else:
raise
base_path = os.path.dirname(os.path.realpath(__file__))
libgooctosql_directory = os.path.abspath(base_path + "/libs")
libgooctosql_path = libgooctosql_directory + "/libgooctosql"
libgooctosql_local = "./libs/native_octosql"
go_src_path = "./src/lib.go"
def custom_build_hook():
print("Will install native library in ["+libgooctosql_path+"]")
try:
mkdir_p(libgooctosql_directory)
except:
print("ok")
print("remove existing files")
subprocess.call(['rm', '-r', '-f', libgooctosql_local])
print("run native bash setup")
subprocess.call(['bash', './setup_native.sh', libgooctosql_local, go_src_path])
print('Remove existing files: '+libgooctosql_path)
subprocess.call(['rm', '-r', '-f', libgooctosql_path])
print('Copy files '+libgooctosql_local+' to '+libgooctosql_path)
subprocess.call(['cp', libgooctosql_local, libgooctosql_path])
class CustomBuildCommand(build_module.build):
def run(self):
custom_build_hook()
build_module.build.run(self)
class CustomInstallCommand(install):
def run(self):
install.run(self)
custom_build_hook()
class CustomDevelopCommand(develop):
def run(self):
develop.run(self)
custom_build_hook()
class CustomEggInfoCommand(egg_info):
def run(self):
egg_info.run(self)
custom_build_hook()
with open('README.rst') as readme_file:
readme = readme_file.read()
with open('HISTORY.rst') as history_file:
history = history_file.read()
requirements = ['Click>=7.0', ]
setup_requirements = ['pytest-runner', ]
test_requirements = ['pytest>=3', ]
native_link_flags = [libgooctosql_path]
if sys.platform.startswith('darwin'):
native_link_flags = [libgooctosql_path, '-framework', 'CoreFoundation', '-framework', 'Security']
setup(
author="Piotr Styczynski",
author_email='[email protected]',
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
cmdclass={
'build': CustomBuildCommand,
'install': CustomInstallCommand,
'develop': CustomDevelopCommand,
'egg_info': CustomEggInfoCommand,
},
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
"Programming Language :: Python :: 2",
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
description="Octosql bindings for Python",
entry_points={
'console_scripts': [
'octosql_py=octosql_py.cli:main',
],
},
install_requires=requirements,
license="MIT license",
long_description=readme + '\n\n' + history,
include_package_data=True,
keywords='octosql_py',
name='octosql_py',
py_modules=['octosql_py', 'octosql_py_native'],
packages=find_packages(include=['octosql_py', 'octosql_py.*', 'octosql_py_native', 'octosql_py_native.*']),
setup_requires=setup_requirements,
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/styczynski/octosql_py',
version='0.3.0',
zip_safe=False,
ext_modules = [Extension("octosql_py_native", [
"./src/python/src/octosql_py_native.cpp"
], extra_compile_args=['-std=c++11'], extra_link_args=native_link_flags)]
)