Rename sys_path_hacks/ to import_shims/
The old folder name is somewhat confusing, because the folder contains shims to _compensate for the removal of sys.path hacks_, but does not contain the sys.path hacks themselves. Furthermore, this import_shims/ system could also be used for other import path changes, such as turning the locally-installed packages in common/lib/ into regular, importable modules (e.g. `from common.lib.xmodule import abc` instead of `from xmodule import abc`). So, a name that is not specific to the sys.path hacks may be better in the medium-to-long term. Along the same lines, we also rename SysPathHackWarning to DeprecatedEdxPlatformImportWarning.
This commit is contained in:
committed by
Kyle McCormick
parent
644963255c
commit
090e10683c
@@ -24,11 +24,11 @@ In order to simplify the edx-platform code environment, we will remove the modif
|
||||
|
||||
This deprecation will take place in the following steps:
|
||||
|
||||
1. Add a new folder (``sys_path_hacks``) to isolate the code used for deprecation warnings.
|
||||
1. Add a new folder (``import_shims``) to isolate the code used for deprecation warnings.
|
||||
|
||||
2. For every module importable using the ``sys.path`` style (for instance, ``courseware``), duplicate that module structure into the ``sys_path_hacks/lms`` (or ``sys_path_hacks/studio``) directory. Each file in that directory should do a wild-card import of the corresponding ``lms.djangoapps.`` module, and should log a warning indicating where it was imported from. For example, in ``sys_path_hacks/lms/courseware/views/views.py``, it will wild-card import ``from lms.djangoapps.courseware.views.views import *``. The ``sys_path_hacks/un_sys_path.sh`` script will generate these files.
|
||||
2. For every module importable using the ``sys.path`` style (for instance, ``courseware``), duplicate that module structure into the ``import_shims/lms`` (or ``import_shims/studio``) directory. Each file in that directory should do a wild-card import of the corresponding ``lms.djangoapps.`` module, and should log a warning indicating where it was imported from. For example, in ``import_shims/lms/courseware/views/views.py``, it will wild-card import ``from lms.djangoapps.courseware.views.views import *``. The ``import_shims/generate_shims.sh`` script will generate these files.
|
||||
|
||||
3. The ``sys.path`` modification will be changed to point to ``sys_path_hacks/lms``, rather than ``lms/djangoapps``. At this point, any code that references the modules directly will trigger warnings with logging about where the imports were coming from (to drive future cleanup efforts). The warnings will be instances of ``SysPathHackWarning`` (subclass of ``DeprecationWarning``).
|
||||
3. The ``sys.path`` modification will be changed to point to ``import_shims/lms``, rather than ``lms/djangoapps``. At this point, any code that references the modules directly will trigger warnings with logging about where the imports were coming from (to drive future cleanup efforts). The warnings will be instances of ``DeprecatedEdxPlatformImportWarning`` (subclass of ``DeprecationWarning``).
|
||||
|
||||
4. Fix all instances where the ``sys.path``-based modules were ``patch``-ed in unit tests, as those patches no longer work.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user