Bug 1542436

Summary: python3-django requires Python 2
Product: [Fedora] Fedora Reporter: Iryna Shcherbina <ishcherb>
Component: python-djangoAssignee: Matthias Runge <mrunge>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: bkabrda, jakub.dornak, jal233, mhroncok, michel, mrunge, pviktori, sgallagh
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-07 11:32:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1340802    

Description Iryna Shcherbina 2018-02-06 11:13:12 UTC
After the latest update python3-django RPM started to require Python 2:

$ dnf repoquery --disablerepo=* --enablerepo=rawhide --requires python3-django
/usr/bin/python2
/usr/bin/python3
python(abi) = 3.6
python-django-bash-completion = 2.0.2-1.fc28
python3-pytz

Apparently the shebangs in the following 2 files were mangled from /usr/bin/env python to /usr/bin/python2:

$ grep -r usr/bin/python2
usr/lib/python3.6/site-packages/django/conf/project_template/manage.py-tpl:#!/usr/bin/python2
usr/lib/python3.6/site-packages/django/bin/django-admin.py:#!/usr/bin/python2

I am not sure if it is correct, maybe shebangs mangling should be disabled in this case, or both scripts should be switched to non-executable?

Comment 1 Miro Hrončok 2018-02-06 16:30:58 UTC
Disabling the mangler will hide the issue. We should either change the shebangs to python3 or make the files non-executable. With the template file, this might bring problems (as the templating mechanism may just preserve the executable flag instead of setting it directly).

We should treat those two cases separately:

 * .../site-packages/django/bin/django-admin.py

This should be changed to `/usr/bin/python3` if needed, or removed and `chmod -x`, if not actually needed.


 * .../site-packages/django/conf/project_template/manage.py-tpl

This should be `chmod -x` and check whether it doesn't break anything. We should consider pushing this upstream (i.e. do not set executable permission on template file, but instead set it after the template file is copied somewhere).
If this approach is impossible, the mangling should be disabled as a workaround until a path based opt-out is provided. See also bug 1541318.

Comment 2 Matthias Runge 2018-02-07 11:32:34 UTC
thanks for the heads-up. It is fixed in 2.0.2-2

Comment 3 Vít Ondruch 2018-02-07 11:41:24 UTC
The shebang is mangled only in executable files. Does the template file need to have executable bit set?

Comment 4 Matthias Runge 2018-02-07 12:03:20 UTC
I can't really say for sure. 

The template file is used as a template to be copied in all new generated projects. The template then named manage.py is actually an executable python script.

That's why I'd choose to keep it executable.

Comment 5 Miro Hrončok 2018-02-07 17:57:59 UTC
Apparently, the template being executable is the only source of information that determines that the target file will be executable as well. Changing this to something else would require a new source of information about the executable flag (the system is used for multiple files, some executable, some not).

See https://github.com/django/django/blob/248fa208cb2c7607fb7a464238fb8ebe62e6a54c/django/core/management/templates.py#L170 and lines around.

I say we keep it executable to stay close to upstream.