Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 456318 - dev-python/cython-0.18 - use distutils-r1.eclass
Summary: dev-python/cython-0.18 - use distutils-r1.eclass
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2013-02-09 15:05 UTC by Matěj Laitl
Modified: 2013-02-09 19:56 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matěj Laitl 2013-02-09 15:05:01 UTC
Hi,
this is my attempt to contribute to python-r1 porting: cython-0.18 ebuild. Apart from the actual porting, following changes are made:
 * EAPI changed to 5 (is this okay?)
 * Description updated to match what upstream says (previous was too narrow)
 * IUSE examples removed - their intallation is removed, because these are rather outdated and many of them are contained in the new documentation
 * USE doc installs the "new" Sphinx-built documentation found in docs/ - this is actually the one rather complete, kept up-to-date and actually developed   instead of the one in Doc/ which is hopelessly outdated and rather a remnant
 * NumPy is only needed in the testsuite, so make it just DEPEND and test-USE conditional
 * CHANGES.rst was added to DOCS

With one TODO item left:
 * the old ebuild had:
   PYTHON_CFLAGS=("2.* + -fno-strict-aliasing")
   I don't know why it is needed and how/whether it should be ported to distutils-r1

Testing done:
 * all USE flag combinations compile/test/work with Python 2.6, 2.7 and 3.2 (Cython and the ebuild supports more however)

P.S: thanks for all the python-r1 work, it is much more convenient user- and developer-wise.
---

--- /usr/portage/dev-python/cython/cython-0.18.ebuild   2013-02-04 05:32:11.000000000 +0100
+++ cython-0.18-r1.ebuild       2013-02-09 15:20:36.169919117 +0100
@@ -1,53 +1,46 @@
 # Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/dev-python/cython/cython-0.18.ebuild,v 1.1 2013/02/04 04:32:11 patrick Exp $
+# $Header: $
 
-EAPI="3"
-SUPPORT_PYTHON_ABIS="1"
-RESTRICT_PYTHON_ABIS="*-jython 2.7-pypy-*"
+EAPI=5
+PYTHON_COMPAT=( python{2_5,2_6,2_7,3_1,3_2,3_3} )
 
-inherit distutils
+inherit distutils-r1
 
 MY_PN="Cython"
 MY_P="${MY_PN}-${PV/_/}"
 
-DESCRIPTION="Compiler for writing C extensions for the Python language"
+DESCRIPTION="A Python to C compiler"
 HOMEPAGE="http://www.cython.org/ http://pypi.python.org/pypi/Cython"
 SRC_URI="http://www.cython.org/release/${MY_P}.tar.gz"
 
 LICENSE="Apache-2.0"
 SLOT="0"
 KEYWORDS="~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~x64-solaris ~x86-solaris"
-IUSE="doc examples numpy"
+IUSE="doc numpy test"
 
-DEPEND="numpy? ( >=dev-python/numpy-1.6.1-r1 )"
-RDEPEND="${DEPEND}"
+# numpy is only needed for tests and not at runtime
+# sphinx is only called as a command, its Python version is irrelevant
+DEPEND="test? ( numpy? ( >=dev-python/numpy-1.6.1-r1[${PYTHON_USEDEP}] ) )
+       doc? ( dev-python/sphinx )
+"
+RDEPEND=""
+
+#TODO is this needed? how to port to -r1?: PYTHON_CFLAGS=("2.* + -fno-strict-aliasing")
+DOCS=( CHANGES.rst README.txt ToDo.txt USAGE.txt )
+DISTUTILS_IN_SOURCE_BUILD="1" # Cython buildsystem touches its sources in 2to3 conversion
 
 S="${WORKDIR}/${MY_PN}-${PV%_*}"
 
