|
| 1 | +#! python |
| 2 | +# -*- coding: UTF-8 -*- |
| 3 | + |
| 4 | +from setuptools import setup |
| 5 | +from setuptools.command.install import install |
| 6 | +import subprocess |
| 7 | +import os |
| 8 | +import sys |
| 9 | +from distutils.spawn import find_executable |
| 10 | + |
| 11 | +package_name = 'osi' |
| 12 | +package_path = os.path.join(os.getcwd(), package_name) |
| 13 | + |
| 14 | + |
| 15 | +class GenerateProtobuf(install): |
| 16 | + @staticmethod |
| 17 | + def find_protoc(): |
| 18 | + """Locates protoc executable""" |
| 19 | + |
| 20 | + if 'PROTOC' in os.environ and os.path.exists(os.environ['PROTOC']): |
| 21 | + protoc = os.environ['PROTOC'] |
| 22 | + else: |
| 23 | + protoc = find_executable('protoc') |
| 24 | + |
| 25 | + if protoc is None: |
| 26 | + sys.stderr.write('protoc not found. Is protobuf-compiler installed? \n' |
| 27 | + 'Alternatively, you can point the PROTOC environment variable at a local version.') |
| 28 | + sys.exit(1) |
| 29 | + return protoc |
| 30 | + |
| 31 | + osi_files = ('osi_common.proto', 'osi_datarecording.proto', 'osi_detectedlandmark.proto', |
| 32 | + 'osi_detectedobject.proto', 'osi_detectedoccupant.proto', 'osi_detectedlane.proto', |
| 33 | + 'osi_environment.proto', 'osi_groundtruth.proto', 'osi_landmark.proto', 'osi_lowleveldata.proto', |
| 34 | + 'osi_modelinternal.proto', 'osi_object.proto', 'osi_occupant.proto', 'osi_lane.proto', |
| 35 | + 'osi_sensordata.proto', 'osi_sensorspecific.proto') |
| 36 | + |
| 37 | + """ Generate Protobuf Messages """ |
| 38 | + def run(self): |
| 39 | + for source in self.osi_files: |
| 40 | + sys.stdout.write('Protobuf-compiling ' + source + '\n') |
| 41 | + subprocess.check_call([self.find_protoc(), '--proto_path=.', '--python_out='+package_path, './' + source]) |
| 42 | + |
| 43 | + install.run(self) |
| 44 | + |
| 45 | +try: |
| 46 | + os.mkdir(package_path) |
| 47 | +except Exception: |
| 48 | + pass |
| 49 | + |
| 50 | +try: |
| 51 | + open(os.path.join(package_path, '__init__.py'), 'a').close() |
| 52 | +except Exception: |
| 53 | + pass |
| 54 | + |
| 55 | +setup(name='open-simulation-interface', |
| 56 | + version='2.0.0', |
| 57 | + description='A generic interface for the environmental perception of automated driving functions in virtual ' |
| 58 | + 'scenarios.', |
| 59 | + author='Carlo van Driesten, Timo Hanke, Nils Hirsenkorn, Pilar Garcia-Ramos, Mark Schiementz, ' |
| 60 | + 'Sebastian Schneider', |
| 61 | + author_email='Carlo.van-Driesten@bmw.de, Timo.Hanke@bmw.de, Nils.Hirsenkorn@tum.de, Pilar.Garcia-Ramos@bmw.de,' |
| 62 | + 'Mark.Schiementz@bmw.de, Sebastian.SB.Schneider@bmw.de', |
| 63 | + packages=[package_name], |
| 64 | + install_requires=['protobuf'], |
| 65 | + cmdclass={ |
| 66 | + 'install': GenerateProtobuf, |
| 67 | + }, |
| 68 | + url='https://github.com/OpenSimulationInterface/open-simulation-interface', |
| 69 | + license="MPL 2.0", |
| 70 | + classifiers=[ |
| 71 | + 'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)', |
| 72 | + ], |
| 73 | + data_files=[("", ["LICENSE"])] |
| 74 | +) |
0 commit comments