-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
64 lines (52 loc) · 1.81 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
"""
NOTE: this is adapted from https://github.com/StanfordVL/iGibson/blob/master/setup.py
"""
import os
import sys
import shutil
import subprocess
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
class CMakeBuild(build_ext):
def run(self):
try:
out = subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError("CMake must be installed.")
for ext in self.extensions:
self.build_extension(ext)
def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
# make build directory
build_dir = os.path.join(extdir, "egl_probe", "build")
if os.path.exists(build_dir):
shutil.rmtree(build_dir)
os.mkdir(build_dir)
# build using cmake
subprocess.check_call("cmake ..; make -j", cwd=build_dir, shell=True)
if sys.version_info.major == 3:
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
else:
# for python2
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name='egl_probe',
version='1.0.1',
author='Stanford University',
url='https://github.com/StanfordVL/egl_probe',
zip_safe=False,
packages=find_packages(),
install_requires=[],
ext_modules=[CMakeExtension('EGLProbe', sourcedir='egl_probe')],
cmdclass=dict(build_ext=CMakeBuild),
tests_require=[],
include_package_data=True,
long_description=long_description,
long_description_content_type='text/markdown'
) #yapf: disable