-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsetup.py
97 lines (85 loc) · 3.04 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
#!/usr/bin/env python3
import os
import setuptools
import subprocess
import sys
from glob import glob
from wheel.bdist_wheel import bdist_wheel
import distutils.sysconfig as sysconfig
import os
from distutils.sysconfig import get_python_inc
python_lib_location = os.path.join(sysconfig.get_config_var('LIBDIR'), sysconfig.get_config_var('LDLIBRARY'))
python_include_dir = get_python_inc()
class platform_bdist_wheel(bdist_wheel):
"""Patched bdist_well to make sure wheels include platform tag."""
def finalize_options(self):
bdist_wheel.finalize_options(self)
self.root_is_pure = False
"""
def _find_packages():
packages = setuptools.find_packages()
packages.append('mypythonpackage.doc')
packages.append('matlabsources')
print('packages found: {}'.format(packages))
return packages
"""
def configure_c_extension():
"""Configure cmake project to C extension."""
print("Configuring for python {}.{}...".format(sys.version_info.major,
sys.version_info.minor))
os.makedirs('cmake_build', exist_ok=True)
build_march_native = int(os.environ.get("BUILD_MARCH_NATIVE", 0))
cmake_command = [
'cmake',
'../',
'-DBUILD_TESTING=OFF',
'-DPYTHON_BUILD=ON',
'-DCMAKE_BUILD_TYPE=Release',
'-DPYTHON_EXECUTABLE=' + sys.executable,
'-DPYTHON_LIBRARY=' + python_lib_location,
'-DPYTHON_INCLUDE_DIR=' + python_include_dir,
'-DBUILD_WITH_MARCH_NATIVE={}'.format("ON" if build_march_native else "OFF")
]
subprocess.check_call(cmake_command, cwd='cmake_build')
def build_c_extension():
"""Compile C extension."""
print("Compiling extension...")
subprocess.check_call(['make', '-j5'], cwd='cmake_build')
def create_package():
files = glob('cmake_build/lib/pytheia*')
subprocess.run(['cp'] + files + ['src/pytheia'])
configure_c_extension()
build_c_extension()
create_package()
setuptools.setup(
name='pytheia',
version='0.2.5',
description='A performant Structure from Motion library for Python',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
url='https://github.com/urbste/pyTheiaSfM.git',
# project_urls={
# "Documentation": "http://theia-sfm.org/",
# },
author='Steffen Urban, Shengyu Yin',
author_email = "[email protected], [email protected]",
license='BSD',
packages=setuptools.find_packages(where='src'),
include_package_data=True,
package_dir={
'pytheia': 'src/pytheia',
},
package_data={
'pytheia': [
'pytheia.*',
'libflann_cpp.*',
#'stubs/pytheia/pytheia/__init__.pyi',
#'stubs/pytheia/pytheia/io/__init__.pyi',
#'stubs/pytheia/pytheia/matching/__init__.pyi',
#'stubs/pytheia/pytheia/math/__init__.pyi',
#'stubs/pytheia/pytheia/sfm/__init__.pyi',
#'stubs/pytheia/pytheia/solvers/__init__.pyi',
]
},
cmdclass={'bdist_wheel': platform_bdist_wheel},
)