Skip to content

Commit

Permalink
Ensure that top-level 'tasks' directory is loaded. (#3582)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Prescod committed Apr 14, 2023
1 parent d45cd2b commit eb22642
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cumulusci/core/config/project_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,9 @@ def _add_tasks_directory_to_python_path(self):
self.logger.debug(f"Adding {directory} to tasks.__path__")
tasks.__path__.append(directory)
if get_debug_mode():
spec = getattr(self.source, "spec", ".")
self.logger.debug(
f"After importing {self.source.spec}: tasks.__path__ {tasks.__path__}"
f"After importing {spec}: tasks.__path__ {tasks.__path__}"
)

def construct_subproject_config(self, **kwargs) -> "BaseProjectConfig":
Expand Down
1 change: 1 addition & 0 deletions cumulusci/core/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def _load_project_config(self, *args, **kwargs):
self.project_config = self.project_config_cls(
self.universal_config, *args, **kwargs
)
self.project_config._add_tasks_directory_to_python_path()

def _load_keychain(self):
if self.keychain is not None:
Expand Down
3 changes: 2 additions & 1 deletion cumulusci/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def import_global(path: str):
components = path.split(".")
module = components[:-1]
module = ".".join(module)
mod = __import__(module, fromlist=[str(components[-1])])

if get_debug_mode():
import sys
Expand All @@ -35,6 +34,8 @@ def import_global(path: str):
logger.info(f"Looking in sys.path {sys.path}")
if components[0] == "tasks":
logger.info(f"With tasks.__path__ {sys.modules['tasks'].__path__}")

mod = __import__(module, fromlist=[str(components[-1])])
return getattr(mod, str(components[-1]))


Expand Down

0 comments on commit eb22642

Please sign in to comment.