forked from OpenDroneMap/OpenSfM
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
97 lines (81 loc) · 2.48 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 multiprocessing
import os
import subprocess
import sys
import setuptools
from wheel.bdist_wheel import bdist_wheel
VERSION = (0, 5, 2)
def version_str(version):
return ".".join(map(str, version))
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 configure_c_extension():
"""Configure cmake project to C extension."""
print(
f"Configuring for python {sys.version_info.major}.{sys.version_info.minor}..."
)
os.makedirs("cmake_build", exist_ok=True)
cmake_command = [
"cmake",
"../opensfm/src",
"-DPYTHON_EXECUTABLE=" + sys.executable,
]
if sys.platform == "win32":
cmake_command += [
"-DVCPKG_TARGET_TRIPLET=x64-windows",
"-DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake",
]
subprocess.check_call(cmake_command, cwd="cmake_build")
def build_c_extension():
"""Compile C extension."""
print("Compiling extension...")
if sys.platform == "win32":
subprocess.check_call(
["cmake", "--build", ".", "--config", "Release"], cwd="cmake_build"
)
else:
subprocess.check_call(
["make", "-j" + str(multiprocessing.cpu_count())], cwd="cmake_build"
)
configure_c_extension()
build_c_extension()
setuptools.setup(
name="opensfm",
version=version_str(VERSION),
description="A Structure from Motion library",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
url="https://github.com/mapillary/OpenSfM",
project_urls={
"Documentation": "https://docs.opensfm.org/",
},
author="Mapillary",
license="BSD",
packages=setuptools.find_packages(),
scripts=[
"bin/opensfm_run_all",
"bin/opensfm",
],
package_data={
"opensfm": [
"pybundle.*",
"pygeo.*",
"pygeometry.*",
"pyrobust.*",
"pyfeatures.*",
"pydense.*",
"pysfm.*",
"pyfoundation.*",
"pymap.*",
"data/sensor_data.json",
"data/camera_calibration.yaml",
"data/bow/bow_hahog_root_uchar_10000.npz",
"data/bow/bow_hahog_root_uchar_64.npz",
]
},
cmdclass={'bdist_wheel': platform_bdist_wheel},
)