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 | |
Mike Frysinger | 0ab6b11 | 2022-12-08 01:46:45 -0500 | [diff] [blame] | 15 | import functools |
Daniel Kutik | 50a2c0e | 2022-11-25 13:32:05 +0100 | [diff] [blame] | 16 | import importlib.machinery |
| 17 | import importlib.util |
Conley Owens | 094cdbe | 2014-01-30 15:09:59 -0800 | [diff] [blame] | 18 | import os |
| 19 | |
| 20 | |
| 21 | def WrapperPath(): |
Gavin Mak | ea2e330 | 2023-03-11 06:46:20 +0000 | [diff] [blame] | 22 | return os.path.join(os.path.dirname(__file__), "repo") |
Conley Owens | 094cdbe | 2014-01-30 15:09:59 -0800 | [diff] [blame] | 23 | |
David Pursehouse | 819827a | 2020-02-12 15:20:19 +0900 | [diff] [blame] | 24 | |
Mike Frysinger | 0ab6b11 | 2022-12-08 01:46:45 -0500 | [diff] [blame] | 25 | @functools.lru_cache(maxsize=None) |
Conley Owens | 094cdbe | 2014-01-30 15:09:59 -0800 | [diff] [blame] | 26 | def Wrapper(): |
Gavin Mak | ea2e330 | 2023-03-11 06:46:20 +0000 | [diff] [blame] | 27 | modname = "wrapper" |
| 28 | loader = importlib.machinery.SourceFileLoader(modname, WrapperPath()) |
| 29 | spec = importlib.util.spec_from_loader(modname, loader) |
| 30 | module = importlib.util.module_from_spec(spec) |
| 31 | loader.exec_module(module) |
| 32 | return module |