#35187: Django 5.0+ doesn't work with pyc files only
-------------------------------------------+------------------------
               Reporter:  Marcus Hoffmann  |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  Uncategorized    |        Version:  5.0
               Severity:  Normal           |       Keywords:
           Triage Stage:  Unreviewed       |      Has patch:  0
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+------------------------
 Since upgrading django to version 5.0.1 (5.0 untested currently) in
 [https://buildroot.org/ buildroot] (an embedded rootfs build toolkit)
 django stopped working correctly in the buildroot default configuration.
 By default buildroot compiles all installed python modules to .pyc files
 and removes the .py files.

 There's been some discussion around this but the conclusion seems to be,
 that this is an officially supported way of running cpython:
 https://github.com/python/cpython/issues/95827

 Here's a test run output of creating a new django project and invoking
 manage.py from it inside a minmal buildroot created image:
 https://gitlab.com/buildroot.org/buildroot/-/jobs/6148209453#L181

 Creating the project works but manage.py fails with:

 {{{
 Traceback (most recent call last):
   File "/opt/testsite/./manage.py", line 22, in <module>
     main()
   File "/opt/testsite/./manage.py", line 18, in main
     execute_from_command_line(sys.argv)
   File "/usr/lib/python3.12/site-
 packages/django/core/management/__init__.py", line 442, in
 execute_from_command_line
   File "/usr/lib/python3.12/site-
 packages/django/core/management/__init__.py", line 416, in execute
   File "/usr/lib/python3.12/site-packages/django/__init__.py", line 24, in
 setup
   File "/usr/lib/python3.12/site-packages/django/apps/registry.py", line
 91, in populate
   File "/usr/lib/python3.12/site-packages/django/apps/config.py", line
 193, in create
   File "/usr/lib/python3.12/importlib/__init__.py", line 90, in
 import_module
   File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
   File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
   File "<frozen importlib._bootstrap>", line 1331, in
 _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
   File "<frozen importlib._bootstrap_external>", line 994, in exec_module
   File "<frozen importlib._bootstrap>", line 488, in
 _call_with_frames_removed
   File "/usr/lib/python3.12/site-
 packages/django/contrib/admin/__init__.py", line 2, in <module>
   File "/usr/lib/python3.12/site-
 packages/django/contrib/admin/filters.py", line 12, in <module>
   File "/usr/lib/python3.12/site-
 packages/django/contrib/admin/options.py", line 33, in <module>
   File "/usr/lib/python3.12/site-
 packages/django/contrib/auth/__init__.py", line 96, in <module>
   File "/usr/lib/python3.12/site-
 packages/django/views/decorators/debug.py", line 50, in decorator
   File "/usr/lib/python3.12/inspect.py", line 1264, in getsourcelines
   File "/usr/lib/python3.12/inspect.py", line 1093, in findsource
 OSError: could not get source code
 }}}

 This seems to specifically fail somewhere in loading contrib.auth, if I
 remove (in a local test) both the 'django.contrib.admin' and
 'django.contrib.auth' apps from the list of installed apps then manage.py
 starts to work correctly.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35187>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d9e538b22-40708171-51ef-4a5d-85b2-4944ec6aad9f-000000%40eu-central-1.amazonses.com.

Reply via email to