Skip to content

Python 2/3 #345

Closed
Closed

Description

@clepple

Portions of NUT rely on the first python command in $PATH being Python 2. (Fortunately, this tends to only affects those building from Git, not from a source tarball.)

Before we jump in and upgrade everything to Python 3, let's summarize what the various distributions ship by default:

  • Debian 8 (jessie): minimal install does not provide Python
    • python-minimal, which provides symlinks /usr/bin/python2 and /usr/bin/python, depends on python2.7-minimal package, which provides /usr/bin/python2.7
  • Ubuntu 12.04 (precise): same as Debian, but python-minimal is installed by default
  • Ubuntu 14.04 (trusty): same as Debian, but python-minimal is installed by default
  • Ubuntu 16.04 (xenial): same as Debian (none installed by default)
  • Arch (prior to 2010-10-18): no Python in 'base' group; /usr/bin/python pointed to python 2 (at that time /usr/bin/python2.6, not 2.7), now to python 3 (package 'python')
  • Arch (2010-10-18 through at least 2016-11-28): no Python in 'base' group; python 2 can be installed with 'python2' package, which provides /usr/bin/python2 symlink pointing to /usr/bin/python2.7.
  • Mac OS X 10.11: /usr/bin/python points to python2.7; no python2 symlink
    • Fink provides a python2 symlink as part of the python meta-package

The short answer is that python2.7 seems to be the only name that won't cause confusion.

We could probably run 2to3 and/or use six to be able to run on whatever version is available. Thoughts?

(If you have proposed changes, please commit them to a branch other than master first, thanks!)

Edit: incorporated #345 (comment) and #345 (comment)

Activity

  1. added a commit that references this issue on Nov 28, 2016
  2. aquette commented on Nov 28, 2016

    @aquette
    Member

    @clepple: not fully exact

    • Debian 8 (jessie): minimal install does not provide Python
      • python-minimal, which provides symlinks /usr/bin/python2 and /usr/bin/python, depends on python2.7-minimal package, which provides /usr/bin/python2.7

    => so /usr/bin/python is avail... once python-minimal is installed.

    Other notes:

    • the only failure is related to autogen.sh and Augeas ups.conf lens generation if "python" is not available, due to distribution issues.
    • other python scripts calls (nut-snmpinfo.py and gitlog2changelog.py) simply generate warnings in case "python" is not available

    Hence my crappy "sed" proposal, which ends up with creating a sane default scripts/augeas/nutupsconf.aug.in for distribution.

  3. zykh commented on Nov 28, 2016

    @zykh
    Contributor

    As an archer.. Arch Linux:

    • python is not installed (neither 2 nor 3) by default ('base' group),
    • python 2 can be installed with 'python2' package, which provides /usr/bin/python2 symlink pointing to /usr/bin/python2.7.
    • before 18/10/2010, /usr/bin/python pointed to python 2 (at that time /usr/bin/python2.6, not 2.7), now to python 3 (package 'python').
  4. clepple commented on Nov 29, 2016

    @clepple
    MemberAuthor

    @aquette and @zykh: thanks, I edited the original description. The "installed by default" part is fuzzy - we advise people to install the build-deps for their distribution, so they don't just have a minimal install at that point.

    For our purposes, Python 2.7 is a superset of Python 2.6. I also don't think we need to worry about distributions more than, say, five years back for bootstrapping like this (given that we have release tarballs from that time).

  5. The-Compiler commented on Nov 29, 2016

    @The-Compiler
    Contributor

    Making the script work with python 3 is trivial, see #346.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions