2018-07-04 17:12:14 +08:00
|
|
|
# Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma de
|
|
|
|
# Barcelona (UAB).
|
|
|
|
#
|
|
|
|
# This work is licensed under the terms of the MIT license.
|
|
|
|
# For a copy, see <https://opensource.org/licenses/MIT>.
|
|
|
|
|
|
|
|
from setuptools import setup, Extension
|
|
|
|
|
|
|
|
import fnmatch
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
def get_libcarla_extensions():
|
2018-07-30 18:11:31 +08:00
|
|
|
include_dirs = ['dependencies/include']
|
|
|
|
library_dirs = ['dependencies/lib']
|
|
|
|
libraries = []
|
2018-07-04 17:12:14 +08:00
|
|
|
|
2018-10-19 18:16:04 +08:00
|
|
|
sources = ['source/libcarla/libcarla.cpp']
|
|
|
|
|
2018-10-29 18:32:32 +08:00
|
|
|
def walk(folder, file_filter='*'):
|
|
|
|
for root, _, filenames in os.walk(folder):
|
|
|
|
for filename in fnmatch.filter(filenames, file_filter):
|
|
|
|
yield os.path.join(root, filename)
|
|
|
|
|
2018-07-04 17:12:14 +08:00
|
|
|
if os.name == "posix":
|
2019-01-11 22:23:58 +08:00
|
|
|
if platform.dist()[0].lower() in ["ubuntu", "debian", "deepin"]:
|
2018-07-30 18:11:31 +08:00
|
|
|
pwd = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
pylib = "libboost_python%d%d.a" % (sys.version_info.major,
|
|
|
|
sys.version_info.minor)
|
|
|
|
extra_link_args = [
|
2018-10-19 18:16:04 +08:00
|
|
|
os.path.join(pwd, 'dependencies/lib/libcarla_client.a'),
|
2018-07-30 18:11:31 +08:00
|
|
|
os.path.join(pwd, 'dependencies/lib/librpc.a'),
|
2018-10-01 01:01:53 +08:00
|
|
|
os.path.join(pwd, 'dependencies/lib/libboost_filesystem.a'),
|
2018-10-08 00:46:02 +08:00
|
|
|
os.path.join(pwd, 'dependencies/lib', pylib)]
|
2018-07-30 18:11:31 +08:00
|
|
|
extra_compile_args = [
|
2018-10-07 17:50:08 +08:00
|
|
|
'-fPIC', '-std=c++14', '-Wno-missing-braces',
|
2018-10-19 18:16:04 +08:00
|
|
|
'-DBOOST_ERROR_CODE_HEADER_ONLY', '-DLIBCARLA_WITH_PYTHON_SUPPORT',
|
|
|
|
'-DLIBCARLA_ENABLE_LIFETIME_PROFILER',
|
2018-07-30 18:11:31 +08:00
|
|
|
]
|
2018-10-08 00:46:02 +08:00
|
|
|
if 'TRAVIS' in os.environ and os.environ['TRAVIS'] == 'true':
|
|
|
|
print('Travis CI build detected: disabling PNG support.')
|
|
|
|
extra_link_args += ['-ljpeg', '-ltiff']
|
|
|
|
extra_compile_args += ['-DLIBCARLA_IMAGE_WITH_PNG_SUPPORT=false']
|
|
|
|
else:
|
|
|
|
extra_link_args += ['-lpng', '-ljpeg', '-ltiff']
|
|
|
|
extra_compile_args += ['-DLIBCARLA_IMAGE_WITH_PNG_SUPPORT=true']
|
2018-07-30 18:11:31 +08:00
|
|
|
# @todo Why would we need this?
|
|
|
|
include_dirs += ['/usr/lib/gcc/x86_64-linux-gnu/7/include']
|
|
|
|
library_dirs += ['/usr/lib/gcc/x86_64-linux-gnu/7']
|
|
|
|
extra_link_args += ['/usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.a']
|
2018-07-30 22:52:29 +08:00
|
|
|
else:
|
2018-10-08 00:46:02 +08:00
|
|
|
raise NotImplementedError
|
2018-07-30 22:52:29 +08:00
|
|
|
elif os.name == "nt":
|
2018-10-19 18:16:04 +08:00
|
|
|
sources += [x for x in walk('dependencies/include/carla', '*.cpp')]
|
|
|
|
|
2018-07-30 22:52:29 +08:00
|
|
|
pwd = os.path.dirname(os.path.realpath(__file__))
|
2018-10-07 17:50:08 +08:00
|
|
|
pylib = "libboost_python%d%d-vc141-mt-x64-1_67.lib" % (
|
|
|
|
sys.version_info.major,
|
|
|
|
sys.version_info.minor)
|
2018-07-30 22:52:29 +08:00
|
|
|
extra_link_args = [
|
|
|
|
'shlwapi.lib',
|
|
|
|
os.path.join(pwd, 'dependencies/lib/rpc.lib'),
|
|
|
|
os.path.join(pwd, 'dependencies/lib', pylib)]
|
|
|
|
|
|
|
|
# https://docs.microsoft.com/es-es/cpp/porting/modifying-winver-and-win32-winnt
|
2018-10-07 17:50:08 +08:00
|
|
|
extra_compile_args = [
|
2018-10-19 18:16:04 +08:00
|
|
|
'/DBOOST_ALL_NO_LIB', '/DBOOST_PYTHON_STATIC_LIB',
|
2018-10-07 17:50:08 +08:00
|
|
|
'/DBOOST_ERROR_CODE_HEADER_ONLY', '/D_WIN32_WINNT=0x0501',
|
|
|
|
'/DLIBCARLA_WITH_PYTHON_SUPPORT']
|
2018-07-04 17:12:14 +08:00
|
|
|
else:
|
|
|
|
raise NotImplementedError
|
|
|
|
|
2018-07-26 23:51:33 +08:00
|
|
|
depends = [x for x in walk('source/libcarla')]
|
|
|
|
depends += [x for x in walk('dependencies')]
|
2018-07-04 17:12:14 +08:00
|
|
|
|
|
|
|
def make_extension(name, sources):
|
2018-07-30 22:52:29 +08:00
|
|
|
|
2018-07-04 17:12:14 +08:00
|
|
|
return Extension(
|
|
|
|
name,
|
|
|
|
sources=sources,
|
2018-07-30 18:11:31 +08:00
|
|
|
include_dirs=include_dirs,
|
|
|
|
library_dirs=library_dirs,
|
2018-07-04 17:12:14 +08:00
|
|
|
libraries=libraries,
|
2018-07-30 18:11:31 +08:00
|
|
|
extra_compile_args=extra_compile_args,
|
|
|
|
extra_link_args=extra_link_args,
|
2018-07-13 18:39:23 +08:00
|
|
|
language='c++14',
|
2018-07-04 17:12:14 +08:00
|
|
|
depends=depends)
|
|
|
|
|
2018-07-26 23:51:33 +08:00
|
|
|
print('compiling:\n - %s' % '\n - '.join(sources))
|
|
|
|
|
|
|
|
return [make_extension('carla.libcarla', sources)]
|
2018-07-04 17:12:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
setup(
|
|
|
|
name='carla',
|
2018-12-22 01:00:49 +08:00
|
|
|
version='0.9.2',
|
2018-07-04 17:12:14 +08:00
|
|
|
package_dir={'': 'source'},
|
|
|
|
packages=['carla'],
|
|
|
|
ext_modules=get_libcarla_extensions(),
|
|
|
|
license='MIT License',
|
|
|
|
description='Python API for communicating with the CARLA server.',
|
|
|
|
url='https://github.com/carla-simulator/carla',
|
|
|
|
author='The CARLA team',
|
|
|
|
author_email='carla.simulator@gmail.com',
|
|
|
|
include_package_data=True)
|