1# Copyright 2018 Espressif Systems (Shanghai) PTE LTD
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16import os
17
18
19def _load_source(name, path):
20    try:
21        from importlib.machinery import SourceFileLoader
22        return SourceFileLoader(name, path).load_module()
23    except ImportError:
24        # importlib.machinery doesn't exists in Python 2 so we will use imp (deprecated in Python 3)
25        import imp
26        return imp.load_source(name, path)
27
28
29idf_path = os.environ['IDF_PATH']
30
31# protocomm component related python files generated from .proto files
32constants_pb2 = _load_source('constants_pb2', idf_path + '/components/protocomm/python/constants_pb2.py')
33sec0_pb2      = _load_source('sec0_pb2',      idf_path + '/components/protocomm/python/sec0_pb2.py')
34sec1_pb2      = _load_source('sec1_pb2',      idf_path + '/components/protocomm/python/sec1_pb2.py')
35session_pb2   = _load_source('session_pb2',   idf_path + '/components/protocomm/python/session_pb2.py')
36
37# wifi_provisioning component related python files generated from .proto files
38wifi_constants_pb2 = _load_source('wifi_constants_pb2', idf_path + '/components/wifi_provisioning/python/wifi_constants_pb2.py')
39wifi_config_pb2    = _load_source('wifi_config_pb2',    idf_path + '/components/wifi_provisioning/python/wifi_config_pb2.py')
40wifi_scan_pb2      = _load_source('wifi_scan_pb2',      idf_path + '/components/wifi_provisioning/python/wifi_scan_pb2.py')
41
42# custom_provisioning component related python files generated from .proto files
43custom_config_pb2  = _load_source('custom_config_pb2',  idf_path +
44                                  '/examples/provisioning/legacy/custom_config/components/custom_provisioning/python/custom_config_pb2.py')
45