Fix for issue #59

Relative paths work great for running as a script.
But break when running as a module since there is no `src/` folder to mention.
This should clear that up as the `src/` now lives under wherever the python package was installed.
This commit is contained in:
Anton Hvornum 2020-11-01 23:01:41 +00:00 committed by GitHub
parent 66e495e994
commit 57eef46f95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -33,6 +33,10 @@ def run_as_a_module():
if f'{profile}.py' not in library:
raise ProfileNotFound(f'Could not locate {profile}.py among the example files.')
# Swap the working dir, otherwise certain relative lookups won't work within archinstall.
# Mainly to avoid https://github.com/Torxed/archinstall/issues/59
os.chdir(os.path.abspath(os.path.dirname(__file__)))
# Import and execute the chosen `<profile>.py`:
spec = importlib.util.spec_from_file_location(
library[f"{profile}.py"],