Conley Owens | 094cdbe | 2014-01-30 15:09:59 -0800 | [diff] [blame] | 1 | # Copyright (C) 2014 The Android Open Source Project |
| 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 | |
Daniel Kutik | 50a2c0e | 2022-11-25 13:32:05 +0100 | [diff] [blame] | 15 | import importlib.machinery |
| 16 | import importlib.util |
Conley Owens | 094cdbe | 2014-01-30 15:09:59 -0800 | [diff] [blame] | 17 | import os |
| 18 | |
| 19 | |
| 20 | def WrapperPath(): |
| 21 | return os.path.join(os.path.dirname(__file__), 'repo') |
| 22 | |
David Pursehouse | 819827a | 2020-02-12 15:20:19 +0900 | [diff] [blame] | 23 | |
Conley Owens | 094cdbe | 2014-01-30 15:09:59 -0800 | [diff] [blame] | 24 | _wrapper_module = None |
David Pursehouse | 819827a | 2020-02-12 15:20:19 +0900 | [diff] [blame] | 25 | |
| 26 | |
Conley Owens | 094cdbe | 2014-01-30 15:09:59 -0800 | [diff] [blame] | 27 | def Wrapper(): |
| 28 | global _wrapper_module |
| 29 | if not _wrapper_module: |
Daniel Kutik | 50a2c0e | 2022-11-25 13:32:05 +0100 | [diff] [blame] | 30 | modname = 'wrapper' |
| 31 | loader = importlib.machinery.SourceFileLoader(modname, WrapperPath()) |
| 32 | spec = importlib.util.spec_from_loader(modname, loader) |
| 33 | _wrapper_module = importlib.util.module_from_spec(spec) |
| 34 | loader.exec_module(_wrapper_module) |
Conley Owens | 094cdbe | 2014-01-30 15:09:59 -0800 | [diff] [blame] | 35 | return _wrapper_module |