Bug 14888

Summary: python3-django: Default version in layer not supported anymore, missing dependency for current versions
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Johannes Schrimpf <johannes.schrimpf>
Component: devtools / tool chainAssignee: Unassigned <unassigned>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: Undecided CC: meta.mr.watcher, meta.watcher, randy.macleod, workjagadeesh
Version: unspecified   
Target Milestone: ---   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
Patch to pull python3-asgiref package for python3-django. none

Description Johannes Schrimpf 2022-08-16 09:06:14 UTC
The newer meta-python versions (honister, kirkstone, master) still use python3-django version 2.2 as default preference, stating in the newer recipes that the LTS version should be build by default. However, 2.2 had end of extended support April 11, 2022. The current LTS is 3.2, which is available as recipe in the layers, but not activated as default.

https://www.djangoproject.com/download/

Additionally, python3-django version 3.2 and 4.x depend on python3-asgiref, which is missing as dependency in the recipes and not part of meta-python.
Comment 1 Johannes Schrimpf 2022-08-16 13:37:20 UTC
*** Bug 14889 has been marked as a duplicate of this bug. ***
Comment 2 Jagadeesh Krishnanjanappa 2022-08-17 14:41:27 UTC
Created attachment 4897 [details]
Patch to pull python3-asgiref package for python3-django.
Comment 3 Jagadeesh Krishnanjanappa 2022-08-17 14:43:40 UTC
Though python3-django needs python3-asgiref it does not
break while building python3-django v3.2.12 and v4.0.2.
This probably is the reason why python3-asgiref recipe 
was not added.

This can be verified with the following changes for kirkstone.

diff --git a/meta-python/recipes-devtools/python/python3-django_3.2.12.bb b/meta-python/recipes-devtools/python/python3-django_3.2.12.bb
index adbc498bd..9e9d6768d 100644
--- a/meta-python/recipes-devtools/python/python3-django_3.2.12.bb
+++ b/meta-python/recipes-devtools/python/python3-django_3.2.12.bb
@@ -10,4 +10,4 @@ RDEPENDS:${PN} += "\
 # Set DEFAULT_PREFERENCE so that the LTS version of django is built by
 # default. To build the 3.x branch,
 # PREFERRED_VERSION_python3-django = "3.2.2" can be added to local.conf
-DEFAULT_PREFERENCE = "-1"
+#DEFAULT_PREFERENCE = "-1"
diff --git a/meta-python/recipes-devtools/python/python3-django_4.0.2.bb b/meta-python/recipes-devtools/python/python3-django_4.0.2.bb
index 690b9809d..84348e0af 100644
--- a/meta-python/recipes-devtools/python/python3-django_4.0.2.bb
+++ b/meta-python/recipes-devtools/python/python3-django_4.0.2.bb
@@ -10,4 +10,4 @@ RDEPENDS:${PN} += "\
 # Set DEFAULT_PREFERENCE so that the LTS version of django is built by
 # default. To build the 4.x branch,
 # PREFERRED_VERSION_python3-django = "4.0.2" can be added to local.conf
-DEFAULT_PREFERENCE = "-1"
+#DEFAULT_PREFERENCE = "-1"

and adding any of the two lines in the conf/local.conf.
PREFERRED_VERSION_python3-django = "4.0.2"
PREFERRED_VERSION_python3-django = "3.2.12"

But yes it crashes while running /usr/bin/django-admin.
-- snip --
root@qemuarm:~# /usr/bin/django-admin
Traceback (most recent call last):
  File "/usr/bin/django-admin", line 5, in <module>
    from django.core.management import execute_from_command_line
  File "/usr/lib/python3.10/site-packages/django/core/management/__init__.py", line 13, in <module>
    from django.apps import apps
  File "/usr/lib/python3.10/site-packages/django/apps/__init__.py", line 1, in <module>
    from .config import AppConfig
  File "/usr/lib/python3.10/site-packages/django/apps/config.py", line 7, in <module>
    from django.utils.deprecation import RemovedInDjango41Warning
  File "/usr/lib/python3.10/site-packages/django/utils/deprecation.py", line 5, in <module>
    from asgiref.sync import sync_to_async
ModuleNotFoundError: No module named 'asgiref'
root@qemuarm:~#
-- snip --

With the attached [patch|https://bugzilla.yoctoproject.org/attachment.cgi?id=4897&action=edit] for kirkstone, /usr/bin/django-admin runs correctly
(though not all options are tested).

-- snip --
root@qemuarm:~# /usr/bin/django-admin shell
Python 3.10.4 (main, Mar 23 2022, 20:25:24) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>
now exiting InteractiveConsole...
root@qemuarm:~#
-- snip --

If the changes look good then I will try to push
to meta-openembedded mailing list.

Regards,
Jagadeesh
Comment 4 Randy MacLeod 2022-08-18 14:40:39 UTC
This isn't a Yocto ( bitbake or oe-core ) bug since the recipe is in meta-openembedded.
Please post a patch or report the bug to the list / layer maintainers where such things are handled: openembedded-devel@lists.openembedded.org

-- YP Triage meeting.
Comment 5 Jagadeesh Krishnanjanappa 2022-08-28 14:54:08 UTC
For the record, the patches are merged in the meta-openembedded layer at https://git.openembedded.org/meta-openembedded/log/meta-python/recipes-devtools/python.

Regards,
Jagadeesh
Comment 6 Johannes Schrimpf 2022-08-29 07:28:56 UTC
Thank you Jagadeesh!

Best regards,
Johannes