forked from qcr/gtsam-quadrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
76 lines (62 loc) · 2.45 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
import os
from setuptools import find_packages, setup, Extension
from setuptools.command.build_ext import build_ext
import shutil
class CMakeExtension(Extension):
def __init__(self, name, cmake_path):
self.cmake_path = cmake_path
super().__init__(name, sources=[])
class cmake_build_ext(build_ext):
def run(self):
self.build_cmake(self.extensions)
super().run()
def build_cmake(self, exts):
# This code assumes 'gtsam' & 'gtsam_quadrics' extensions are specified
# in that order...
gtsam_ext = exts[0]
gtsam_quadrics_ext = exts[1]
# Build our CPython shared objects
source_dir = os.getcwd()
build_dir = self.build_temp
self.spawn([
'cmake', '-DBUILD_SHARED_LIBS=OFF',
'-DCMAKE_POSITION_INDEPENDENT_CODE=ON', '-G', 'Ninja', '-B',
build_dir, '-S', source_dir
])
self.spawn(['cmake', '--build', build_dir])
# Move shared objects to the expected output location
lib_dir = os.path.dirname(self.get_ext_fullpath(gtsam_ext.name))
os.makedirs(lib_dir, exist_ok=True)
shutil.copy(
os.path.join(build_dir, 'gtsam', 'python', 'gtsam',
self.get_ext_filename(gtsam_ext.name)),
self.get_ext_fullpath(gtsam_ext.name))
shutil.copy(
os.path.join(build_dir,
self.get_ext_filename(gtsam_quadrics_ext.name)),
self.get_ext_fullpath(gtsam_quadrics_ext.name))
with open("README.md", 'r') as f:
long_description = f.read()
setup(name='gtsam_quadrics',
version='0.1.0',
author='Lachlan Nicholson',
author_email='[email protected]',
maintainer='Ben Talbot',
maintainer_email='[email protected]',
url='https://github.com/best-of-acrv/gtsam_quadrics',
description='Quadrics for GTSAM',
long_description=long_description,
long_description_content_type='text/markdown',
packages=find_packages(),
install_requires=[],
ext_modules=[
CMakeExtension('gtsam', './gtsam/CMakeLists.txt'),
CMakeExtension('gtsam_quadrics', './CMakeLists.txt')
],
cmdclass={'build_ext': cmake_build_ext},
classifiers=(
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
))