-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean ad/ stub files and SOURCES for non-rss builds
- Loading branch information
Showing
2 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,15 @@ | |
# This work is licensed under the terms of the MIT license. | ||
# For a copy, see <https://opensource.org/licenses/MIT>. | ||
|
||
import shutil | ||
from setuptools import setup, Extension | ||
|
||
import fnmatch | ||
import os | ||
import sys | ||
|
||
from distutils.command.install_lib import install_lib | ||
|
||
def is_rss_variant_enabled(): | ||
if 'BUILD_RSS_VARIANT' in os.environ and os.environ['BUILD_RSS_VARIANT'] == 'true': | ||
return True | ||
|
@@ -135,8 +138,8 @@ def walk(folder, file_filter='*'): | |
else: | ||
raise NotImplementedError | ||
|
||
depends = [x for x in walk('source/libcarla')] | ||
depends += [x for x in walk('dependencies')] | ||
depends = list(walk('source/libcarla')) | ||
depends += list(walk('dependencies')) | ||
|
||
def make_extension(name, sources): | ||
|
||
|
@@ -163,11 +166,42 @@ def get_license(): | |
with open("README.md") as f: | ||
long_description = f.read() | ||
|
||
class CleanADStubFiles(install_lib): | ||
""" | ||
Removes the ad/ files from the build directory in a normal built | ||
that else would be copies over. | ||
""" | ||
|
||
CARLA_RSS_STUB_FILE = "__carla_rss.pyi" | ||
_CARLA_RSS_STUB_FILE_PATH = os.path.join("carla", CARLA_RSS_STUB_FILE) | ||
CARLA_AD_STUB_DIR = os.path.join("carla", "ad") | ||
|
||
def run(self): | ||
if not is_rss_variant_enabled(): | ||
self.prune_rss() | ||
super().run() | ||
|
||
def prune_rss(self): | ||
"""Removes files from an rss build that we do not want to be copied over to a non-rss build.""" | ||
if not self.build_dir: | ||
return | ||
print("Cleaning possible RSS files from previous build.") | ||
shutil.rmtree(os.path.join(self.build_dir, self.CARLA_AD_STUB_DIR), ignore_errors=True) | ||
try: | ||
os.remove(os.path.join(self.build_dir, self._CARLA_RSS_STUB_FILE_PATH)) | ||
except FileNotFoundError: | ||
pass | ||
return | ||
|
||
setup( | ||
name='carla', | ||
version='0.9.15', | ||
package_dir={'': 'source'}, | ||
packages=['carla'] if not is_rss_variant_enabled() else ['carla', 'carla.ad', 'carla.ad.map', 'carla.ad.rss'], | ||
# Avoid "Package would be ignored" warning for non-rss build if using ['carla'] here | ||
packages=['carla', 'carla.ad', 'carla.ad.rss', 'carla.ad.map'] if is_rss_variant_enabled() else ['carla'], | ||
# For non-rss build do a fine grained include/exclude on the package data. | ||
package_data={'carla' : [""]}, | ||
exclude_package_data={} if is_rss_variant_enabled() else {'carla':[CleanADStubFiles.CARLA_RSS_STUB_FILE]}, | ||
ext_modules=get_libcarla_extensions(), | ||
license=get_license(), | ||
description='Python API for communicating with the CARLA server.', | ||
|
@@ -176,4 +210,6 @@ def get_license(): | |
url='https://github.com/carla-simulator/carla', | ||
author='The CARLA team', | ||
author_email='[email protected]', | ||
include_package_data=True) | ||
include_package_data=True, | ||
cmdclass={'install_lib': CleanADStubFiles}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters