Re: [gentoo-dev] [New eclass] twisted-r1.eclass

2013-08-04 Thread Michał Górny
Dnia 2013-08-03, o godz. 17:13:03
Michał Górny mgo...@gentoo.org napisał(a):

 We've been working with yac for a while to get the old twisted.eclass
 converted to be compliant with distutils-r1 both in design
 and in spirit. This is the first version we'd like to submit for review.

Following comments from marienz:

1. Restored the other subshell obtaining TWISTED_PN from
_twisted_camelcase,

2. Fixed handling empty TWISTED_PLUGINS,

3. Added integrity check for TEST_DIR consistency,

4. Made TWISTED_P*  HTML_DOCS overridable,

5. Added TWISTED_RELEASE that contains major+minor version as it's used
to build SRC_URI and often in dependencies,

6. Improved docs.

-- 
Best regards,
Michał Górny
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/eclass/twisted.eclass,v 1.10 2011/12/27 
06:54:23 floppym Exp $

# @ECLASS: twisted-r1.eclass
# @MAINTAINER:
# Gentoo Python Project pyt...@gentoo.org
# @AUTHOR:
# Author: Michał Górny mgo...@gentoo.org
# Author: Jan Matejka y...@gentoo.org
# @BLURB: Eclass for Twisted packages
# @DESCRIPTION:
# The twisted eclass defines phase functions for Twisted packages.

case ${EAPI:-0} in
0|1|2|3)
die Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}
;;
4|5)
;;
*)
die Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}
;;
esac

if [[ ! ${_TWISTED_R1} ]]; then

inherit distutils-r1 versionator

fi # ! ${_TWISTED_R1}

EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm

if [[ ! ${_TWISTED_R1} ]]; then

# @FUNCTION: _twisted-r1_camelcase
# @USAGE: pn
# @DESCRIPTION:
# Convert dash-separated pn to CamelCase name suitable for Twisted.
# In pure bash, therefore safe for global scope execution.
_twisted-r1_camelcase() {
local IFS=-

# IFS=- splits words by -.
local words=( ${1} )

# we can't keep '-' as it collides with [a-z] check
# and '' is used by bash-4 words[*], so let's just set globally
IFS=

if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
echo ${words[*]^}
return
fi

local w LC_COLLATE=C uc='ABCDEFGHIJKLMNOPQRSTUVWXYZ'

local out
for w in ${words[@]}; do
local fl=${w:0:1}

# Danger: magic starts here. Please close your eyes.
# In base 36, a..z represents digits 10..35. We substract 10
# and get array subscripts for uc.

[[ ${fl} == [a-z] ]]  fl=${uc:36#${fl} - 10:1}

out+=${fl}${w:1}
done

echo ${out}
}

# @ECLASS-VARIABLE: TWISTED_PN
# @DESCRIPTION:
# The real package name. Default to camel-case conversion of ${PN}.
#
# Example: TwistedCore
: ${TWISTED_PN:=$(_twisted-r1_camelcase ${PN})}

# @ECLASS-VARIABLE: TWISTED_P
# @DESCRIPTION:
# The real package name with version appended.
#
# It is used to build the default SRC_URI and S values.
#
# Example: TwistedCore-1.2.3
: ${TWISTED_P:=${TWISTED_PN}-${PV}}

# @ECLASS-VARIABLE: TWISTED_RELEASE
# @DESCRIPTION:
# The 'release' of Twisted. Defaults to the major  minor version
# number from ${PV}.
#
# It is used to build the default SRC_URI. It may be also used
# in dependencies against other Twisted packages.
#
# Example: 1.2
: ${TWISTED_RELEASE:=$(get_version_component_range 1-2 ${PV})}

HOMEPAGE=http://www.twistedmatrix.com/;
SRC_URI=http://twistedmatrix.com/Releases/${TWISTED_PN};
SRC_URI=${SRC_URI}/${TWISTED_RELEASE}/${TWISTED_P}.tar.bz2

LICENSE=MIT
SLOT=0
IUSE=

S=${WORKDIR}/${TWISTED_P}

# @ECLASS-VARIABLE: TWISTED_PLUGINS
# @DESCRIPTION:
# An array of Twisted plugins, whose cache is regenerated
# in pkg_postinst() and pkg_postrm() phases.
#
# If no plugins are installed, set to empty array.
declare -p TWISTED_PLUGINS /dev/null || TWISTED_PLUGINS=( twisted.plugins )

# @FUNCTION: twisted-r1_python_test
# @DESCRIPTION:
# The common python_test() implementation that suffices for Twisted
# packages.
twisted-r1_python_test() {
local sitedir=$(python_get_sitedir)

# Copy modules of other Twisted packages from site-packages
# directory to the temporary directory.
local libdir=${BUILD_DIR}/test/lib
mkdir -p ${libdir} || die
cp -r ${ROOT}${sitedir}/twisted ${libdir} || die
# Drop the installed module in case previous version conflicts with
# the new one somehow.
rm -fr ${libdir}/${PN/-//} || die

distutils_install_for_testing || die

if [[ ${TEST_DIR} != ${BUILD_DIR}/test ]]; then
eqawarn twisted-r1 integrity check failed.
eqawarn TEST_DIR: ${TEST_DIR}
eqawarn expected: ${BUILD_DIR}/test
fi

cd ${TEST_DIR}/lib || die
trial ${PN/-/.} || die Tests fail with ${EPYTHON}
}

# @FUNCTION: python_test
# @DESCRIPTION:
# Default python_test() for Twisted 

[gentoo-dev] [New eclass] twisted-r1.eclass

2013-08-03 Thread Michał Górny
Hello,

We've been working with yac for a while to get the old twisted.eclass
converted to be compliant with distutils-r1 both in design
and in spirit. This is the first version we'd like to submit for review.

A few notes:

1. The eclass aims to be less conditional than the old one. Especially
we've dropped all the ${CATEGORY}/${PN} checks. The code still sets all
the funny defaults for Twisted suite but those aren't incremental
and can easily be overrode in ebuilds. And in most cases, they simple
are (SRC_URI, LICENSE).

2. The eclass comes with a pure bash-3.2 CamelCase converter
for changing PNs like 'twisted-foo' into 'TwistedFoo'. The relevant
code can be moved to eutils as portable replacements for bash-4 ${foo^}
and friends.

3. The eclass provides a reusable twisted-r1_python_test and sets it as
default python_test. If someone needs to override it, he can still call
it using the former name.

4. Cache updating hack is based off twisted.eclass. Sadly, it's not
something we can do without postrm/postinst. Similarly to the old
eclass, TWISTED_PLUGINS needs to list the plugin locations. Since most
ebuilds install to twisted.plugins, it defaults to that. If an ebuild
does not install plugins at all, it needs to set empty TWISTED_PLUGINS.

-- 
Best regards,
Michał Górny
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/eclass/twisted.eclass,v 1.10 2011/12/27 
06:54:23 floppym Exp $

# @ECLASS: twisted-r1.eclass
# @MAINTAINER:
# Gentoo Python Project pyt...@gentoo.org
# @AUTHOR:
# Author: Michał Górny mgo...@gentoo.org
# Author: Jan Matejka y...@gentoo.org
# @BLURB: Eclass for Twisted packages
# @DESCRIPTION:
# The twisted eclass defines phase functions for Twisted packages.

case ${EAPI:-0} in
0|1|2|3)
die Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}
;;
4|5)
;;
*)
die Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}
;;
esac

