Skip to content

Commit a19973b

Browse files
committed
Add a function to tools/vendored to list root packages
1 parent a14e36a commit a19973b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/vendored.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,17 @@ def update_setuptools():
166166
rewrite_more_itertools(vendor / "more_itertools")
167167

168168

169+
def yield_root_package(name):
170+
"""Useful when defining the MetaPathFinder
171+
>>> set(yield_root_package("setuptools")) & {"jaraco", "backports"}
172+
{'jaraco', 'backports'}
173+
"""
174+
vendored = Path(f"{name}/_vendor/vendored.txt")
175+
yield from (
176+
line.partition("=")[0].partition(".")[0].replace("-", "_")
177+
for line in vendored.read_text(encoding="utf-8").splitlines()
178+
if line and not line.startswith("#")
179+
)
180+
181+
169182
__name__ == '__main__' and update_vendored()

0 commit comments

Comments
 (0)