-PYTHON_CFLAGS=("2.* + -fno-strict-aliasing")
-
-DOCS="README.txt ToDo.txt USAGE.txt"
-PYTHON_MODNAME="Cython cython.py pyximport"
-
-src_test() {
-       testing() {
-               "$(PYTHON)" runtests.py -vv --work-dir tests-${PYTHON_ABI}
-       }
-       python_execute_function testing
+python_test() {
+       "${PYTHON}" runtests.py -v || die
 }
 
-src_install() {
-       distutils_src_install
-       python_generate_wrapper_scripts -E -f -q "${ED}usr/bin/cython"
-
+python_install_all() {
        if use doc; then
-               # "-A c" is for ignoring of "Doc/primes.c".
-               dohtml -A c -r Doc/* || die "Installation of documentation failed"
+               make -C docs html || die "Failed to generate html documentation"
+               HTML_DOCS=( docs/build/html/ )
        fi
 
-       if use examples; then
-               insinto /usr/share/doc/${PF}/examples
-               doins -r Demos/* || die "Installation of examples failed"
-       fi
+       distutils-r1_python_install_all
 }
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2013-02-09 17:37:31 UTC
*cython-0.18-r1 (09 Feb 2013)

  09 Feb 2013; Michał Górny <mgorny@gentoo.org> +cython-0.18-r1.ebuild:
  Migrate to distutils-r1.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-02-09 17:43:46 UTC
Well, too late to convert but we can still use other fixes you're suggesting.

(In reply to comment #0)
>  * NumPy is only needed in the testsuite, so make it just DEPEND and
> test-USE conditional

Are you sure about that? I still references to numpy in Cython/Compiler/FusedNode.py. Looks like it's a very soft dep but still.
Comment 3 Matěj Laitl 2013-02-09 18:14:33 UTC
(In reply to comment #2)
> Well, too late to convert but we can still use other fixes you're suggesting.

Heh, bad timing, I should've pushed it sooner. :-)

> (In reply to comment #0)
> >  * NumPy is only needed in the testsuite, so make it just DEPEND and
> > test-USE conditional
> 
> Are you sure about that? I still references to numpy in
> Cython/Compiler/FusedNode.py. Looks like it's a very soft dep but still.

Pretty sure i.e. Cython can be used to compile code that uses NumPy and provides some optimizations for it, but it doesn't need itself to do it. FusedNode is a good example:
FusedNode.py-447-        pyx_code.imports.put_chunk(
FusedNode.py-448-            u"""
FusedNode.py-449-                try:
FusedNode.py:450:                    import numpy
FusedNode.py-451-                except ImportError:
FusedNode.py-452-                    numpy = None
FusedNode.py-453-            """)

Without the context it looks like it imports numpy, but actually it just spits code that imports numpy. :-) Code in Build/Inline.py:178 actually imports numpy directly, but only if it is in the process of compiling Cython code that actually imports numpy. Last occasion is:
TestInline.py-6-try:
TestInline.py:7:    import numpy
TestInline.py-8-    has_numpy = True
TestInline.py-9-except:
TestInline.py-10-    has_numpy = False

where it just runs more tests when you have numpy available. (the numpy presence test is done runtime, so it will run the numpy tests even if you compiled Cython without numy installed)

In other words, presence of numpy doesn't affect the built Cython package in any way, and it should run fine w/out numpy installed (unless you build a project that actually uses numpy).
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-02-09 19:11:02 UTC
Oh, thanks. Since we want the widest possible set of tests being run, I'll just make it conditional to 'test'.

By the way, about sphinx. You are mostly correct with the no PYTHON_USEDEP assumption but we treat sphinx a bit different. Since it imports the package code, we need it to have one of the implementations supported by the package (e.g. sphinx for py2 will have wrong grammar for py3-only package), so we just use PYTHON_USEDEP there as well.
Comment 5 Matěj Laitl 2013-02-09 19:56:49 UTC
(In reply to comment #4)
> Oh, thanks. Since we want the widest possible set of tests being run, I'll
> just make it conditional to 'test'.

Good decision.

> By the way, about sphinx. You are mostly correct with the no PYTHON_USEDEP
> assumption but we treat sphinx a bit different. Since it imports the package
> code, we need it to have one of the implementations supported by the package
> (e.g. sphinx for py2 will have wrong grammar for py3-only package), so we
> just use PYTHON_USEDEP there as well.

Good catch, but Cython docs actualy don't use Sphinx' sphinx.ext.autodoc, sphinx.ext.doctest or sphinx.ext.coverage extensions that would be importing Cython code, see docs/conf.py:
37:extensions = [
38-    'ipython_console_highlighting',
39-    'cython_highlighting',
40-    'sphinx.ext.pngmath',
41-    'sphinx.ext.todo',
42-    'sphinx.ext.intersphinx'
43-    ]

The docs are generated just from static .rst files. OTOH, depending on "more of" Sphinx isn't a big deal either.