From 638a217580dc7a290fb636dcbc823b1f6cecdabc Mon Sep 17 00:00:00 2001 From: Xiangquan Xiao Date: Wed, 20 Nov 2019 11:22:59 -0800 Subject: [PATCH] Cyber: Add Python version check to wrappers. --- cyber/python/cyber_py/__init__.py | 26 ++++++++++++++++++++++++++ cyber/python/cyber_py3/__init__.py | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/cyber/python/cyber_py/__init__.py b/cyber/python/cyber_py/__init__.py index e69de29bb2..2b1b2e0bf3 100644 --- a/cyber/python/cyber_py/__init__.py +++ b/cyber/python/cyber_py/__init__.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python2 + +# **************************************************************************** +# Copyright 2019 The Apollo Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# **************************************************************************** + +import sys + + +if sys.version_info[0] >= 3: + sys.stderr.write(''' + You are running Python3 while importing Python2 Cyber wrapper! + Please change to "import cyber_py3.xyz" accordingly.''') + sys.exit(1) diff --git a/cyber/python/cyber_py3/__init__.py b/cyber/python/cyber_py3/__init__.py index e69de29bb2..060a9aac03 100644 --- a/cyber/python/cyber_py3/__init__.py +++ b/cyber/python/cyber_py3/__init__.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +# **************************************************************************** +# Copyright 2019 The Apollo Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# **************************************************************************** + +import sys + + +if sys.version_info[0] < 3: + sys.stderr.write(''' + You are running Python2 while importing Python3 Cyber wrapper! + Please change to "import cyber_py.xyz" accordingly.''') + sys.exit(1) -- GitLab