Changes between Initial Version and Version 1 of Ticket #30950, comment 6
- Timestamp:
- Dec 21, 2020, 1:52:23 PM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #30950, comment 6
initial v1 1 1 Support for PyOxidizer is important to my use case. 2 2 3 In addition to the issue of package data, for which `importlib.resources` is a good solution, there's also the matter of management commands. The current algorithm uses the standard library's `pkgutil.iter_modules`, which only works with file-system based code. A good alternative that would work for non-file code would be to use the import mechanism as follows. The following code would replace [https://github.com/django/django/blob/0a306f7da668e53af2516bfad759b52d6c650b69/django/core/management/__init__.py#L41-L73 django.core.management.get_commands()] and [https://github.com/django/django/blob/0a306f7da668e53af2516bfad759b52d6c650b69/django/core/management/__init__.py#L21-L28 django.core.management.find_commands()]. I made some effort to keep the code similar to the existing code. I dressed up some of the docstring for Sphinx in case a description of the algorithm would need to go into the docs.3 In addition to the issue of package data, for which `importlib.resources` is a good solution, there's also the matter of management commands. The current algorithm uses the standard library's `pkgutil.iter_modules`, which only works with modules located by [https://docs.python.org/3/reference/import.html#path-entry-finders path-entry finders] (cf. [https://github.com/indygreg/PyOxidizer/issues/337 indygreg/PyOxidizer#337]). A good alternative that would work for non-file code would be to use the import mechanism as follows. The following code would replace [https://github.com/django/django/blob/0a306f7da668e53af2516bfad759b52d6c650b69/django/core/management/__init__.py#L41-L73 django.core.management.get_commands()] and [https://github.com/django/django/blob/0a306f7da668e53af2516bfad759b52d6c650b69/django/core/management/__init__.py#L21-L28 django.core.management.find_commands()]. I made some effort to keep the code similar to the existing code. I dressed up some of the docstring for Sphinx in case a description of the algorithm would need to go into the docs. 4 4 5 5 {{{