Expand env vars for `custom_modules` build option

The order of conversion is also changed to ensure that the resulting
path can be properly validated later on.

(cherry picked from commit 80249e7190)
This commit is contained in:
Andrii Doroshenko (Xrayez) 2020-07-10 15:57:53 +03:00 committed by Rémi Verschelde
parent e76a9a51df
commit 670205a22f
1 changed files with 3 additions and 2 deletions

View File

@ -201,14 +201,15 @@ void unregister_module_types() {
def convert_custom_modules_path(path):
if not path:
return path
path = os.path.realpath(os.path.expanduser(os.path.expandvars(path)))
err_msg = "Build option 'custom_modules' must %s"
if not os.path.isdir(path):
raise ValueError(err_msg % "point to an existing directory.")
if os.path.realpath(path) == os.path.realpath("modules"):
if path == os.path.realpath("modules"):
raise ValueError(err_msg % "be a directory other than built-in `modules` directory.")
if is_module(path):
raise ValueError(err_msg % "point to a directory with modules, not a single module.")
return os.path.realpath(os.path.expanduser(path))
return path
def disable_module(self):