Instead of the floating patches and p-d-ng modifications I sent
earlier, here are the two complete (so far, well, initial :P) eclasses
for review.
They are designed as 'mostly' drop-in python-distutils-ng replacement.
--
Best regards,
Michał Górny
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: python-r1
# @MAINTAINER:
# Python herd <python@gentoo.org>
# @AUTHOR:
# Author: MichaÅ? Górny <mgorny@gentoo.org>
# Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
# @BLURB: A common, simple eclass for Python packages.
# @DESCRIPTION:
# A common eclass providing helper functions to build and install
# packages supporting being installed for multiple Python
# implementations.
#
# This eclass sets correct IUSE and REQUIRED_USE. It exports PYTHON_DEPS
# and PYTHON_USEDEP so you can create correct dependencies for your
# package easily. It also provides methods to easily run a command for
# each enabled Python implementation and duplicate the sources for them.
case "${EAPI}" in
0|1|2|3)
die "Unsupported EAPI=${EAPI} (too old) for ${ECLASS}"
;;
4)
# EAPI=4 needed for REQUIRED_USE
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
;;
esac
# @ECLASS-VARIABLE: _PYTHON_ALL_IMPLS
# @INTERNAL
# @DESCRIPTION:
# All supported Python implementations, most preferred last.
_PYTHON_ALL_IMPLS=(
jython2_5
pypy1_8 pypy1_9
python3_1 python3_2
python2_5 python2_6 python2_7
)
# @ECLASS-VARIABLE: PYTHON_COMPAT
# @DESCRIPTION:
# This variable contains a space separated list of Python
# implementations a package supports. It must be set before
# the `inherit' call. The default is to enable all implementations.
#
# PYTHON_COMPAT can be either a scalar or an array. If it's a scalar,
# the eclass will implicitly convert it to an array.
: ${PYTHON_COMPAT:=${_PYTHON_ALL_IMPLS[@]}}
# @ECLASS-VARIABLE: PYTHON_REQ_USE
# @DEFAULT_UNSET
# @DESCRIPTION:
# The list of USEflags required to be enabled on the chosen Python
# implementations, formed as a USE-dependency string. It should be valid
# for all implementations in PYTHON_COMPAT, so it may be necessary to
# use USE defaults.
#
# Example:
# @CODE
# PYTHON_REQ_USE="gdbm,ncurses(-)?"
# @CODE
#
# Will cause the Python dependencies to look like:
# @CODE
# python_targets_pythonX_Y? (
# dev-lang/python:X_Y[gdbm,ncurses(-)?] )
# @CODE
# @ECLASS-VARIABLE: PYTHON_DEPS
# @DESCRIPTION:
# This is an eclass-generated Python dependency string for all
# implementations listed in PYTHON_COMPAT. It should be used
# in RDEPEND and/or DEPEND like:
#
# @CODE
# RDEPEND="${PYTHON_DEPS}
# dev-foo/mydep"
# DEPEND="${RDEPEND}"
# @CODE
# @ECLASS-VARIABLE: PYTHON_USEDEP
# @DESCRIPTION:
# This is an eclass-generated USE-dependency string which can be used to
# depend on another Python package being built for the same Python
# implementations. It should be used like:
#
# @CODE
# RDEPEND="dev-python/foo[${PYTHON_USEDEP}]"
# @CODE
PYTHON_COMPAT=( ${PYTHON_COMPAT[@]} )
_python_set_globals() {
local flags=( "${PYTHON_COMPAT[@]/#/python_targets_}" )
local optflags=${flags[@]/%/?}
PYTHON_DEPS=
local i
for i in ${PYTHON_COMPAT[@]}; do
local d
case ${i} in
python*)
d='dev-lang/python';;
jython*)
d='dev-java/jython';;
pypy*)
d='dev-python/pypy';;
*)
die "Invalid implementation: ${i}"
esac
local v=${i##*[a-z]}
local usestr
[[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]"
PYTHON_DEPS+=" python_targets_${i}? (
${d}:${v/_/.}${usestr} )"
done
}
_python_set_globals
# @FUNCTION: python_get_PYTHON
# @USAGE: <impl>
# @DESCRIPTION:
# Get the Python executable name for the given implementation. Please
# note that this this function returns the 'basename' only.
# If using it for a hashbang, please use #!/usr/bin/env.
python_get_PYTHON() {
local impl=${1/_/.}
case "${impl}" in
python*|jython*)
echo ${impl}
;;
pypy*)
echo pypy-c${impl#pypy}
;;
*)
die "Invalid argument to python_get_PYTHON: ${1}"
;;
esac
}
# @FUNCTION: python_copy_sources
# @DESCRIPTION:
# Create a single copy of the package sources (${S}) for each enabled
# Python implementation.
python_copy_sources() {
local impl
local bdir=${BUILD_DIR:-${S}}
einfo "Will copy sources from ${S}"
# the order is irrelevant here
for impl in ${PYTHON_COMPAT[@]}; do
if use python_targets_${impl}
then
local BUILD_DIR=${bdir%%/}-${impl}
einfo "${impl}: copying to ${BUILD_DIR}"
cp -pr "${S}" "${BUILD_DIR}" || die
fi
done
}
# @FUNCTION: python_foreach_impl
# @USAGE: <command> [<args>...]
# @DESCRIPTION:
# Run the given command for each of the enabled Python implementations.
# If additional parameters are passed, they will be passed through
# to the command. If the command fails, python_foreach_impl dies.
# If necessary, use ':' to force a successful return.
#
# Before the command is run, EPYTHON is set to the name of the current
# Python implementation, PYTHON is set to the correct Python executable
# name and exported, and BUILD_DIR is set to a 'default' build directory
# for given implementation (e.g. ${BUILD_DIR:-${S}}-python2_7).
#
# The command is run inside the build directory. If it doesn't exist
# yet, it is created (as an empty directory!). If your build system does
# not support out-of-source builds, you will likely want to use
# python_copy_sources first.
python_foreach_impl() {
local impl
local bdir=${BUILD_DIR:-${S}}
for impl in ${_PYTHON_ALL_IMPLS[@]}; do
if has ${impl} ${PYTHON_COMPAT[@]} && use python_targets_${impl}
then
local PYTHON=$(python_get_PYTHON "${impl}")
local EPYTHON=${impl}
local BUILD_DIR=${bdir%%/}-${impl}
export PYTHON
mkdir -p "${BUILD_DIR}" || die
pushd "${BUILD_DIR}" &>/dev/null || die
einfo "${EPYTHON}: running ${@}"
"${@}" || die "${EPYTHON}: ${1} failed"
popd || die
fi
done
}
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: distutils-r1
# @MAINTAINER:
# Python herd <python@gentoo.org>
# @AUTHOR:
# Author: MichaÅ? Górny <mgorny@gentoo.org>
# Based on the work of: Krzysztof Pawlik <nelchael@gentoo.org>
# @BLURB: A simple eclass to build Python packages using distutils.
# @DESCRIPTION:
# A simple eclass providing functions to build Python packages using
# the distutils build system. It exports phase functions for all
# the src_* phases. Each of the phases runs two pseudo-phases:
# python_..._all() (e.g. python_prepare_all()) once in ${S}, then
# python_...() (e.g. python_prepare()) for each implementation
# (see: python_foreach_impl() in python-r1).
#
# In distutils-r1_src_prepare(), the 'all' function is run before
# per-implementation ones (because it creates the implementations),
# per-implementation functions are run in a random order.
#
# In remaining phase functions, the per-implementation functions are run
# before the 'all' one, and they are ordered from the least to the most
# preferred implementation (so that 'better' files overwrite 'worse'
# ones).
#
# If the ebuild doesn't specify a particular pseudo-phase function,
# the default one will be used (distutils-r1_...). Defaults are provided
# for all per-implementation pseudo-phases, python_prepare_all()
# and python_install_all(); whenever writing your own pseudo-phase
# functions, you should consider calling the defaults (and especially
# distutils-r1_python_prepare_all).
#
# Please note that distutils-r1 sets RDEPEND and DEPEND for you.
case "${EAPI}" in
0|1|2|3)
die "Unsupported EAPI=${EAPI} (too old) for ${ECLASS}"
;;
4)
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
;;
esac
# @FUNCTION: distutils-r1_python_prepare_all
# @DESCRIPTION:
# The default python_prepare_all(). It applies the patches from PATCHES
# array, then user patches and finally calls python_copy_sources to
# create copies of resulting sources for each Python implementation.
distutils-r1_python_prepare_all() {
[[ ${PATCHES} ]] && epatch "${PATCHES[@]}"
epatch_user
# create source copies for each implementation
python_copy_sources
}
# @FUNCTION: distutils-r1_python_prepare
# @DESCRIPTION:
# The default python_prepare(). Currently it is a no-op
# but in the future it may apply implementation-specific quirks
# to the build system.
distutils-r1_python_prepare() {
:
}
# @FUNCTION: distutils-r1_python_configure
# @DESCRIPTION:
# The default python_configure(). Currently a no-op.
distutils-r1_python_configure() {
:
}
# @FUNCTION: distutils-r1_python_compile
# @DESCRIPTION:
# The default python_compile(). Runs 'setup.py build' using the correct
# Python implementation.
distutils-r1_python_compile() {
cd "${BUILD_DIR}" || die
"${PYTHON}" setup.py build || die
}
# @FUNCTION: distutils-r1_python_test
# @DESCRIPTION:
# The default python_test(). Currently a no-op.
distutils-r1_python_test() {
:
}
# @FUNCTION: distutils-r1_rename_scripts
# @DESCRIPTION:
# Renames installed Python scripts to be implementation-suffixed.
# ${PYTHON} has to be set to the expected Python executable (which
# hashbang will be grepped for), and ${EPYTHON} to the implementation
# name (for new name).
distutils-r1_rename_scripts() {
local dir f
local wrapdir=${T}/distutils_wrappers
# XXX: change this if we ever allow directories in bin/sbin
for dir in bin sbin usr/bin usr/sbin; do
for f in "${D}"/${dir}/*; do
if [[ -x ${f} ]]; then
if [[ "$(head -n 1 "${f}")" == '#!'*${PYTHON}* ]]
then
local newf=${f}-${EPYTHON}
mv "${f}" "${newf}" || die
mkdir -p "${wrapdir}"/${dir}
ln -fs "${newf##*/}"
"${wrapdir}"/${dir}/"${f##*/}" || die
fi
fi
done
done
}
# @FUNCTION: distutils-r1_python_install
# @DESCRIPTION:
# The default python_install(). Runs 'setup.py install' using
# the correct Python implementation, and appending the optimization
# flags. Then calls distutils-r1_rename_scripts.
distutils-r1_python_install() {
local flags
case "${EPYTHON}" in
jython*)
flags='--compile';;
*)
flags='--compile -O2';;
esac
# XXX: where does it come from?!
unset PYTHONDONTWRITEBYTECODE
cd "${BUILD_DIR}" || die
"${PYTHON}" setup.py install ${flags} --root="${D}" || die
distutils-r1_rename_scripts
}
# @FUNCTION: distutils-r1_python_install_all
# @DESCRIPTION:
# The default python_install_all(). It creates wrappers
# for the implementation-suffixed executables.
distutils-r1_python_install_all() {
local wrapdir=${T}/distutils_wrappers
if [[ -d ${wrapdir} ]]; then
cp -r "${wrapdir}/." "${D}" || die
fi
}
distutils-r1_src_prepare() {
# common preparations
if declare -f python_prepare_all >/dev/null; then
python_prepare_all
else
distutils-r1_python_prepare_all
fi
if declare -f python_prepare >/dev/null; then
python_foreach_impl python_prepare
else
distutils-r1_python_prepare
fi
}
distutils-r1_src_configure() {
if declare -f python_configure >/dev/null; then
python_foreach_impl python_configure
else
distutils-r1_python_configure
fi
if declare -f python_configure_all >/dev/null; then
python_configure_all
fi
}
distutils-r1_src_compile() {
if declare -f python_compile >/dev/null; then
python_foreach_impl python_compile
else
python_foreach_impl distutils-r1_python_compile
fi
if declare -f python_compile_all >/dev/null; then
python_compile_all
fi
}
distutils-r1_src_test() {
if declare -f python_test >/dev/null; then
python_foreach_impl python_test
else
distutils-r1_python_test
fi
if declare -f python_test_all >/dev/null; then
python_test_all
fi
}
distutils-r1_src_install() {
if declare -f python_install >/dev/null; then
python_foreach_impl python_install
else
python_foreach_impl distutils-r1_python_install
fi
if declare -f python_install_all >/dev/null; then
python_install_all
else
distutils-r1_python_install_all
fi
}
09-29-2012, 10:00 AM
Tomáš Chvátal
Initial python-r1.eclass & distutils-r1.eclass
2012/9/29 Michał Górny <mgorny@gentoo.org>:
> Hello,
>
> Instead of the floating patches and p-d-ng modifications I sent
> earlier, here are the two complete (so far, well, initial :P) eclasses
> for review.
>
> They are designed as 'mostly' drop-in python-distutils-ng replacement.
>
Hi,
the eclasses look pretty, so good job,
just one question tho, would it be possible to use more
debug-something calls so the log file would be populated automatically
with whats going on (same like eg git-2 eclass)?
Cheers
Tom
09-29-2012, 10:20 AM
Markos Chandras
Initial python-r1.eclass & distutils-r1.eclass
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
On 09/29/2012 09:53 AM, Micha? Górny wrote:
> Hello,
>
> Instead of the floating patches and p-d-ng modifications I sent
> earlier, here are the two complete (so far, well, initial :P)
> eclasses for review.
>
> They are designed as 'mostly' drop-in python-distutils-ng
> replacement.
>
Hi,
Are you saying that you are going to remove the python-distutils-ng
eclass in favour of the new eclasses? I don't quite understand the
reasons to be honest.
> 2012/9/29 Michał Górny <mgorny@gentoo.org>:
> > Hello,
> >
> > Instead of the floating patches and p-d-ng modifications I sent
> > earlier, here are the two complete (so far, well, initial :P) eclasses
> > for review.
> >
> > They are designed as 'mostly' drop-in python-distutils-ng replacement.
> >
> Hi,
>
> the eclasses look pretty, so good job,
> just one question tho, would it be possible to use more
> debug-something calls so the log file would be populated automatically
> with whats going on (same like eg git-2 eclass)?
> 2012/9/29 Michał Górny <mgorny@gentoo.org>:
> > Hello,
> >
> > Instead of the floating patches and p-d-ng modifications I sent
> > earlier, here are the two complete (so far, well, initial :P) eclasses
> > for review.
> >
> > They are designed as 'mostly' drop-in python-distutils-ng replacement.
> >
> Hi,
>
> the eclasses look pretty, so good job,
> just one question tho, would it be possible to use more
> debug-something calls so the log file would be populated automatically
> with whats going on (same like eg git-2 eclass)?
Try now :P.
--
Best regards,
Michał Górny
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: python-r1
# @MAINTAINER:
# Python herd <python@gentoo.org>
# @AUTHOR:
# Author: MichaÅ? Górny <mgorny@gentoo.org>
# Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
# @BLURB: A common, simple eclass for Python packages.
# @DESCRIPTION:
# A common eclass providing helper functions to build and install
# packages supporting being installed for multiple Python
# implementations.
#
# This eclass sets correct IUSE and REQUIRED_USE. It exports PYTHON_DEPS
# and PYTHON_USEDEP so you can create correct dependencies for your
# package easily. It also provides methods to easily run a command for
# each enabled Python implementation and duplicate the sources for them.
case "${EAPI}" in
0|1|2|3)
die "Unsupported EAPI=${EAPI} (too old) for ${ECLASS}"
;;
4)
# EAPI=4 needed for REQUIRED_USE
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
;;
esac
# @ECLASS-VARIABLE: _PYTHON_ALL_IMPLS
# @INTERNAL
# @DESCRIPTION:
# All supported Python implementations, most preferred last.
_PYTHON_ALL_IMPLS=(
jython2_5
pypy1_8 pypy1_9
python3_1 python3_2
python2_5 python2_6 python2_7
)
# @ECLASS-VARIABLE: PYTHON_COMPAT
# @DESCRIPTION:
# This variable contains a space separated list of Python
# implementations a package supports. It must be set before
# the `inherit' call. The default is to enable all implementations.
#
# PYTHON_COMPAT can be either a scalar or an array. If it's a scalar,
# the eclass will implicitly convert it to an array.
: ${PYTHON_COMPAT:=${_PYTHON_ALL_IMPLS[@]}}
# @ECLASS-VARIABLE: PYTHON_REQ_USE
# @DEFAULT_UNSET
# @DESCRIPTION:
# The list of USEflags required to be enabled on the chosen Python
# implementations, formed as a USE-dependency string. It should be valid
# for all implementations in PYTHON_COMPAT, so it may be necessary to
# use USE defaults.
#
# Example:
# @CODE
# PYTHON_REQ_USE="gdbm,ncurses(-)?"
# @CODE
#
# Will cause the Python dependencies to look like:
# @CODE
# python_targets_pythonX_Y? (
# dev-lang/python:X_Y[gdbm,ncurses(-)?] )
# @CODE
# @ECLASS-VARIABLE: PYTHON_DEPS
# @DESCRIPTION:
# This is an eclass-generated Python dependency string for all
# implementations listed in PYTHON_COMPAT. It should be used
# in RDEPEND and/or DEPEND like:
#
# @CODE
# RDEPEND="${PYTHON_DEPS}
# dev-foo/mydep"
# DEPEND="${RDEPEND}"
# @CODE
# @ECLASS-VARIABLE: PYTHON_USEDEP
# @DESCRIPTION:
# This is an eclass-generated USE-dependency string which can be used to
# depend on another Python package being built for the same Python
# implementations. It should be used like:
#
# @CODE
# RDEPEND="dev-python/foo[${PYTHON_USEDEP}]"
# @CODE
PYTHON_COMPAT=( ${PYTHON_COMPAT[@]} )
_python_set_globals() {
local flags=( "${PYTHON_COMPAT[@]/#/python_targets_}" )
local optflags=${flags[@]/%/?}
PYTHON_DEPS=
local i
for i in ${PYTHON_COMPAT[@]}; do
local d
case ${i} in
python*)
d='dev-lang/python';;
jython*)
d='dev-java/jython';;
pypy*)
d='dev-python/pypy';;
*)
die "Invalid implementation: ${i}"
esac
local v=${i##*[a-z]}
local usestr
[[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]"
PYTHON_DEPS+=" python_targets_${i}? (
${d}:${v/_/.}${usestr} )"
done
}
_python_set_globals
# @FUNCTION: python_get_PYTHON
# @USAGE: <impl>
# @DESCRIPTION:
# Get the Python executable name for the given implementation. Please
# note that this this function returns the 'basename' only.
# If using it for a hashbang, please use #!/usr/bin/env.
python_get_PYTHON() {
debug-print-function ${FUNCNAME} "${@}"
local impl=${1/_/.}
local ret
case "${impl}" in
python*|jython*)
ret=${impl}
;;
pypy*)
ret=pypy-c${impl#pypy}
;;
*)
die "Invalid argument to python_get_PYTHON: ${1}"
;;
esac
# @FUNCTION: python_copy_sources
# @DESCRIPTION:
# Create a single copy of the package sources (${S}) for each enabled
# Python implementation.
python_copy_sources() {
debug-print-function ${FUNCNAME} "${@}"
local impl
local bdir=${BUILD_DIR:-${S}}
debug-print "${FUNCNAME}: bdir = ${bdir}"
einfo "Will copy sources from ${S}"
# the order is irrelevant here
for impl in ${PYTHON_COMPAT[@]}; do
if use python_targets_${impl}
then
local BUILD_DIR=${bdir%%/}-${impl}
einfo "${impl}: copying to ${BUILD_DIR}"
debug-print "${FUNCNAME}: [${impl}] cp ${S} => ${BUILD_DIR}"
cp -pr "${S}" "${BUILD_DIR}" || die
fi
done
}
# @FUNCTION: python_foreach_impl
# @USAGE: <command> [<args>...]
# @DESCRIPTION:
# Run the given command for each of the enabled Python implementations.
# If additional parameters are passed, they will be passed through
# to the command. If the command fails, python_foreach_impl dies.
# If necessary, use ':' to force a successful return.
#
# Before the command is run, EPYTHON is set to the name of the current
# Python implementation, PYTHON is set to the correct Python executable
# name and exported, and BUILD_DIR is set to a 'default' build directory
# for given implementation (e.g. ${BUILD_DIR:-${S}}-python2_7).
#
# The command is run inside the build directory. If it doesn't exist
# yet, it is created (as an empty directory!). If your build system does
# not support out-of-source builds, you will likely want to use
# python_copy_sources first.
python_foreach_impl() {
debug-print-function ${FUNCNAME} "${@}"
local impl
local bdir=${BUILD_DIR:-${S}}
debug-print "${FUNCNAME}: bdir = ${bdir}"
for impl in ${_PYTHON_ALL_IMPLS[@]}; do
if has ${impl} ${PYTHON_COMPAT[@]} && use python_targets_${impl}
then
local PYTHON=$(python_get_PYTHON "${impl}")
local EPYTHON=${impl}
local BUILD_DIR=${bdir%%/}-${impl}
export PYTHON
mkdir -p "${BUILD_DIR}" || die
pushd "${BUILD_DIR}" &>/dev/null || die
einfo "${EPYTHON}: running ${@}"
"${@}" || die "${EPYTHON}: ${1} failed"
popd &>/dev/null || die
fi
done
}
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: distutils-r1
# @MAINTAINER:
# Python herd <python@gentoo.org>
# @AUTHOR:
# Author: MichaÅ? Górny <mgorny@gentoo.org>
# Based on the work of: Krzysztof Pawlik <nelchael@gentoo.org>
# @BLURB: A simple eclass to build Python packages using distutils.
# @DESCRIPTION:
# A simple eclass providing functions to build Python packages using
# the distutils build system. It exports phase functions for all
# the src_* phases. Each of the phases runs two pseudo-phases:
# python_..._all() (e.g. python_prepare_all()) once in ${S}, then
# python_...() (e.g. python_prepare()) for each implementation
# (see: python_foreach_impl() in python-r1).
#
# In distutils-r1_src_prepare(), the 'all' function is run before
# per-implementation ones (because it creates the implementations),
# per-implementation functions are run in a random order.
#
# In remaining phase functions, the per-implementation functions are run
# before the 'all' one, and they are ordered from the least to the most
# preferred implementation (so that 'better' files overwrite 'worse'
# ones).
#
# If the ebuild doesn't specify a particular pseudo-phase function,
# the default one will be used (distutils-r1_...). Defaults are provided
# for all per-implementation pseudo-phases, python_prepare_all()
# and python_install_all(); whenever writing your own pseudo-phase
# functions, you should consider calling the defaults (and especially
# distutils-r1_python_prepare_all).
#
# Please note that distutils-r1 sets RDEPEND and DEPEND for you.
case "${EAPI}" in
0|1|2|3)
die "Unsupported EAPI=${EAPI} (too old) for ${ECLASS}"
;;
4)
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
;;
esac
# @FUNCTION: distutils-r1_python_prepare_all
# @DESCRIPTION:
# The default python_prepare_all(). It applies the patches from PATCHES
# array, then user patches and finally calls python_copy_sources to
# create copies of resulting sources for each Python implementation.
distutils-r1_python_prepare_all() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${PATCHES} ]] && epatch "${PATCHES[@]}"
epatch_user
# create source copies for each implementation
python_copy_sources
}
# @FUNCTION: distutils-r1_python_prepare
# @DESCRIPTION:
# The default python_prepare(). Currently it is a no-op
# but in the future it may apply implementation-specific quirks
# to the build system.
distutils-r1_python_prepare() {
debug-print-function ${FUNCNAME} "${@}"
:
}
# @FUNCTION: distutils-r1_python_configure
# @DESCRIPTION:
# The default python_configure(). Currently a no-op.
distutils-r1_python_configure() {
debug-print-function ${FUNCNAME} "${@}"
:
}
# @FUNCTION: distutils-r1_python_compile
# @DESCRIPTION:
# The default python_compile(). Runs 'setup.py build' using the correct
# Python implementation.
distutils-r1_python_compile() {
debug-print-function ${FUNCNAME} "${@}"
cd "${BUILD_DIR}" || die
set -- "${PYTHON}" setup.py build
echo "${@}"
"${@}" || die
}
# @FUNCTION: distutils-r1_python_test
# @DESCRIPTION:
# The default python_test(). Currently a no-op.
distutils-r1_python_test() {
debug-print-function ${FUNCNAME} "${@}"
:
}
# @FUNCTION: distutils-r1_rename_scripts
# @DESCRIPTION:
# Renames installed Python scripts to be implementation-suffixed.
# ${PYTHON} has to be set to the expected Python executable (which
# hashbang will be grepped for), and ${EPYTHON} to the implementation
# name (for new name).
distutils-r1_rename_scripts() {
debug-print-function ${FUNCNAME} "${@}"
local dir f
local wrapdir=${T}/distutils_wrappers
# XXX: change this if we ever allow directories in bin/sbin
for dir in bin sbin usr/bin usr/sbin; do
for f in "${D}"/${dir}/*; do
if [[ -x ${f} ]]; then
debug-print "${FUNCNAME}: found executable at ${f#${D}/}"
if [[ "$(head -n 1 "${f}")" == '#!'*${PYTHON}* ]]
then
debug-print "${FUNCNAME}: matching shebang: $(head -n 1 "${f}")"
local newf=${f}-${EPYTHON}
debug-print "${FUNCNAME}: renamed to ${newf#${D}/}"
mv "${f}" "${newf}" || die
debug-print "${FUNCNAME}: symlink to ${wrapdir}/${dir}/${f##*/}"
mkdir -p "${wrapdir}"/${dir}
ln -fs "${newf##*/}"
"${wrapdir}/${dir}/${f##*/}" || die
fi
fi
done
done
}
# @FUNCTION: distutils-r1_python_install
# @DESCRIPTION:
# The default python_install(). Runs 'setup.py install' using
# the correct Python implementation, and appending the optimization
# flags. Then calls distutils-r1_rename_scripts.
distutils-r1_python_install() {
debug-print-function ${FUNCNAME} "${@}"
local flags
case "${EPYTHON}" in
jython*)
flags='--compile';;
*)
flags='--compile -O2';;
esac
debug-print "${FUNCNAME}: [${EPYTHON}] flags: ${flags}"
unset PYTHONDONTWRITEBYTECODE
cd "${BUILD_DIR}" || die
set -- "${PYTHON}" setup.py install ${flags} --root="${D}"
echo "${@}"
"${@}" || die
distutils-r1_rename_scripts
}
# @FUNCTION: distutils-r1_python_install_all
# @DESCRIPTION:
# The default python_install_all(). It creates wrappers
# for the implementation-suffixed executables.
distutils-r1_python_install_all() {
debug-print-function ${FUNCNAME} "${@}"
local wrapdir=${T}/distutils_wrappers
if [[ -d ${wrapdir} ]]; then
cp -r "${wrapdir}/." "${D}" || die
fi
}
# common preparations
if declare -f python_prepare_all >/dev/null; then
python_prepare_all
else
distutils-r1_python_prepare_all
fi
if declare -f python_prepare >/dev/null; then
python_foreach_impl python_prepare
else
distutils-r1_python_prepare
fi
}
distutils-r1_src_configure() {
if declare -f python_configure >/dev/null; then
python_foreach_impl python_configure
else
distutils-r1_python_configure
fi
if declare -f python_configure_all >/dev/null; then
python_configure_all
fi
}
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> On 09/29/2012 09:53 AM, Micha? Górny wrote:
> > Hello,
> >
> > Instead of the floating patches and p-d-ng modifications I sent
> > earlier, here are the two complete (so far, well, initial :P)
> > eclasses for review.
> >
> > They are designed as 'mostly' drop-in python-distutils-ng
> > replacement.
> >
> Hi,
>
> Are you saying that you are going to remove the python-distutils-ng
> eclass in favour of the new eclasses? I don't quite understand the
> reasons to be honest.
The reason is simple -- I can't fix it without changing the API.
Changing the API on a live eclass is confusing, and considering that it
is not used by many packages, it's easier to lastrite it.
Also, this fixes the name not to have any '-ng' nor '-ds9'.
--
Best regards,
Michał Górny
09-29-2012, 01:49 PM
hasufell
Initial python-r1.eclass & distutils-r1.eclass
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 09/29/2012 12:49 PM, Michał Górny wrote:
> On Sat, 29 Sep 2012 11:20:31 +0100 Markos Chandras
> <hwoarang@gentoo.org> wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
>>
>> On 09/29/2012 09:53 AM, Micha? Górny wrote:
>>> Hello,
>>>
>>> Instead of the floating patches and p-d-ng modifications I sent
>>> earlier, here are the two complete (so far, well, initial :P)
>>> eclasses for review.
>>>
>>> They are designed as 'mostly' drop-in python-distutils-ng
>>> replacement.
>>>
>> Hi,
>>
>> Are you saying that you are going to remove the
>> python-distutils-ng eclass in favour of the new eclasses? I don't
>> quite understand the reasons to be honest.
>
> The reason is simple -- I can't fix it without changing the API.
> Changing the API on a live eclass is confusing, and considering
> that it is not used by many packages, it's easier to lastrite it.
>
> Also, this fixes the name not to have any '-ng' nor '-ds9'.
>
What are the reasons to change the API in the first place? There has
to be a good reason, cause this will involve yet another migration of
many ebuilds. I don't see any bugreports.
I fear this will cause more confusion, i.e. some ebuilds using the old
distutils, some using python-distutils-ng and some using distutils-r1
resulting in weird tree behavior.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
On 29/09/12 09:49 AM, hasufell wrote:
> On 09/29/2012 12:49 PM, Michał Górny wrote:
>> On Sat, 29 Sep 2012 11:20:31 +0100 Markos Chandras
>> <hwoarang@gentoo.org> wrote:
>
>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
>>>
>>> On 09/29/2012 09:53 AM, Micha? Górny wrote:
>>>> Hello,
>>>>
>>>> Instead of the floating patches and p-d-ng modifications I
>>>> sent earlier, here are the two complete (so far, well,
>>>> initial :P) eclasses for review.
>>>>
>>>> They are designed as 'mostly' drop-in python-distutils-ng
>>>> replacement.
>>>>
>>> Hi,
>>>
>>> Are you saying that you are going to remove the
>>> python-distutils-ng eclass in favour of the new eclasses? I
>>> don't quite understand the reasons to be honest.
>
>> The reason is simple -- I can't fix it without changing the API.
>> Changing the API on a live eclass is confusing, and considering
>> that it is not used by many packages, it's easier to lastrite
>> it.
>
>> Also, this fixes the name not to have any '-ng' nor '-ds9'.
>
>
> What are the reasons to change the API in the first place? There
> has to be a good reason, cause this will involve yet another
> migration of many ebuilds. I don't see any bugreports.
>
> I fear this will cause more confusion, i.e. some ebuilds using the
> old distutils, some using python-distutils-ng and some using
> distutils-r1 resulting in weird tree behavior.
>
Given that at present, distutils-r1 and python-distutils-ng have
identical end-results, I think that the introduction of distutils-r1
to the tree should also involve a sed against all the existing ebuilds
using python-distutils-ng to move them to the new eclass. Then
python-distutils-ng only needs to remain to support overlays.
On 09/29/2012 04:19 PM, Ian Stakenvicius wrote:
> On 29/09/12 09:49 AM, hasufell wrote:
>> On 09/29/2012 12:49 PM, Michał Górny wrote:
>>> On Sat, 29 Sep 2012 11:20:31 +0100 Markos Chandras
>>> <hwoarang@gentoo.org> wrote:
>
>>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
>>>>
>>>> On 09/29/2012 09:53 AM, Micha? Górny wrote:
>>>>> Hello,
>>>>>
>>>>> Instead of the floating patches and p-d-ng modifications I
>>>>> sent earlier, here are the two complete (so far, well,
>>>>> initial :P) eclasses for review.
>>>>>
>>>>> They are designed as 'mostly' drop-in python-distutils-ng
>>>>> replacement.
>>>>>
>>>> Hi,
>>>>
>>>> Are you saying that you are going to remove the
>>>> python-distutils-ng eclass in favour of the new eclasses? I
>>>> don't quite understand the reasons to be honest.
>
>>> The reason is simple -- I can't fix it without changing the
>>> API. Changing the API on a live eclass is confusing, and
>>> considering that it is not used by many packages, it's easier
>>> to lastrite it.
>
>>> Also, this fixes the name not to have any '-ng' nor '-ds9'.
>
>
>> What are the reasons to change the API in the first place? There
>> has to be a good reason, cause this will involve yet another
>> migration of many ebuilds. I don't see any bugreports.
>
>> I fear this will cause more confusion, i.e. some ebuilds using
>> the old distutils, some using python-distutils-ng and some using
>> distutils-r1 resulting in weird tree behavior.
>
>
> Given that at present, distutils-r1 and python-distutils-ng have
> identical end-results, I think that the introduction of
> distutils-r1 to the tree should also involve a sed against all the
> existing ebuilds using python-distutils-ng to move them to the new
> eclass. Then python-distutils-ng only needs to remain to support
> overlays.
>
>
That still does not explain the reasons why this work was initiated.
If there is any way to fix the current eclass, that should be preferred.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
On Sat, Sep 29, 2012 at 4:26 PM, hasufell <hasufell@gentoo.org> wrote:
> That still does not explain the reasons why this work was initiated.
>
> If there is any way to fix the current eclass, that should be preferred.
I tend to agree. Michał, let me first say I value the time you have
invested to make the eclasses better. However, at this point I have a
strong feeling that we have more people willing to write code to fix
things than we have people building consensus on what
features/policies/mechanisms we need to make it easy to write
high-quality ebuilds for Python/distutils. I would prefer discussions
on problems that the current ebuilds have and discussions on how to
solve them, not at the code level, but that the mechanism level.