@@ -546,7 +546,19 @@ def _build_migration_manifest(
546546
547547
548548def _load_settings (filename ):
549- """Load settings module from file or default location.
549+ """Load a migration settings module.
550+
551+ Purpose:
552+ Resolve settings.py as a file-based module and keep imports local to the
553+ settings file directory for this process.
554+
555+ Best practices:
556+ Keep modules imported by settings.py in the same project/package rooted
557+ near the settings file. Let IoP manage temporary import path setup.
558+
559+ Common mistakes:
560+ Do not require users to set PYTHONPATH. Do not mutate environment
561+ variables to force imports when module/package layout should be fixed.
550562
551563 Returns:
552564 tuple: (settings_module, path_added_to_sys)
@@ -723,6 +735,20 @@ def _cleanup_sys_path(path):
723735
724736
725737def import_module_from_path (module_name , file_path ):
738+ """Import one module from an absolute file path.
739+
740+ Purpose:
741+ Execute a specific settings or component module by file location
742+ without relying on global PYTHONPATH configuration.
743+
744+ Best practices:
745+ Use absolute paths and stable module/package layout so imports resolve
746+ from the project directory containing settings.py.
747+
748+ Common mistakes:
749+ Do not patch PYTHONPATH or sys.path globally to make imports pass.
750+ Keep import fixes in project structure and import statements.
751+ """
726752 if not os .path .isabs (file_path ):
727753 raise ValueError ("The file path must be absolute" )
728754
0 commit comments