Add a .pth to the onedir env to ensure packages in extras are importable

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-05-02 22:02:12 +01:00 committed by Pedro Algarvio
parent 42d3eaa6e6
commit 3584921fc6
2 changed files with 9 additions and 0 deletions

1
changelog/64192.fixed.md Normal file
View file

@ -0,0 +1 @@
Add a `.pth` to the onedir env to ensure packages in extras are importable.

View file

@ -538,6 +538,14 @@ def salt_onedir(
shutil.rmtree(onedir_env / "etc", onerror=errfn)
shutil.rmtree(onedir_env / "Library", onerror=errfn)
# TODO: Fix hardcoded 3.10
dest_path = onedir_env / "lib" / "python3.10" / "site-packages" / "extras.pth"
ctx.info(f"Writing '{dest_path}' ...")
dest_path.write_text(
'import sys, pathlib; extras = str(pathlib.Path(__file__).parent.parent.parent / "extras-{}.{}".format(*sys.version_info)); '
"extras not in sys.path and sys.path.insert(0, extras)\n"
)
def _check_pkg_build_files_exist(ctx: Context, **kwargs):
for name, path in kwargs.items():