-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from pathlib import Path | ||
|
||
|
||
template = """ | ||
python_sources = [ | ||
{sources} | ||
] | ||
py.install_sources( | ||
python_sources, | ||
subdir: '{subdir}' | ||
) | ||
""" | ||
|
||
|
||
def process_directory(path_dir): | ||
|
||
print(f"Process {path_dir}") | ||
|
||
names_py = sorted(path.name for path in path_dir.glob("*.py")) | ||
print(f"{names_py = }") | ||
paths_subdirs = [ | ||
path | ||
for path in path_dir.glob("*") | ||
if path.is_dir() and not path.name.startswith("__") | ||
] | ||
|
||
names_subdirs = sorted(path.name for path in paths_subdirs) | ||
print(f"{names_subdirs = }") | ||
|
||
if names_py: | ||
code = template.format( | ||
sources="\n".join(f" '{name}'," for name in names_py), subdir=path_dir | ||
) | ||
else: | ||
code = "" | ||
|
||
if names_subdirs: | ||
code += "\n" + "\n".join(f"subdir('{name}')" for name in names_subdirs) + "\n" | ||
|
||
if not code: | ||
return | ||
|
||
with open(path_dir / "meson.build", "w", encoding="utf-8") as file: | ||
file.write(code) | ||
|
||
for path_subdir in paths_subdirs: | ||
process_directory(path_subdir) | ||
|
||
|
||
def main(): | ||
raise NotImplementedError() |