forked from StanfordVL/GibsonEnv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
111 lines (93 loc) · 4.03 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import setuptools
from setuptools import setup, find_packages, Extension
import subprocess
from distutils.command.build_ext import build_ext
from distutils.extension import Extension
from setuptools import setup, find_packages, Extension
from setuptools.command.develop import develop
from setuptools.command.install import install
from subprocess import check_call
from distutils.command.build_py import build_py as _build_py
import sys, os.path
from codecs import open as copen
# Get the long description from the relevant file
here = os.path.abspath(os.path.dirname(__file__))
with copen(os.path.join(here, 'long_description.rst'), encoding='utf-8') as f:
long_description = f.read()
class CMakeExtension(Extension):
def __init__(self, name, source_dir=''):
Extension.__init__(self, name, sources=[])
self.source_dir = os.path.abspath(source_dir)
class CMakeBuild(build_ext):
def run(self):
try:
subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError("CMake must be installed to build the following extensions: " +
", ".join(e.name for e in self.extensions))
for ext in self.extensions:
self.build_extension(ext)
def build_extension(self, ext):
ext_dir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
cmake_args = [
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' +
os.path.join(ext_dir, 'channels'),
'-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=' +
os.path.join(ext_dir, 'channels', 'build'),
'-DPYTHON_EXECUTABLE=' + sys.executable
]
cfg = 'Debug' if self.debug else 'Release'
build_args = ['--config', cfg]
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
build_args += ['-j8']
env = os.environ.copy()
env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
self.distribution.get_version())
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
subprocess.check_call(['cmake', ext.source_dir], cwd=self.build_temp, env=env)
subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
'''
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
print('post installation')
check_call("bash realenv/envs/build.sh".split())
install.run(self)
'''
# Read requirements.txt
with open(os.path.abspath('requirements.txt'), mode='r') as f:
requirements = [line.rstrip() for line in f]
print(requirements)
setup(name='gibson',
version='1.0.0',
description='Real Environment Developed by Stanford University',
long_description=long_description,
long_description_content_type='text/x-rst',
url='https://github.com/micheleantonazzi/GibsonEnv',
author='Michele Antonazzi',
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10'
],
zip_safe=False,
packages=find_packages(),
install_requires=requirements,
include_package_data=True,
tests_require=[],
entry_points={
'console_scripts': [
'gibson-set-assets-path = gibson.assets.assets_actions:set_assets_path',
'gibson-download-assets-core = gibson.assets.assets_actions:download_assets_core',
'gibson-download-dataset = gibson.assets.assets_actions:download_dataset',
],
},
ext_modules=[CMakeExtension('GibsonChannel', source_dir='gibson/core')],
cmdclass=dict(build_ext=CMakeBuild),
python_requires='>2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, < 4',
)
# check_call("bash realenv/envs/build.sh".split())