There's no reason to assume that sys.path is an appropriate location for generating code. Specifically that doesn't work with extend_sys_path which puts the additional directories at the end of sys.path. In order to create a new migrations module, instead of using an arbitrary entry from sys.path, import as much as possible from the path to the module, then create missing submodules from there. Without this change, the tests introduced in the following commit fail, which seems sufficient to prevent regressions for such a refactoring.
|Failed to load latest commit information.|
|backends||Fixed signature of BaseDatabaseOperations.date_interval_sql() and doc…|
|migrations||Prevented makemigrations from writing in sys.path.|
|models||Fixed #24381 -- removed ForeignObjectRel opts and to_opts|
|__init__.py||Fixed #21430 -- Added a RuntimeWarning when unpickling Models and Que…|
|transaction.py||Sorted imports with isort; refs #23860.|
|utils.py||Fixed #24351, #24346 -- Changed the signature of allow_migrate().|