| 1 | import sys |
| 2 | from importlib.metadata import Distribution, DistributionFinder |
| 3 | from pathlib import Path |
| 4 | |
| 5 | |
| 6 | class UninstalledDistributionFinder(DistributionFinder): |
| 7 | """Find metadata for lazr.delegates despite it not being installed.""" |
| 8 | |
| 9 | @staticmethod |
| 10 | def find_spec(fullname, path=None, target=None): |
| 11 | return None |
| 12 | |
| 13 | @staticmethod |
| 14 | def find_module(fullname, path): |
| 15 | return None |
| 16 | |
| 17 | @staticmethod |
| 18 | def invalidate_caches(): |
| 19 | pass |
| 20 | |
| 21 | @staticmethod |
| 22 | def find_distributions(context=DistributionFinder.Context()): |
| 23 | if context.name == "lazr.delegates": |
| 24 | return [ |
| 25 | Distribution.at(Path(__file__).parent / "lazr" / "delegates") |
| 26 | ] |
| 27 | |
| 28 | |
| 29 | sys.meta_path.append(UninstalledDistributionFinder) |