From 2f7ccc1d2db7a93e0485ba2db98f62eaf35c113f Mon Sep 17 00:00:00 2001 From: Dominik George <dominik.george@teckids.org> Date: Fri, 12 Feb 2021 15:45:52 +0100 Subject: [PATCH] Align with Django 3.1.6 behaviour for own management wrappers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > commit ec6d2531c59466924b645f314ac33f54470d7ac3 > Author: William Schwartz <wkschwartz@gmail.com> > Date: Mon Jan 4 08:50:49 2021 -0600 > > Fixed #32314 -- Fixed detection when started non-django modules with "python -m" in autoreloader. > > django.utils.autoreload.get_child_arguments() detected when Python was > started with the `-m` option only for `django` module. This commit > changes the logic to check __spec__, see > https://docs.python.org/3/reference/import.html#main-spec > > Now packages can implement their own __main__ with the runserver > command. Thanks to William for breaking the API in a a.b.c.d.e patch-level release ♥! --- aleksis/core/{util/manage.py => __main__.py} | 5 +++++ pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) rename aleksis/core/{util/manage.py => __main__.py} (77%) diff --git a/aleksis/core/util/manage.py b/aleksis/core/__main__.py similarity index 77% rename from aleksis/core/util/manage.py rename to aleksis/core/__main__.py index 64441f62d..1005582cc 100644 --- a/aleksis/core/util/manage.py +++ b/aleksis/core/__main__.py @@ -9,4 +9,9 @@ from django.core.management import execute_from_command_line def aleksis_cmd(): """Run django-admin command with correct settings path.""" os.environ.setdefault("DJANGO_SETTINGS_MODULE", "aleksis.core.settings") + sys.argv[0] = os.path.dirname(__file__) execute_from_command_line(sys.argv) + + +if __name__ == "__main__": + sys.exit(aleksis_cmd()) diff --git a/pyproject.toml b/pyproject.toml index c9aeb3938..ef322dec6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -103,7 +103,7 @@ celery = ["Celery", "django-celery-results", "django-celery-beat", "django-celer aleksis-builddeps = "*" [tool.poetry.scripts] -aleksis-admin = 'aleksis.core.util.manage:aleksis_cmd' +aleksis-admin = 'aleksis.core.__main__:aleksis_cmd' [tool.black] line-length = 100 -- GitLab