From 980a8a6c1e314f7d66c8a9faf46a2703e9583de9 Mon Sep 17 00:00:00 2001
From: Yaroslav Halchenko <debian@onerussian.com>
Date: Thu, 8 Aug 2013 15:29:29 -0400
Subject: [PATCH] if available cython >= 0.19 -- re-build Cythonized sources
 while monitoring for changes using dh_autoreconf

---
 debian/changelog |  3 +++
 debian/control   |  2 +-
 debian/rules     | 12 +++++++++++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 9308dbd98d..c7d543411a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,9 @@ scikit-learn (0.14.1-1) unstable; urgency=low
 
   * The freshiest upstream release
     - addressed 'clean -a' issue, thus removing the dh_auto_clean override
+  * debian/rules
+    - if available cython >= 0.19 -- re-build Cythonized sources while
+      monitoring for changes using dh_autoreconf
 
  -- Yaroslav Halchenko <debian@onerussian.com>  Thu, 08 Aug 2013 14:06:48 -0400
 
diff --git a/debian/control b/debian/control
index 16ed7d2800..79772b29f4 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: python
 Priority: optional
 Maintainer: NeuroDebian Team <team@neuro.debian.net>
 Uploaders: Yaroslav Halchenko <debian@onerussian.com>, Michael Hanke <michael.hanke@gmail.com>
-Build-Depends: debhelper (>= 7.0.50),
+Build-Depends: debhelper (>= 7.0.50), dh-autoreconf,
                python-all-dev (>= 2.5),
                cython (>= 0.12~),
                python-setuptools,
diff --git a/debian/rules b/debian/rules
index 0818ec0b06..ed72058651 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,6 +11,9 @@ SPHINX_VER := $(shell python -c 'from sphinx import __version__; print __version
 NODOC = $(shell dpkg --compare-versions $(SPHINX_VER) lt 10.1.3 && echo "nodoc" || echo "")
 export DEB_BUILD_OPTIONS += $(NODOC)
 
+CYTHON_VER := $(shell dpkg -l cython 2>/dev/null | awk '/^ii/{print $$3;}' || echo 0)
+RECONF = $(shell dpkg --compare-versions $(CYTHON_VER) ge 0.19 && echo ",autoreconf" || echo "")
+
 # Some tests are known to fail randomly so need to be excluded ATM
 NOSEARGS := 
 # --exclude='test_(sparse_svc_clone_with_callable_kernel|spectral_clustering_sparse|ovr_fit_predict)'
@@ -18,8 +21,15 @@ NOSEARGS :=
 # Mega rule
 %:
 	: # Explicit build system to avoid use of all-in-1 Makefile
-	dh $@ --buildsystem=python_distutils --with python2
+	dh $@ --buildsystem=python_distutils --with python2$(RECONF)
+
+cythonize:
+	@echo "D: removing previously generated by Cython sources"
+	find -iname *.c | xargs grep -l 'Generated by Cython' | xargs rm
+	make cython
 
+override_dh_autoreconf:
+	dh_autoreconf debian/rules -- cythonize
 
 override_dh_clean:
 	rm -rf build doc/_build doc/auto_examples *-stamp *.egg-info sklearn/datasets/__config__.py
-- 
GitLab