Hello!

Current situation
=================
Without specifying USE_PYTHON in /etc/make.conf ebuilds based on the
python eclass will install packages for no more ABIs than the two active
versions on the 2.x and 3.x lines.  To give an example: with Python 2.6,
2.7 and 3.1 installed and 2.7 set as the active 2.x Python version I
would get files installed for python 2.7 and 3.1, but not 2.6.

Is that a sane default?  Especially when a new slot of Python arrives at
the Gentoo tree, you run into situations with two slots of Python 2.x
installed.  To have packages functioning with both, you would need a
custom USE_PYTHON line like USE_PYTHON="2.6 2.7" - otherwise one of
these slots' Python will be very limited.

This problem is made worse by the fact that USE_PYTHON has almost no
documentation.  This bug shows well, that the current behavior is a
surprising troublemaker:

https://bugs.gentoo.org/show_bug.cgi?id=347153


Proposed new situation
======================
If I have a version of Python installed, it should be usable well.
So USE_PYTHON is derived from the list of all available Python slots.
Excluded are ABIs restricted by an ebuild, say by a line like

  RESTRICT_PYTHON_ABIS="3.*"

for software that does not build with Python 3.x.


Proposed code
=============
I would love to just pass a patch here - I have two files to diff
between - but (due to the algorithm diff works with) the patch is much
less clear as the relevant excerpt itself.

If you want a patch or the file version get my modified python.eclass
file from here:
http://hartwork.org/public/python.eclass

So now comes the excerpt (with tabs converted to double spaces just for
this mail).  The code is meant to fill variable PYTHON_ABIS with content
like "2.6 2.7" in case of no USE_PYTHON line around.

=======================================================================
  debug-print 'USE_PYTHON not specified in make.conf, deriving default'
  # - include all installed ABIs
  # - but exclude those restricted by the ebuild

  local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI
python_versions

  restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}"
  python_versions=("${_cpython2_supported_ab...@]}"
"${_cpython3_supported_ab...@]}")

  for PYTHON_ABI in ${python_versio...@]} ; do
    # ABI available?
    local interpreter="${EPREFIX}"/usr/bin/python${PYTHON_ABI}
    if [[ ! -x "${interpreter}" ]]; then
      debug-print "Disabling ABI ${PYTHON_ABI} (interpreter
${interpreter} missing)"
      continue
    fi

    # ABI restricted by ebuild?
    support_ABI="1"
    while read restricted_ABI; do
      if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
        support_ABI="0"
        break
      fi
    done <<< "${restricted_ABIs}"
    if [[ "${support_ABI}" != "1" ]]; then
      debug-print "Disabling ABI ${PYTHON_ABI} (due to restrictions from
the ebuild)"
      continue
    fi

    debug-print "Enabling ABI ${PYTHON_ABI}"
    export PYTHON_ABIS+="${PYTHON_ABIS:+ }${PYTHON_ABI}"
  done

  export PYTHON_ABIS="${PYTHON_ABIS% }"
  debug-print "PYTHON_ABIS now is '${PYTHON_ABIS}'"
=======================================================================

Please review the proposal and above code.  Thanks in advance.
ECLASS_DEBUG_OUTPUT=on may be of use when testing.

Best,



Sebastian

Reply via email to