-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
74 lines (64 loc) · 2.27 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
import contextlib
import os
import platform
from codecs import open # To use a consistent encoding
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
# Get the current directory path.
here = os.path.abspath(os.path.dirname(__file__))
# Extract the description from the top-level README.
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
description = 'dartpy provides python bindings for DART.'
# Set the dependencies depending on the platform
system = platform.system()
if system == 'Linux':
distro = platform.linux_distribution()[1]
if distro == '14.04':
install_requires = ['numpy', 'pyassimp', 'pytest']
else:
install_requires = ['numpy', 'pyassimp', 'pytest']
else:
install_requires = ['numpy', 'pyassimp', 'pytest']
# See: http://www.astropython.org/snippet/2009/10/chdir-context-manager
@contextlib.contextmanager
def chdir(dirname=None):
""" Context manager for changing directories. """
curdir = os.getcwd()
try:
if dirname is not None:
os.chdir(dirname)
yield
finally:
os.chdir(curdir)
# See: https://github.com/libdynd/dynd-python/blob/master/setup.py
class cmake_build_ext(build_ext):
""" Wrapper class that builds the extension using CMake. """
def run(self):
""" Build using CMake from the specified build directory. """
self.mkpath(self.build_temp)
with chdir(self.build_temp):
self.spawn(['cmake', here])
self.spawn(['make'])
# Set up the python package wrapping this extension.
setup(
name='dartpy',
version='0.0.1',
description=description,
long_description=long_description,
ext_modules=[Extension('dartpy', sources=[])],
url='https://github.com/personalrobotics/dartpy',
author='Michael Koval',
author_email='[email protected]',
maintainer='Jeongseok Lee',
maintainer_email='[email protected]',
license='BSD',
keywords=['dartsim', 'physics', 'robotics', 'simulation'],
classifiers=[
'Development Status :: 1 - Planning',
'License :: OSI Approved :: BSD License',
'Intended Audience :: Developers',
],
# cmdclass={'build_ext': cmake_build_ext},
install_requires=install_requires
)