#698 Forbid the use of /usr/bin/python
Closed: accepted 6 years ago Opened 6 years ago by churchyard.

Link to the draft

https://fedoraproject.org/wiki/User:Churchyard/Packaging:Python

Link to diff

https://fedoraproject.org/w/index.php?title=User%3AChurchyard%2FPackaging%3APython&diff=498285&oldid=498137

Diff

However, packages in Fedora must (instead of should) not depend on where /usr/bin/python happens to point but instead must (instead of should) call the proper executable for the needed python major version directly, either /usr/bin/python2 or /usr/bin/python3 as appropriate. As a result of that /usr/bin/python (as well as /usr/bin/env python and similar) is also explicitly forbidden in shebangs and as a dependency of a package.

Explanation

Previously this was added as a SHOULD rule in #327, however the time when we switch /usr/bin/python to Python 3 is getting closer and closer. We need a strict guideline that forbids the usage of /usr/bin/python, so we can start filling bugs, fixing packages, etc. This guidelines change is a part of Finalizing Fedora's Switch to Python 3.


Should the explanation also mention that in advance of Fedora changing the default, we'd like to allow admins to change their local default without breaking any system packages?

They would also benefit form this change, yes. However, it is IMO not our primary reason, nor we will encourage that. Also, I don't think there will be much time in between getting rid of /usr/bin/python usage in packages and changing the default. Nevertheless the sysadmins might want to change the default after the switch (i.e. back to Python 2) and if nothing in Fedora uses /usr/bin/python any more, it should be safe for them to do so.

@churchyard That second part sounds like a good thing to make an explicit design goal then: when the default changes, we want to provide a supported way for admins to change it back (at least for a couple more releases after the default changes)

Metadata Update from @tibbs:
- Issue tagged with: meeting

6 years ago

+1 to the concept to me. As to the draft itself, well, the ban on use of env doesn't really follow from the ban on use of /usr/bin/python so the language is a little confusing.

I note that the problem with env isn't really Python-specific, so I filed #700 regarding a global ban. But anyway, for cleaner language I propose just using this text for the relevant section:

Multiple Python Runtimes

Each Python runtime corresponds to a binary of the form /usr/bin/python$MAJOR.$MINOR. /usr/bin/python$MAJOR is also provided. In addition, for end user convenience one of these python runtimes is designated as the "system runtime" and is run when /usr/bin/python is called.

The following restrictions apply:

  • Packages MUST NOT contain dependencies on '/usr/bin/python'.
  • Packaged software MUST NOT on which version of Python is provided by the system runtime, or even that it exists on the system.
  • Installed executables MUST NOT reference /usr/bin/python in shebang lines or call /usr/bin/python directly.
  • Installed executables MUST NOT make use of env in shebang lines.

Packaged software MUST NOT on which version of Python is provided by the system runtime, or even that it exists on the system.

There's a verb missing.

Note that firstly, I didn't include anything about /usr/bin/env python, because I was confident it is already forbidden:

https://fedoraproject.org/w/index.php?title=User%3AChurchyard%2FPackaging%3APython&diff=498138&oldid=498137

Later I found out that /usr/bin/env ... is not actually forbidden, so I've added that as well. Given #700, we can revert back to https://fedoraproject.org/w/index.php?title=User:Churchyard/Packaging:Python&oldid=498138 or use your text.

I think I just had hopes that people would realize how bad an idea env is and... not use it in their packages. 1277 packages prove me wrong.

And yeah, the missing verb there is "rely". I am trying to avoid "depend" unless specifically referring to a package dependency.

I think I prefer the original text.

We discussed this at this weeks meeting (https://meetbot-raw.fedoraproject.org/fedora-meeting-2/2017-08-09/fpc.2017-08-09-17.00.txt):

  • x698 Forbid the use of /usr/bin/python (geppetto, 17:18:57)
  • ACTION: Forbid the use of /usr/bin/python (+1:5, 0:0, -1:0)
    (geppetto, 17:30:43)

Metadata Update from @james:
- Issue untagged with: meeting
- Issue assigned to tibbs
- Issue tagged with: writeup

6 years ago

Announcement text:

The python guidelines were modified to forbid the use of /usr/bin/python in shebang lines or as a dependency of a package.

Metadata Update from @tibbs:
- Issue untagged with: writeup
- Issue tagged with: announce

6 years ago

Metadata Update from @tibbs:
- Issue untagged with: announce
- Issue close_status updated to: accepted
- Issue status updated to: Closed (was: Open)

6 years ago

Login to comment on this ticket.

Metadata