if [[ ! ${_TWISTED_R1} ]]; then

inherit distutils-r1 versionator

fi # ! ${_TWISTED_R1}

EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm

if [[ ! ${_TWISTED_R1} ]]; then

# @FUNCTION: _twisted_camelcase
# @USAGE: package-name
# @DESCRIPTION:
# Convert dash-separated package name to CamelCase. In pure bash.
# Really.
_twisted_camelcase() {
local pn=${1}
local save_IFS=${IFS}
local IFS=-

# IFS=- splits words by -.
local w words=( ${pn} )

local IFS=${save_IFS}
for w in ${words[@]}; do
local fl=${w:0:1}
# obtain octal ASCII code for the first letter.
local ord=$(printf '%o' '${fl})

# check if it's [a-z]. ASCII codes are locale-safe.
if [[ ${ord} -ge 141  ${ord} -le 172 ]]; then
# now substract 040 to make it upper-case.
# fun fact: in range 0141..0172, decimal '- 40' is fine.
local ord=$(( ${ord} - 40))
# and convert it back to the character.
fl=$(printf '\'${ord})
fi

echo -n ${fl}${w:1}
done
}

# @ECLASS-VARIABLE: TWISTED_PN
# @DESCRIPTION:
# The Twisted CamelCase converted form of package name.
#
# Example: TwistedCore
TWISTED_PN=$(_twisted_camelcase ${PN})

# @ECLASS-VARIABLE: TWISTED_P
# @DESCRIPTION:
# The Twisted CamelCase package name  version.
#
# Example: TwistedCore-1.2.3
TWISTED_P=${TWISTED_PN}-${PV}

HOMEPAGE=http://www.twistedmatrix.com/;
SRC_URI=http://twistedmatrix.com/Releases/${TWISTED_PN};
SRC_URI=${SRC_URI}/$(get_version_component_range 1-2 ${PV})
SRC_URI=${SRC_URI}/${TWISTED_P}.tar.bz2

LICENSE=MIT
SLOT=0
IUSE=

S=${WORKDIR}/${TWISTED_P}

# @ECLASS-VARIABLE: TWISTED_PLUGINS
# @DESCRIPTION:
# An array of Twisted plugins, whose cache is regenerated
# in pkg_postinst() and pkg_postrm() phases.
#
# If no plugins are installed, set to empty array.
[[ ${TWISTED_PLUGINS[@]} ]] || TWISTED_PLUGINS=( twisted.plugins )


# @FUNCTION: twisted-r1_python_test
# @DESCRIPTION:
# The common python_test() implementation that suffices Twisted
# packages.
twisted-r1_python_test() {
local sitedir=$(python_get_sitedir)

# Copy modules of other Twisted packages from site-packages
# directory to the temporary directory.
local libdir=${BUILD_DIR}/test/lib
mkdir -p ${libdir} || die
cp -r ${ROOT}${sitedir}/twisted ${libdir} || die
# Drop the installed module in case previous version conflicts with
# the new one somehow.
rm -fr ${libdir}/${PN/-//} || die

distutils_install_for_testing || die

cd ${TEST_DIR}/lib || die
trial ${PN/-/.} || die Tests fail with ${EPYTHON}
}

# @FUNCTION: python_test
# @DESCRIPTION:
# Default python_test() for Twisted packages. If you need to override
# it, you 

Re: [gentoo-dev] [New eclass] twisted-r1.eclass

2013-08-03 Thread Ulrich Mueller
 On Sat, 3 Aug 2013, Michał Górny wrote:

 2. The eclass comes with a pure bash-3.2 CamelCase converter for
 changing PNs like 'twisted-foo' into 'TwistedFoo'. The relevant code
 can be moved to eutils as portable replacements for bash-4 ${foo^}
 and friends.

   # obtain octal ASCII code for the first letter.
   local ord=$(printf '%o' '${fl})

   # check if it's [a-z]. ASCII codes are locale-safe.
   if [[ ${ord} -ge 141  ${ord} -le 172 ]]; then
   # now substract 040 to make it upper-case.
   # fun fact: in range 0141..0172, decimal '- 40' is fine.
   local ord=$(( ${ord} - 40))
   # and convert it back to the character.
   fl=$(printf '\'${ord})
   fi

This looks just horrible. You do decimal arithmetic on octal numbers?

Ulrich



Re: [gentoo-dev] [New eclass] twisted-r1.eclass

2013-08-03 Thread Michał Górny
Dnia 2013-08-03, o godz. 17:54:42
Ulrich Mueller u...@gentoo.org napisał(a):

  On Sat, 3 Aug 2013, Michał Górny wrote:
 
  2. The eclass comes with a pure bash-3.2 CamelCase converter for
  changing PNs like 'twisted-foo' into 'TwistedFoo'. The relevant code
  can be moved to eutils as portable replacements for bash-4 ${foo^}
  and friends.
 
  # obtain octal ASCII code for the first letter.
  local ord=$(printf '%o' '${fl})
 
  # check if it's [a-z]. ASCII codes are locale-safe.
  if [[ ${ord} -ge 141  ${ord} -le 172 ]]; then
  # now substract 040 to make it upper-case.
  # fun fact: in range 0141..0172, decimal '- 40' is fine.
  local ord=$(( ${ord} - 40))
  # and convert it back to the character.
  fl=$(printf '\'${ord})
  fi
 
 This looks just horrible. You do decimal arithmetic on octal numbers?

Yes. Bash wasn't really happy to do octal arithmetic for me. Yet
in this particular case, with proper assumptions, decimal arithmetic is
practically equivalent.

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


Re: [gentoo-dev] [New eclass] twisted-r1.eclass

2013-08-03 Thread Ulrich Mueller
 On Sat, 3 Aug 2013, Michał Górny wrote:

 Dnia 2013-08-03, o godz. 17:54:42 Ulrich Mueller u...@gentoo.org
 napisał(a):

 This looks just horrible. You do decimal arithmetic on octal
 numbers?

 Yes. Bash wasn't really happy to do octal arithmetic for me. Yet in
 this particular case, with proper assumptions, decimal arithmetic is
 practically equivalent.

Do you consider that in future maybe someone else has to maintain that
code? IMHO we should avoid such hacks.

Why don't you do the calculations in decimal throughout? You can
convert to octal (using printf) in the last step.

Ulrich



Re: [gentoo-dev] [New eclass] twisted-r1.eclass

2013-08-03 Thread Alex Xu
On 03/08/13 02:29 PM, Michał Górny wrote:
 Dnia 2013-08-03, o godz. 17:54:42
 Ulrich Mueller u...@gentoo.org napisał(a):
 
 On Sat, 3 Aug 2013, Michał Górny wrote:

 2. The eclass comes with a pure bash-3.2 CamelCase converter for
 changing PNs like 'twisted-foo' into 'TwistedFoo'. The relevant code
 can be moved to eutils as portable replacements for bash-4 ${foo^}
 and friends.

 # obtain octal ASCII code for the first letter.
 local ord=$(printf '%o' '${fl})

 # check if it's [a-z]. ASCII codes are locale-safe.
 if [[ ${ord} -ge 141  ${ord} -le 172 ]]; then
 # now substract 040 to make it upper-case.
 # fun fact: in range 0141..0172, decimal '- 40' is fine.
 local ord=$(( ${ord} - 40))
 # and convert it back to the character.
 fl=$(printf '\'${ord})
 fi

 This looks just horrible. You do decimal arithmetic on octal numbers?
 
 Yes. Bash wasn't really happy to do octal arithmetic for me. Yet
 in this particular case, with proper assumptions, decimal arithmetic is
 practically equivalent.
 

# obtain decimal ASCII code for the first letter.
local fl=$(printf '%d' '${w})

# check if it's [a-z]. ASCII codes are locale-safe.
if [[ ${ord} -ge 97  ${ord} -le 122 ]]; then
local ord=$(( ${ord} - 32 ))
# and convert it back to the character.
fl=$(printf '\'${ord})
fi

echo -n ${fl}${w:1}

Probably var names should be adjusted, I'm not too familiar with bash
locals.

printf '%d' 'twisted outputs 116 as expected, similar to
printf(%d, *asdf qwerty) in C.

Tested in Bash 4.2.45.

Now time to sit back and wait for it to break in bash
obscure-version-here.



signature.asc
Description: OpenPGP digital signature


Re: [gentoo-dev] [New eclass] twisted-r1.eclass

2013-08-03 Thread Michał Górny
Dnia 2013-08-03, o godz. 21:37:10
Ulrich Mueller u...@gentoo.org napisał(a):

  On Sat, 3 Aug 2013, Michał Górny wrote:
 
  Dnia 2013-08-03, o godz. 17:54:42 Ulrich Mueller u...@gentoo.org
  napisał(a):
 
  This looks just horrible. You do decimal arithmetic on octal
  numbers?
 
  Yes. Bash wasn't really happy to do octal arithmetic for me. Yet in
  this particular case, with proper assumptions, decimal arithmetic is
  practically equivalent.
 
 Do you consider that in future maybe someone else has to maintain that
 code? IMHO we should avoid such hacks.

Well, the code isn't really supposed to need much maintenance. And it
becomes obsolete as soon as we switch to bash-4. I've already added
additional:

  if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
echo -n ${w^}
  else
# current snippet
  fi

Anyway, given the comments and specific case, I doubt it should be
a real issue. 

 Why don't you do the calculations in decimal throughout? You can
 convert to octal (using printf) in the last step.

I consider that a pointless conversion, esp. that it doesn't 
make a difference code-wise.

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


Re: [gentoo-dev] [New eclass] twisted-r1.eclass

2013-08-03 Thread Alex Xu
On 03/08/13 03:37 PM, Alex Xu wrote:
 On 03/08/13 02:29 PM, Michał Górny wrote:
 Dnia 2013-08-03, o godz. 17:54:42
 Ulrich Mueller u...@gentoo.org napisał(a):

 On Sat, 3 Aug 2013, Michał Górny wrote:

 2. The eclass comes with a pure bash-3.2 CamelCase converter for
 changing PNs like 'twisted-foo' into 'TwistedFoo'. The relevant code
 can be moved to eutils as portable replacements for bash-4 ${foo^}
 and friends.

# obtain octal ASCII code for the first letter.
local ord=$(printf '%o' '${fl})

# check if it's [a-z]. ASCII codes are locale-safe.
if [[ ${ord} -ge 141  ${ord} -le 172 ]]; then
# now substract 040 to make it upper-case.
# fun fact: in range 0141..0172, decimal '- 40' is fine.
local ord=$(( ${ord} - 40))
# and convert it back to the character.
fl=$(printf '\'${ord})
fi

 This looks just horrible. You do decimal arithmetic on octal numbers?

 Yes. Bash wasn't really happy to do octal arithmetic for me. Yet
 in this particular case, with proper assumptions, decimal arithmetic is
 practically equivalent.

 
   # obtain decimal ASCII code for the first letter.
   local fl=$(printf '%d' '${w})
 
   # check if it's [a-z]. ASCII codes are locale-safe.
   if [[ ${ord} -ge 97  ${ord} -le 122 ]]; then
   local ord=$(( ${ord} - 32 ))
   # and convert it back to the character.
   fl=$(printf '\'${ord})
   fi
 
   echo -n ${fl}${w:1}
 
 Probably var names should be adjusted, I'm not too familiar with bash
 locals.
 
 printf '%d' 'twisted outputs 116 as expected, similar to
 printf(%d, *asdf qwerty) in C.
 
 Tested in Bash 4.2.45.
 
 Now time to sit back and wait for it to break in bash
 obscure-version-here.
 

I am dumb. Please disregard the previous message.



signature.asc
Description: OpenPGP digital signature


Re: [gentoo-dev] [New eclass] twisted-r1.eclass

2013-08-03 Thread Michał Górny
Dnia 2013-08-03, o godz. 15:37:54
Alex Xu alex_y...@yahoo.ca napisał(a):

 On 03/08/13 02:29 PM, Michał Górny wrote:
  Dnia 2013-08-03, o godz. 17:54:42
  Ulrich Mueller u...@gentoo.org napisał(a):
  
  On Sat, 3 Aug 2013, Michał Górny wrote:
 
  2. The eclass comes with a pure bash-3.2 CamelCase converter for
  changing PNs like 'twisted-foo' into 'TwistedFoo'. The relevant code
  can be moved to eutils as portable replacements for bash-4 ${foo^}
  and friends.
 
# obtain octal ASCII code for the first letter.
local ord=$(printf '%o' '${fl})
 
# check if it's [a-z]. ASCII codes are locale-safe.
if [[ ${ord} -ge 141  ${ord} -le 172 ]]; then
# now substract 040 to make it upper-case.
# fun fact: in range 0141..0172, decimal '- 40' is fine.
local ord=$(( ${ord} - 40))
# and convert it back to the character.
fl=$(printf '\'${ord})
fi
 
  This looks just horrible. You do decimal arithmetic on octal numbers?
  
  Yes. Bash wasn't really happy to do octal arithmetic for me. Yet
  in this particular case, with proper assumptions, decimal arithmetic is
  practically equivalent.
  
 
   # obtain decimal ASCII code for the first letter.
   local fl=$(printf '%d' '${w})
 
   # check if it's [a-z]. ASCII codes are locale-safe.
   if [[ ${ord} -ge 97  ${ord} -le 122 ]]; then
   local ord=$(( ${ord} - 32 ))
   # and convert it back to the character.
   fl=$(printf '\'${ord})
   fi
 
   echo -n ${fl}${w:1}
 
 Probably var names should be adjusted, I'm not too familiar with bash
 locals.
 
 printf '%d' 'twisted outputs 116 as expected, similar to
 printf(%d, *asdf qwerty) in C.
 
 Tested in Bash 4.2.45.

You could test the whole snippet, not just the beginning. Then you
would know that you're passing decimal to '\ooo' which expects octal.

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


Re: [gentoo-dev] [New eclass] twisted-r1.eclass

2013-08-03 Thread Michał Górny
Dnia 2013-08-03, o godz. 17:13:03
Michał Górny mgo...@gentoo.org napisał(a):

 We've been working with yac for a while to get the old twisted.eclass
 converted to be compliant with distutils-r1 both in design
 and in spirit. This is the first version we'd like to submit for review.

Second version, with much more faster camelcase magic (about 1.5 times)
and bash-4 support.

-- 
Best regards,
Michał Górny
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/eclass/twisted.eclass,v 1.10 2011/12/27 
06:54:23 floppym Exp $

# @ECLASS: twisted-r1.eclass
# @MAINTAINER:
# Gentoo Python Project pyt...@gentoo.org
# @AUTHOR:
# Author: Michał Górny mgo...@gentoo.org
# Author: Jan Matejka y...@gentoo.org
# @BLURB: Eclass for Twisted packages
# @DESCRIPTION:
# The twisted eclass defines phase functions for Twisted packages.

case ${EAPI:-0} in
0|1|2|3)
die Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}
;;
4|5)
;;
*)
die Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}
;;
esac

if [[ ! ${_TWISTED_R1} ]]; then

inherit distutils-r1 versionator

fi # ! ${_TWISTED_R1}

EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm

if [[ ! ${_TWISTED_R1} ]]; then

# @FUNCTION: _twisted-r1_camelcase_pn
# @DESCRIPTION:
# Convert dash-separated ${PN} to CamelCase ${TWISTED_PN}. In pure bash.
# Really.
_twisted-r1_camelcase_pn() {
local save_IFS=${IFS}
local IFS=-

# IFS=- splits words by -.
local w words=( ${PN} )

TWISTED_PN=

local IFS=${save_IFS}
local LC_COLLATE=C

local uc='ABCDEFGHIJKLMNOPQRSTUVWXYZ'

for w in ${words[@]}; do
if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
TWISTED_PN+=${w^}
else
local fl=${w:0:1}

# Danger: magic starts here. Please close your eyes.
# In base 36, a..z represents digits 10..35. We 
substract 10
# and get array subscripts for uc.

[[ ${fl} == [a-z] ]]  fl=${uc:36#${fl} - 10:1}

TWISTED_PN+=${fl}${w:1}
fi
done
}

# @ECLASS-VARIABLE: TWISTED_PN
# @DESCRIPTION:
# The Twisted CamelCase converted form of package name.
#
# Example: TwistedCore
_twisted-r1_camelcase_pn

# @ECLASS-VARIABLE: TWISTED_P
# @DESCRIPTION:
# The Twisted CamelCase package name  version.
#
# Example: TwistedCore-1.2.3
TWISTED_P=${TWISTED_PN}-${PV}

HOMEPAGE=http://www.twistedmatrix.com/;
SRC_URI=http://twistedmatrix.com/Releases/${TWISTED_PN};
SRC_URI=${SRC_URI}/$(get_version_component_range 1-2 ${PV})
SRC_URI=${SRC_URI}/${TWISTED_P}.tar.bz2

LICENSE=MIT
SLOT=0
IUSE=

S=${WORKDIR}/${TWISTED_P}

# @ECLASS-VARIABLE: TWISTED_PLUGINS
# @DESCRIPTION:
# An array of Twisted plugins, whose cache is regenerated
# in pkg_postinst() and pkg_postrm() phases.
#
# If no plugins are installed, set to empty array.
[[ ${TWISTED_PLUGINS[@]} ]] || TWISTED_PLUGINS=( twisted.plugins )


# @FUNCTION: twisted-r1_python_test
# @DESCRIPTION:
# The common python_test() implementation that suffices Twisted
# packages.
twisted-r1_python_test() {
local sitedir=$(python_get_sitedir)

# Copy modules of other Twisted packages from site-packages
# directory to the temporary directory.
local libdir=${BUILD_DIR}/test/lib
mkdir -p ${libdir} || die
cp -r ${ROOT}${sitedir}/twisted ${libdir} || die
# Drop the installed module in case previous version conflicts with
# the new one somehow.
rm -fr ${libdir}/${PN/-//} || die

distutils_install_for_testing || die

cd ${TEST_DIR}/lib || die
trial ${PN/-/.} || die Tests fail with ${EPYTHON}
}

# @FUNCTION: python_test
# @DESCRIPTION:
# Default python_test() for Twisted packages. If you need to override
# it, you can access the original implementation
# via twisted-r1_python_test.
python_test() {
twisted-r1_python_test
}

# @FUNCTION: twisted-r1_src_install
# @DESCRIPTION:
# Default src_install() for Twisted packages. Automatically handles HTML
# docs and manpages in Twisted packages
twisted-r1_src_install() {
# TODO: doesn't this accidentially involve installing manpages? ;f
if [[ ${CATEGORY}/${PN} == dev-python/twisted*  -d doc ]]; then
local HTML_DOCS=( doc/. )
fi

distutils-r1_src_install

[[ -d doc/man ]]  doman doc/man/*.[[:digit:]]
}

# @FUNCTION: _twisted-r1_create_caches
# @USAGE: packages...
# @DESCRIPTION:
# Create dropin.cache for plugins in specified packages. The packages
# are to be listed in standard dotted Python syntax.
_twisted-r1_create_caches() {
# http://twistedmatrix.com/documents/current/core/howto/plugin.html
${PYTHON} -c \
import sys

Re: [gentoo-dev] [New eclass] twisted-r1.eclass

2013-08-03 Thread Michał Górny
Dnia 2013-08-03, o godz. 17:13:03
Michał Górny mgo...@gentoo.org napisał(a):

 We've been working with yac for a while to get the old twisted.eclass
 converted to be compliant with distutils-r1 both in design
 and in spirit. This is the first version we'd like to submit for review.

One more bit of optimization.

-- 
Best regards,
Michał Górny
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/eclass/twisted.eclass,v 1.10 2011/12/27 
06:54:23 floppym Exp $

# @ECLASS: twisted-r1.eclass
# @MAINTAINER:
# Gentoo Python Project pyt...@gentoo.org
# @AUTHOR:
# Author: Michał Górny mgo...@gentoo.org
# Author: Jan Matejka y...@gentoo.org
# @BLURB: Eclass for Twisted packages
# @DESCRIPTION:
# The twisted eclass defines phase functions for Twisted packages.

case ${EAPI:-0} in
0|1|2|3)
die Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}
;;
4|5)
;;
*)
die Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}
;;
esac

if [[ ! ${_TWISTED_R1} ]]; then

inherit distutils-r1 versionator

fi # ! ${_TWISTED_R1}

EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm

if [[ ! ${_TWISTED_R1} ]]; then

# @FUNCTION: _twisted-r1_camelcase_pn
# @DESCRIPTION:
# Convert dash-separated ${PN} to CamelCase ${TWISTED_PN}. In pure bash.
# Really.
_twisted-r1_camelcase_pn() {
local IFS=-

# IFS=- splits words by -.
local words=( ${PN} )

# we can't keep '-' as it collides with [a-z] check
# and '' is used by bash-4 words[*], so let's just set globally
IFS=

if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
TWISTED_PN=${words[*]^}
return
fi

local w LC_COLLATE=C uc='ABCDEFGHIJKLMNOPQRSTUVWXYZ'

TWISTED_PN=
for w in ${words[@]}; do
local fl=${w:0:1}

# Danger: magic starts here. Please close your eyes.
# In base 36, a..z represents digits 10..35. We substract 10
# and get array subscripts for uc.

[[ ${fl} == [a-z] ]]  fl=${uc:36#${fl} - 10:1}

TWISTED_PN+=${fl}${w:1}
done
}

# @ECLASS-VARIABLE: TWISTED_PN
# @DESCRIPTION:
# The Twisted CamelCase converted form of package name.
#
# Example: TwistedCore
_twisted-r1_camelcase_pn

# @ECLASS-VARIABLE: TWISTED_P
# @DESCRIPTION:
# The Twisted CamelCase package name  version.
#
# Example: TwistedCore-1.2.3
TWISTED_P=${TWISTED_PN}-${PV}

HOMEPAGE=http://www.twistedmatrix.com/;
SRC_URI=http://twistedmatrix.com/Releases/${TWISTED_PN};
SRC_URI=${SRC_URI}/$(get_version_component_range 1-2 ${PV})
SRC_URI=${SRC_URI}/${TWISTED_P}.tar.bz2

LICENSE=MIT
SLOT=0
IUSE=

S=${WORKDIR}/${TWISTED_P}

# @ECLASS-VARIABLE: TWISTED_PLUGINS
# @DESCRIPTION:
# An array of Twisted plugins, whose cache is regenerated
# in pkg_postinst() and pkg_postrm() phases.
#
# If no plugins are installed, set to empty array.
[[ ${TWISTED_PLUGINS[@]} ]] || TWISTED_PLUGINS=( twisted.plugins )


# @FUNCTION: twisted-r1_python_test
# @DESCRIPTION:
# The common python_test() implementation that suffices Twisted
# packages.
twisted-r1_python_test() {
local sitedir=$(python_get_sitedir)

# Copy modules of other Twisted packages from site-packages
# directory to the temporary directory.
local libdir=${BUILD_DIR}/test/lib
mkdir -p ${libdir} || die
cp -r ${ROOT}${sitedir}/twisted ${libdir} || die
# Drop the installed module in case previous version conflicts with
# the new one somehow.
rm -fr ${libdir}/${PN/-//} || die

distutils_install_for_testing || die

cd ${TEST_DIR}/lib || die
trial ${PN/-/.} || die Tests fail with ${EPYTHON}
}

# @FUNCTION: python_test
# @DESCRIPTION:
# Default python_test() for Twisted packages. If you need to override
# it, you can access the original implementation
# via twisted-r1_python_test.
python_test() {
twisted-r1_python_test
}

# @FUNCTION: twisted-r1_src_install
# @DESCRIPTION:
# Default src_install() for Twisted packages. Automatically handles HTML
# docs and manpages in Twisted packages
twisted-r1_src_install() {
# TODO: doesn't this accidentially involve installing manpages? ;f
if [[ ${CATEGORY}/${PN} == dev-python/twisted*  -d doc ]]; then
local HTML_DOCS=( doc/. )
fi

distutils-r1_src_install

[[ -d doc/man ]]  doman doc/man/*.[[:digit:]]
}

# @FUNCTION: _twisted-r1_create_caches
# @USAGE: packages...
# @DESCRIPTION:
# Create dropin.cache for plugins in specified packages. The packages
# are to be listed in standard dotted Python syntax.
_twisted-r1_create_caches() {
# http://twistedmatrix.com/documents/current/core/howto/plugin.html
${PYTHON} -c \
import sys
sys.path.insert(0, '${ROOT}$(python_get_sitedir)')

fail = 

[gentoo-dev] New eclass: twisted-r1

2013-07-26 Thread yac
Hi,

I'm sending revised twisted-r1.eclass including the ebuild bumps.

You can view the diff either in the included patch or at github [1]

I have tested on amd64 and x86. All packages emerge and tests are
passing, besides nevow, axiom, and mantissa which are failing anyway
with the old eclass too.

Will commit tomorrow if there are no disputers.

[1] 
https://github.com/yaccz/gentoo-overlay/commit/1288b7989a156d3e9c3b6b1a0f079c33c9dffc10
commit 1288b7989a156d3e9c3b6b1a0f079c33c9dffc10
Author: Jan (yac) Matějka jmate...@suse.cz
Date:   Mon Jul 8 13:57:23 2013 +0200

eapi 5/twisted-r1 bumps

* elcass
* twisted-* ebuilds
* twisted depender ebuilds

diff --git a/dev-python/axiom/axiom-0.6.0-r1.ebuild b/dev-python/axiom/axiom-0.6.0-r1.ebuild
index 7291292..8e88ccb 100644
--- a/dev-python/axiom/axiom-0.6.0-r1.ebuild
+++ b/dev-python/axiom/axiom-0.6.0-r1.ebuild
@@ -2,17 +2,11 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Header: /var/cvsroot/gentoo-x86/dev-python/axiom/axiom-0.6.0.ebuild,v 1.14 2013/05/12 18:32:59 floppym Exp $
 
-EAPI=3
-PYTHON_DEPEND=2
-SUPPORT_PYTHON_ABIS=1
-RESTRICT_PYTHON_ABIS=2.5 3.* *-jython
-PYTHON_USE_WITH=sqlite
+EAPI=5
+PYTHON_COMPAT=( python{2_6,2_7} pypy{1_9,2_0} )
+PYTHON_REQ_USE=sqlite
 
-# setup.py uses epsilon.setuphelper.autosetup(), which tries to use
-# build-${PYTHON_ABI} directories as packages.
-DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES=1
-
-inherit eutils twisted
+inherit eutils twisted-r1
 
 MY_PN=Axiom
 MY_P=${MY_PN}-${PV}
@@ -23,35 +17,24 @@ SRC_URI=mirror://pypi/${MY_PN:0:1}/${MY_PN}/${MY_P}.tar.gz
 
 LICENSE=MIT
 SLOT=0
-KEYWORDS=amd64 ppc ppc64 sparc x86
+KEYWORDS=~amd64 ~ppc ~ppc64 ~sparc ~x86
 IUSE=
 
-DEPEND==dev-python/epsilon-0.6
-	=dev-python/twisted-2.4
-	=dev-python/twisted-conch-0.7.0-r1
+DEPEND==dev-python/epsilon-0.6.0-r2[${PYTHON_USEDEP}]
+	dev-python/twisted[${PYTHON_USEDEP}]
+	dev-python/twisted-conch[${PYTHON_USEDEP}]
 RDEPEND=${DEPEND}
 
 S=${WORKDIR}/${MY_P}
 
-DOCS=NAME.txt
-PYTHON_MODNAME=axiom twisted/plugins/axiom_plugins.py
-TWISTED_PLUGINS=axiom.plugins twisted.plugins
-
-src_prepare() {
-	epatch ${FILESDIR}/${PN}-0.5.30-sqlite3.patch
-	epatch ${FILESDIR}/${PN}-0.5.30-sqlite3_3.6.4.patch
-	python_copy_sources
-}
-
-src_compile() {
-	# Skip distutils_src_compile to avoid installation of $(python_get_sitedir)/build directory.
-	:
-}
+DOCS=( NAME.txt )
+PATCHES=(
+	${FILESDIR}/${PN}-0.5.30-sqlite3.patch
+	${FILESDIR}/${PN}-0.5.30-sqlite3_3.6.4.patch
+)
 
-src_test() {
-	python_execute_trial -P . axiom
-}
+TWISTED_PLUGINS=axiom.plugins twisted.plugins
 
-src_install() {
-	PORTAGE_PLUGINCACHE_NOOP=1 distutils_src_install
+python_test() {
+	trial -P . axiom || die tests failed with $EPYTHON
 }
diff --git a/dev-python/epsilon/epsilon-0.6.0-r2.ebuild b/dev-python/epsilon/epsilon-0.6.0-r2.ebuild
index cc893ad..9462af6 100644
--- a/dev-python/epsilon/epsilon-0.6.0-r2.ebuild
+++ b/dev-python/epsilon/epsilon-0.6.0-r2.ebuild
@@ -2,18 +2,10 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Header: /var/cvsroot/gentoo-x86/dev-python/epsilon/epsilon-0.6.0-r1.ebuild,v 1.2 2012/10/12 08:15:00 patrick Exp $
 
-EAPI=3
-PYTHON_DEPEND=2
-SUPPORT_PYTHON_ABIS=1
-RESTRICT_PYTHON_ABIS=2.5 3.* *-jython
-DISTUTILS_SRC_TEST=trial
-DISTUTILS_DISABLE_TEST_DEPENDENCY=1
+EAPI=5
+PYTHON_COMPAT=( python{2_6,2_7} pypy{1_9,2_0} )
 
-# setup.py uses epsilon.setuphelper.autosetup(), which tries to use
-# build-${PYTHON_ABI} directories as packages.
-DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES=1
-
-inherit eutils twisted
+inherit eutils twisted-r1
 
 MY_PN=Epsilon
 MY_P=${MY_PN}-${PV}
@@ -27,14 +19,15 @@ SLOT=0
 KEYWORDS=~amd64 ~ppc ~ppc64 ~sparc ~x86
 IUSE=
 
-DEPEND==dev-python/twisted-2.4
+DEPEND=dev-python/twisted[${PYTHON_USEDEP}]
 RDEPEND=${DEPEND}
 
 S=${WORKDIR}/${MY_P}
 
-DOCS=NAME.txt NEWS.txt
+DOCS=( NAME.txt NEWS.txt )
+PATCHES=( ${FILESDIR}/epsilon_plugincache_portagesandbox.patch )
 
-src_prepare() {
+python_prepare_all() {
 	# Rename to avoid file-collisions
 	mv bin/benchmark bin/epsilon-benchmark
 	sed -i \
@@ -42,27 +35,16 @@ src_prepare() {
 		setup.py || die sed failed
 	# otherwise we get sandbox violations as it wants to update
 	# the plugin cache
-	epatch ${FILESDIR}/epsilon_plugincache_portagesandbox.patch
 
 	#These test are removed upstream
 	rm -f epsilon/test/test_sslverify.py epsilon/sslverify.py || die
 	#See bug 357157 comment 5 for Ian Delaney's explanation of this fix
 	sed -e 's:month) 2004 9:month) 2004 14:' \
 		-i epsilon/test/test_extime.py || die
-	#These are broken too
-	rm -f epsilon/test/test_release.py epsilon/release.py || die
-
-	python_copy_sources
-}
-
-src_compile() {
-	# Skip distutils_src_compile to avoid installation of $(python_get_sitedir)/build directory.
-	:
-}
-
-src_test() {
 	# Release tests need DivmodCombinator.
-	rm -f epsilon/test/test_release.py* epsilon/release.py
+	rm -f epsilon/test/test_release.py* epsilon/release.py || die
+}
 
-	

Re: [gentoo-dev] New eclass - twisted-r1

2013-07-11 Thread Michał Górny
Dnia 2013-07-10, o godz. 23:40:11
yac y...@gentoo.org napisał(a):

 On Wed, 10 Jul 2013 22:25:50 +0200
 Michał Górny mgo...@gentoo.org wrote:
 
  First of all: please wrap lines at 72 or 80 chars (even if the
  original eclass didn't do that).
  
   if [[ ${CATEGORY}/${PN} == dev-python/twisted* ]]; then
  
  I know you're not responsible for this but it seems wrong to have two
  different behaviors depending on PN. Is this used somewhere actually?
  
 MY_PV=${MY_PV:-${PV}}
 MY_P=Twisted${MY_PACKAGE}-${MY_PV}
   
 HOMEPAGE=http://www.twistedmatrix.com/;
 
   #SRC_URI=http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/$(get_version_component_range
   1-2 ${MY_PV})/${MY_P}.tar.bz2
   SRC_URI=http://twistedmatrix.com/Releases/${MY_PACKAGE}/$(get_version_component_range
   1-2 ${MY_PV})/${MY_P}.tar.bz2
   
 LICENSE=MIT
 SLOT=0
 IUSE=
   
 S=${WORKDIR}/${MY_P}
   
 TWISTED_PLUGINS=${TWISTED_PLUGINS:-twisted.plugins}
   fi
 
 That's what I thought when I saw that but I found that all the
 dev-python/twisted-* packages are depending on this, so I went with it.
 
 Now I'm thinking I could instead provide functions
 twisted-r1_twisted_src_uri and twisted-r1_twisted_build_dir used as
 
 SRC_URI=$(twisted-r1_twisted_src_uri)
 S=$(twisted-r1_twisted_build_dir)
 
 in the depender ebuilds.

I'm more-of wondering if that conditional is really necessary useful.
Unless I'm missing something, the non-twisted ebuilds will replace
those variables anyway, won't them?

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


Re: [gentoo-dev] New eclass - twisted-r1

2013-07-11 Thread yac
On Thu, 11 Jul 2013 08:55:47 +0200
Michał Górny mgo...@gentoo.org wrote:

 Dnia 2013-07-10, o godz. 23:40:11
 yac y...@gentoo.org napisał(a):
 
  On Wed, 10 Jul 2013 22:25:50 +0200
  Michał Górny mgo...@gentoo.org wrote:
  
   First of all: please wrap lines at 72 or 80 chars (even if the
   original eclass didn't do that).
   
if [[ ${CATEGORY}/${PN} == dev-python/twisted* ]]; then
   
   I know you're not responsible for this but it seems wrong to have
   two different behaviors depending on PN. Is this used somewhere
   actually?
   
MY_PV=${MY_PV:-${PV}}
MY_P=Twisted${MY_PACKAGE}-${MY_PV}

HOMEPAGE=http://www.twistedmatrix.com/;

#SRC_URI=http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/$(get_version_component_range
1-2 ${MY_PV})/${MY_P}.tar.bz2
SRC_URI=http://twistedmatrix.com/Releases/${MY_PACKAGE}/$(get_version_component_range
1-2 ${MY_PV})/${MY_P}.tar.bz2

LICENSE=MIT
SLOT=0
IUSE=

S=${WORKDIR}/${MY_P}

TWISTED_PLUGINS=${TWISTED_PLUGINS:-twisted.plugins}
fi
  
  That's what I thought when I saw that but I found that all the
  dev-python/twisted-* packages are depending on this, so I went with
  it.
  
  Now I'm thinking I could instead provide functions
  twisted-r1_twisted_src_uri and twisted-r1_twisted_build_dir used as
  
  SRC_URI=$(twisted-r1_twisted_src_uri)
  S=$(twisted-r1_twisted_build_dir)
  
  in the depender ebuilds.
 
 I'm more-of wondering if that conditional is really necessary useful.
 Unless I'm missing something, the non-twisted ebuilds will replace
 those variables anyway, won't them?

The dev-python/twisted-* packages do rely on this. They will set just
MY_PACKAGE=

And the S, SRC_URI, LICENSE, SLOT, IUSE is set by the eclass.

Other than dev-python/twisted-* packages does not match, so they need
not to override it.

I think the main purpose is code deduplication regarding setting the
SRC_URI and S.


signature.asc
Description: PGP signature


Re: [gentoo-dev] New eclass - twisted-r1

2013-07-11 Thread yac
On Wed, 10 Jul 2013 22:25:50 +0200
Michał Górny mgo...@gentoo.org wrote:
  python_test() {
  # TODO: this seems to be used only in dev-python/twisted-*
  packages as # dev-python/twisted-13.0.0 have it's own src_test
  if [[ ${CATEGORY}/${PN} != dev-python/twisted* ]]; then
  die ${FUNCNAME}() can be used only in
  dev-python/twisted* packages fi
  
  local sitedir=${EPREFIX}$(python_get_sitedir)
  
  # Copy modules of other Twisted packages from site-packages
  directory to temporary directory. mkdir -p ${T}/${sitedir}
  cp -R ${ROOT}${sitedir}/twisted ${T}/${sitedir} || die
  Copying of modules of other Twisted packages failed with
  $(python_get_implementation) $(python_get_version) rm -fr
  ${T}/${sitedir}/${PN/-//}
 
 Awful and ugly. Try to find a way to run the tests without this
 hackery.

What are you referring to?

For the ${CATEGORY}/${PN} match. All the non-twisted packages are
overriding src_test but it's probably be gonna cleaner to rename the
python_test to twisted-r1_twisted_test and call it explicitly for the
twisted packages.

As for the Copy modules, I'm afraid that's inevitable.


signature.asc
Description: PGP signature


Re: [gentoo-dev] New eclass - twisted-r1

2013-07-11 Thread Michał Górny
Dnia 2013-07-11, o godz. 13:34:01
yac y...@gentoo.org napisał(a):

 On Thu, 11 Jul 2013 08:55:47 +0200
 Michał Górny mgo...@gentoo.org wrote:
 
  Dnia 2013-07-10, o godz. 23:40:11
  yac y...@gentoo.org napisał(a):
  
   On Wed, 10 Jul 2013 22:25:50 +0200
   Michał Górny mgo...@gentoo.org wrote:
   
First of all: please wrap lines at 72 or 80 chars (even if the
original eclass didn't do that).

 if [[ ${CATEGORY}/${PN} == dev-python/twisted* ]]; then

I know you're not responsible for this but it seems wrong to have
two different behaviors depending on PN. Is this used somewhere
actually?

   MY_PV=${MY_PV:-${PV}}
   MY_P=Twisted${MY_PACKAGE}-${MY_PV}
 
   HOMEPAGE=http://www.twistedmatrix.com/;
   
 #SRC_URI=http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/$(get_version_component_range
 1-2 ${MY_PV})/${MY_P}.tar.bz2
 SRC_URI=http://twistedmatrix.com/Releases/${MY_PACKAGE}/$(get_version_component_range
 1-2 ${MY_PV})/${MY_P}.tar.bz2
 
   LICENSE=MIT
   SLOT=0
   IUSE=
 
   S=${WORKDIR}/${MY_P}
 
   TWISTED_PLUGINS=${TWISTED_PLUGINS:-twisted.plugins}
 fi
   
   That's what I thought when I saw that but I found that all the
   dev-python/twisted-* packages are depending on this, so I went with
   it.
   
   Now I'm thinking I could instead provide functions
   twisted-r1_twisted_src_uri and twisted-r1_twisted_build_dir used as
   
   SRC_URI=$(twisted-r1_twisted_src_uri)
   S=$(twisted-r1_twisted_build_dir)
   
   in the depender ebuilds.
  
  I'm more-of wondering if that conditional is really necessary useful.
  Unless I'm missing something, the non-twisted ebuilds will replace
  those variables anyway, won't them?
 
 The dev-python/twisted-* packages do rely on this. They will set just
 MY_PACKAGE=
 
 And the S, SRC_URI, LICENSE, SLOT, IUSE is set by the eclass.
 
 Other than dev-python/twisted-* packages does not match, so they need
 not to override it.

Well, I meant that the other packages need to set SRC_URI and stuff
anyway, so they will override it anyway. But S is a fair point.

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


[gentoo-dev] New eclass - twisted-r1

2013-07-10 Thread yac
Hello everypony

In order to bump dev-python/twisted packages to EAPI=5 we also need to
bump the twisted eclass to use distutils-r1.

I have made this bump (to the eclass and dev-python/twisted*) packages
in my yac overlay [1]

You can view the actuall changes at [2]. It's merely the existing
twisted eclass adapted to distutils-r1.

I have tested the packages (merge, module import in python and tests)
on python2_7 at amd64.

I don't know when I'll get around to testing other pythons and x86.
Certainly I'm currently unable to test pypy and eprefix.

Besides reviewing the changes, could somepony test these arches?


[1] https://github.com/yaccz/gentoo-overlay/tree/twisted-r1
[2] https://github.com/yaccz/gentoo-overlay/compare/5421996...020b0c2


signature.asc
Description: PGP signature


Re: [gentoo-dev] New eclass - twisted-r1

2013-07-10 Thread Michał Górny
First of all: please wrap lines at 72 or 80 chars (even if the original
eclass didn't do that).

 if [[ ${CATEGORY}/${PN} == dev-python/twisted* ]]; then

I know you're not responsible for this but it seems wrong to have two
different behaviors depending on PN. Is this used somewhere actually?

   MY_PV=${MY_PV:-${PV}}
   MY_P=Twisted${MY_PACKAGE}-${MY_PV}
 
   HOMEPAGE=http://www.twistedmatrix.com/;
   
 #SRC_URI=http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/$(get_version_component_range
  1-2 ${MY_PV})/${MY_P}.tar.bz2
   
 SRC_URI=http://twistedmatrix.com/Releases/${MY_PACKAGE}/$(get_version_component_range
  1-2 ${MY_PV})/${MY_P}.tar.bz2
 
   LICENSE=MIT
   SLOT=0
   IUSE=
 
   S=${WORKDIR}/${MY_P}
 
   TWISTED_PLUGINS=${TWISTED_PLUGINS:-twisted.plugins}
 fi
 
 # @ECLASS-VARIABLE: TWISTED_PLUGINS
 # @DESCRIPTION:
 # Twisted plugins, whose cache is regenerated in pkg_postinst() and 
 pkg_postrm() phases.
 
 python_test() {
   # TODO: this seems to be used only in dev-python/twisted-* packages as
   # dev-python/twisted-13.0.0 have it's own src_test
   if [[ ${CATEGORY}/${PN} != dev-python/twisted* ]]; then
   die ${FUNCNAME}() can be used only in dev-python/twisted* 
 packages
   fi
 
   local sitedir=${EPREFIX}$(python_get_sitedir)
 
   # Copy modules of other Twisted packages from site-packages directory 
 to temporary directory.
   mkdir -p ${T}/${sitedir}
   cp -R ${ROOT}${sitedir}/twisted ${T}/${sitedir} || die Copying of 
 modules of other Twisted packages failed with $(python_get_implementation) 
 $(python_get_version)
   rm -fr ${T}/${sitedir}/${PN/-//}

Awful and ugly. Try to find a way to run the tests without this hackery.

   # Install modules of current package to temporary directory.
   ${PYTHON} setup.py build -b build-${EPYTHON} install --force 
 --no-compile --root=${T} || die Installation into temporary directory 
 failed with $(python_get_implementation) $(python_get_version)

This is likely a candidate for 'distutils_install_for_testing'.
Or 'esetup.py' at least. Inlining build-dir is simply wrong.

   pushd ${T}/${sitedir}  /dev/null || return 1
   PATH=${T}${EPREFIX}/usr/bin:${PATH} PYTHONPATH=${T}/${sitedir} 
 trial ${PN/-/.} || return 1
   popd  /dev/null || return 1
 
   rm -fr ${T}/${sitedir}
 }
 
 twisted-r1_src_install() {
   distutils-r1_src_install
 
   if [[ -d doc/man ]]; then
   doman doc/man/*.[[:digit:]]
   fi
 
   if [[ -d doc ]]; then
   insinto /usr/share/doc/${PF}
   doins -r $(find doc -mindepth 1 -maxdepth 1 -not -name man)
   fi
 }
 
 _twisted-r1_update_plugin_cache() {
   local dir exit_status=0 module
 
   for module in ${TWISTED_PLUGINS}; do
   if [[ -d ${EROOT}$(python_get_sitedir)/${module//.//} ]]; then
   find ${EROOT}$(python_get_sitedir)/${module//.//} 
 -name dropin.cache -print0 | xargs -0 rm -f
   fi
   done
 
   for module in ${TWISTED_PLUGINS}; do
   # 
 http://twistedmatrix.com/documents/current/core/howto/plugin.html
   ${PYTHON} -c \
 import sys
 sys.path.insert(0, '${EROOT}$(python_get_sitedir)')
 
 try:
   import twisted.plugin
   import ${module}
 except ImportError:
   if '${EBUILD_PHASE}' == 'postinst':
   raise
   else:
   # Twisted, zope.interface or given plugins might have been 
 uninstalled.
   sys.exit(0)
 
 list(twisted.plugin.getPlugins(twisted.plugin.IPlugin, ${module})) || 
 exit_status=1
   done
 
   for module in ${TWISTED_PLUGINS}; do
   # Delete empty parent directories.
   local dir=${EROOT}$(python_get_sitedir)/${module//.//}
   while [[ ${dir} != ${EROOT%/} ]]; do
   rmdir ${dir} 2 /dev/null || break
   dir=${dir%/*}
   done
   done
 
   return ${exit_status}
 }
 
 twisted-r1_pkg_postinst() {
   _distutils-r1_run_foreach_impl _twisted-r1_update_plugin_cache
 }
 
 twisted-r1_pkg_postrm() {
   _distutils-r1_run_foreach_impl _twisted-r1_update_plugin_cache
 }

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


Re: [gentoo-dev] New eclass - twisted-r1

2013-07-10 Thread yac
On Wed, 10 Jul 2013 22:25:50 +0200
Michał Górny mgo...@gentoo.org wrote:

 First of all: please wrap lines at 72 or 80 chars (even if the
 original eclass didn't do that).
 
  if [[ ${CATEGORY}/${PN} == dev-python/twisted* ]]; then
 
 I know you're not responsible for this but it seems wrong to have two
 different behaviors depending on PN. Is this used somewhere actually?
 
  MY_PV=${MY_PV:-${PV}}
  MY_P=Twisted${MY_PACKAGE}-${MY_PV}
  
  HOMEPAGE=http://www.twistedmatrix.com/;
  
  #SRC_URI=http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/$(get_version_component_range
  1-2 ${MY_PV})/${MY_P}.tar.bz2
  SRC_URI=http://twistedmatrix.com/Releases/${MY_PACKAGE}/$(get_version_component_range
  1-2 ${MY_PV})/${MY_P}.tar.bz2
  
  LICENSE=MIT
  SLOT=0
  IUSE=
  
  S=${WORKDIR}/${MY_P}
  
  TWISTED_PLUGINS=${TWISTED_PLUGINS:-twisted.plugins}
  fi

That's what I thought when I saw that but I found that all the
dev-python/twisted-* packages are depending on this, so I went with it.

Now I'm thinking I could instead provide functions
twisted-r1_twisted_src_uri and twisted-r1_twisted_build_dir used as

SRC_URI=$(twisted-r1_twisted_src_uri)
S=$(twisted-r1_twisted_build_dir)

in the depender ebuilds.


signature.asc
Description: PGP signature