blob: 55082248f860155cefd6e35b6b7c8d7500649665 [file] [log] [blame]
Conley Owens094cdbe2014-01-30 15:09:59 -08001# 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 Frysinger0ab6b112022-12-08 01:46:45 -050015import functools
Daniel Kutik50a2c0e2022-11-25 13:32:05 +010016import importlib.machinery
17import importlib.util
Conley Owens094cdbe2014-01-30 15:09:59 -080018import os
19
20
Mike Frysinger44066422024-03-21 12:58:01 -040021def WrapperDir():
22 return os.path.dirname(__file__)
23
24
Conley Owens094cdbe2014-01-30 15:09:59 -080025def WrapperPath():
Mike Frysinger44066422024-03-21 12:58:01 -040026 return os.path.join(WrapperDir(), "repo")
Conley Owens094cdbe2014-01-30 15:09:59 -080027
David Pursehouse819827a2020-02-12 15:20:19 +090028
Mike Frysinger0ab6b112022-12-08 01:46:45 -050029@functools.lru_cache(maxsize=None)
Conley Owens094cdbe2014-01-30 15:09:59 -080030def Wrapper():
Gavin Makea2e3302023-03-11 06:46:20 +000031 modname = "wrapper"
32 loader = importlib.machinery.SourceFileLoader(modname, WrapperPath())
33 spec = importlib.util.spec_from_loader(modname, loader)
34 module = importlib.util.module_from_spec(spec)
35 loader.exec_module(module)
36 return module