On Sun, 19 Apr 2015 19:17:58 -0400 Yaroslav Halchenko 
<y...@onerussian.com> wrote:
> Help indeed would be appreciated
> 

Hello

I needed to use statsmodels for something at work and have partially ported it 
to building a python3 package. I used the pybuild recipe from 
https://wiki.debian.org/Python/LibraryStyleGuide#Overriding

There's two things I didn't resolve were:

You had the the .so files installed into a separate -lib package, which is 
somewhat unusual, that could probably be replicated by using the .install files.

I'm using ipython 3.1 and the code to build the example notebooks broke.

Hopefully this helps some making official python3 packages.

I also changed the watch file to match the github examples from 
https://wiki.debian.org/debian/watch#GitHub because the current version didn't 
download the orignal source for me.

Diane Trout
>From f81ac24d6548e99d405c662bbbaef0b542d6dc47 Mon Sep 17 00:00:00 2001
From: Diane Trout <di...@ghic.org>
Date: Wed, 17 Jun 2015 19:52:06 -0700
Subject: [PATCH 1/2] use recommendations from wiki.debian.org/debian/watch for
 github debian/watch

---
 debian/watch | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/debian/watch b/debian/watch
index 381e81f..d8e44d5 100644
--- a/debian/watch
+++ b/debian/watch
@@ -1,3 +1,3 @@
 version=3
-opts="uversionmangle=s/rc/~rc/g" \
- http://githubredir.debian.net/github/statsmodels/statsmodels/ v(.+).tar.gz
+opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/statsmodels-$1\.tar\.gz/ \
+  https://github.com/statsmodels/statsmodels/tags .*/v?(\d\S*)\.tar\.gz
-- 
2.1.4

>From 7fc33adbcbc440cc2f0cbfa621ee51a8553e7e86 Mon Sep 17 00:00:00 2001
From: Diane Trout <di...@ghic.org>
Date: Wed, 17 Jun 2015 20:04:12 -0700
Subject: [PATCH 2/2] Partially convert to building a python3 package

---
 debian/control                     |  54 +++++++++++----
 debian/python-statsmodels.install  |   1 +
 debian/python3-statsmodels.install |   1 +
 debian/rules                       | 135 ++++++++++++++-----------------------
 4 files changed, 93 insertions(+), 98 deletions(-)
 create mode 100644 debian/python-statsmodels.install
 create mode 100644 debian/python3-statsmodels.install

diff --git a/debian/control b/debian/control
index 12ddfd4..7e3d638 100644
--- a/debian/control
+++ b/debian/control
@@ -3,31 +3,33 @@ Section: python
 Priority: extra
 Maintainer: NeuroDebian Team <t...@neuro.debian.net>
 Uploaders: Yaroslav Halchenko <deb...@onerussian.com>, Michael Hanke <michael.ha...@gmail.com>
-Build-Depends: debhelper (>= 7.0.50~),
+Build-Depends: debhelper (>= 7.0.50~), dh-python,
                python-all-dev, python-setuptools,
-               python-numpy (>= 1:1.4.0),
-               python-scipy,
-               python-nose,
-               python-matplotlib,
-               python-pandas,
-               python-joblib,
-               ipython-notebook (>= 0.13.1) | ipython01x,
-               python-zmq,
+               python3-all, python3-setuptools,
+               python-numpy (>= 1:1.4.0), python3-numpy (>= 1:1.4.0),
+               python-scipy, python3-scipy,
+               python-nose, python3-nose,
+               python-matplotlib, python3-matplotlib,
+               python-pandas, python3-pandas,
+               python-joblib, python3-joblib,
+               ipython-notebook (>= 0.13.1) | ipython01x, ipython3-notebook,
+               python-zmq, python3-zmq,
                cython,
-               python-patsy,
+               python-patsy, python3-patsy,
                python-cvxopt,
 Build-Depends-Indep:
                python-sphinx (>= 1.0.6),
                nodejs | pandoc,
 Standards-Version: 3.9.6
 X-Python-Version: >= 2.7
+X-Python3-Version: >= 3.3
 Homepage: http://statsmodels.sourceforge.net/
 Vcs-Git: git://git.debian.org/pkg-exppsy/statsmodels.git
 Vcs-Browser: http://git.debian.org/?p=pkg-exppsy/statsmodels.git;a=summary
 
 Package: python-statsmodels
-Architecture: all
-Depends: ${misc:Depends}, ${python:Depends},
+Architecture: any
+Depends: ${misc:Depends}, ${python:Depends}, ${shlibs:Depends},
          python-numpy,
          python-scipy,
          python-statsmodels-lib (>= ${source:Version}),
@@ -41,13 +43,39 @@ Suggests: python-statsmodels-doc,
 Provides: ${python:Provides}
 Conflicts: python-scikits-statsmodels, python-scikits.statsmodels (<< 0.4)
 Replaces: python-scikits-statsmodels, python-scikits.statsmodels (<< 0.4)
-Description: Python module for the estimation of statistical models
+Description: Python 2 module for the estimation of statistical models
+ statsmodels Python module provides classes and functions for the
+ estimation of several categories of statistical models. These
+ currently include linear regression models, OLS, GLS, WLS and GLS
+ with AR(p) errors, generalized linear models for six distribution
+ families and M-estimators for robust linear models. An extensive list
+ of result statistics are available for each estimation problem.
+ .
+ This provides the Python 2 version of the library.
+
+Package: python3-statsmodels
+Architecture: any
+Depends: ${misc:Depends}, ${python:Depends}, ${shlibs:Depends},
+         python3-numpy,
+         python3-scipy,
+         python3-patsy
+#         python3-statsmodels-lib (>= ${source:Version}),
+Recommends: python3-pandas,
+            python3-matplotlib,
+            python3-nose,
+            python3-joblib,
+#            python-cvxopt,
+Suggests: python-statsmodels-doc,
+Provides: ${python3:Provides}
+Description: Python 3 module for the estimation of statistical models
  statsmodels Python module provides classes and functions for the
  estimation of several categories of statistical models. These
  currently include linear regression models, OLS, GLS, WLS and GLS
  with AR(p) errors, generalized linear models for six distribution
  families and M-estimators for robust linear models. An extensive list
  of result statistics are available for each estimation problem.
+ .
+ This provides the Python 2 version of the library.
 
 Package: python-statsmodels-lib
 Architecture: any
diff --git a/debian/python-statsmodels.install b/debian/python-statsmodels.install
new file mode 100644
index 0000000..d0a67d5
--- /dev/null
+++ b/debian/python-statsmodels.install
@@ -0,0 +1 @@
+usr/lib/python2*/dist-packages/
diff --git a/debian/python3-statsmodels.install b/debian/python3-statsmodels.install
new file mode 100644
index 0000000..c1ecddb
--- /dev/null
+++ b/debian/python3-statsmodels.install
@@ -0,0 +1 @@
+usr/lib/python3*/dist-packages/
diff --git a/debian/rules b/debian/rules
index 3f70c7e..259acb5 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,11 +6,7 @@
 export HOME=$(CURDIR)/build
 export MPLCONFIGDIR=$(HOME)
 
-PACKAGE_NAME = python-statsmodels
-PACKAGE_ROOT_DIR = debian/${PACKAGE_NAME}
-
-PYVERS = $(shell pyversions -vr)
-PYVER = $(shell pyversions -vd)
+PYBUILD_NAME=statsmodels
 
 UVER := $(shell LC_ALL=C dpkg-parsechangelog | awk '/^Version:/{print $$2;}' | sed -e 's,-[^-]*$$,,g')
 CYTHONVER := $(shell dpkg -l cython | awk '/^ii/{print $$3;}' || echo 0)
@@ -26,7 +22,7 @@ export OPT+=-g -O0
 endif
 
 %:
-	dh  $@ --with python2
+	dh  $@ --with python2,python3,sphinxdoc --buildsystem=pybuild
 
 
 cythonize:
@@ -60,28 +56,32 @@ $(HOME):
 # Build docs during build
 override_dh_auto_build: $(HOME)
 	dh_auto_build
-	: # Hardcode backend to Agg to avoid doc build and tests failures
-	echo "backend : Agg" >| $(MPLCONFIGDIR)/matplotlibrc
-
-
-doc-stamp: python-install$(PYVER)
-	: # I: Generate documentation
-	: # Build Documentation -- assure existence of build/html for nodoc
-	mkdir -p build/html
-ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
-	PYTHONPATH=`/bin/ls -d $(CURDIR)/$(PACKAGE_ROOT_DIR)/usr/lib/python$(PYVER)/*/`:$(CURDIR)$(IPYTHONPATH) \
-	 $(MAKE) -C docs html
-	mv docs/build/* build/
-	: # Fix up links to MathJax to be local
-	grep -l '/mathjax/' -R build/html/examples/notebooks \
-	| xargs sed -i -e 's,https://\S*.com/mathjax/latest/MathJax.js,file:///usr/share/javascript/mathjax/MathJax.js,g'
-	rm -rf docs/source/generated/
-endif
-	touch $@
+	sphinx-build docs/source/ build/html
+
+#doc-stamp: python-install$(PYVER)
+#	: # I: Generate documentation
+#	: # Build Documentation -- assure existence of build/html for nodoc
+#	mkdir -p build/html
+#ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
+#	PYTHONPATH=`/bin/ls -d $(CURDIR)/$(PACKAGE_ROOT_DIR)/usr/lib/python$(PYVER)/*/`:$(CURDIR)$(IPYTHONPATH) \
+#	 $(MAKE) -C docs html
+#	mv docs/build/* build/
+#	: # Fix up links to MathJax to be local
+#	grep -l '/mathjax/' -R build/html/examples/notebooks \
+#	| xargs sed -i -e 's,https://\S*.com/mathjax/latest/MathJax.js,file:///usr/share/javascript/mathjax/MathJax.js,g'
+#	rm -rf docs/source/generated/
+#endif
+#	touch $@
 
 override_dh_auto_clean: $(HOME)
 	dh_auto_clean
 	-rm -f cythonize.dat
+	-rm -rf docs/source/dev/generated/
+	-rm docs/source/_static/gettingstarted_0.png
+	-rm docs/source/datasets/statsmodels.datasets.clear_data_home.rst
+	-rm docs/source/datasets/statsmodels.datasets.get_data_home.rst
+	-rm docs/source/datasets/statsmodels.datasets.get_rdataset.rst
+	-rm docs/source/datasets/statsmodels.datasets.webuse.rst
 
 override_dh_clean:
 	dh_clean
@@ -90,71 +90,36 @@ override_dh_clean:
 	rm -f statsmodels/version.py
 	rm -f doc-stamp
 
-override_dh_auto_install: ${PYVERS:%=python-install%} ${PYVERS:%=python-test%}
-
-# Per Python version logic -- install, test, move .so into -lib
-python-install%:
-	python$* setup.py install --install-layout=deb --root=$(PACKAGE_ROOT_DIR)
-
-python-test%: python-install%
-ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
-	: # Run unittests here against installed statsmodels
-	cd build/ && \
-	 PYTHONPATH=`/bin/ls -d $(CURDIR)/$(PACKAGE_ROOT_DIR)/usr/lib/python$*/*/` \
-	 MPLCONFIGDIR=$(CURDIR)/build \
-	 python$* /usr/bin/nosetests -s -v --exclude=sandbox statsmodels
-else
-	: # Skip unittests due to nocheck
-endif
-
-
-override_dh_install:
-	dh_install
-	: # Remove compiled due to testing files
+override_dh_auto_install:
+	dh_auto_install
 	find debian -name *.pyc -delete
-	: # strip docs/ since they aren't really a Python module, there is -doc for it
-	: # TODO find debian -wholename \*scikits/statsmodels/docs | xargs rm -rf
 	find debian -iname COPYING -o -iname LICENSE* | xargs -r rm -f
-
-
-## immediately useable documentation and exemplar scripts/data
-override_dh_compress:
-	dh_compress -X.py -X.html -X.pdf -X.css -X.jpg -X.txt -X.js -X.json -X.rtc -X.inv -Xobjects.inv
-
-
-override_dh_installdocs:
-	: # Use jquery from Debian package, so prune shipped one
-	-rm ./build/html/_static/jquery.js
-	dh_installdocs
-
+	find debian -name cancer.csv -exec chmod a-x {} \;
+	dh_numpy
+	dh_numpy3
+
+#python-test%: python-install%
+#ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
+#	: # Run unittests here against installed statsmodels
+#	cd build/ && \
+#	 PYTHONPATH=`/bin/ls -d $(CURDIR)/$(PACKAGE_ROOT_DIR)/usr/lib/python$*/*/` \
+#	 MPLCONFIGDIR=$(CURDIR)/build \
+#	 python$* /usr/bin/nosetests -s -v --exclude=sandbox statsmodels
+#else
+#	: # Skip unittests due to nocheck
+#endif
+#
 
 ## move binary libraries into -lib
-override_dh_python2:
-	: # Move platform-specific libraries into -lib
-	for lib in $$(find $(PACKAGE_ROOT_DIR)/usr -name '*.so'); do \
-	   sdir=$$(dirname $$lib) ; \
-	   tdir=$(PACKAGE_ROOT_DIR)-lib/$${sdir#*$(PACKAGE_NAME)/} ; \
-	   mkdir -p $$tdir ; \
-	   echo "I: Moving '$$lib' into '$$tdir'." ; \
-	   mv $$lib $$tdir ; \
-	done
-	if [ -x /usr/bin/dh_numpy ]; then dh_numpy -ppython-statsmodels-lib; fi
-	: # Prune scikits/__init__.py to avoid conflicts
-	find debian -wholename \*scikits/__init__.py -delete
-	: # Move scikits. space into a compatibility package
-	set -e; \
-	find debian -wholename \*scikits -type d | while read skd; do \
-		skbd=$$(dirname $$skd); \
-		skbd_=$$(echo $$skbd | sed -e 's/python-statsmodels/python-scikits.statsmodels/g'); \
-		mkdir -p $$skbd_; \
-		mv $$skd $$skbd_; \
-	done
-	dh_python2
-
-# We build documentation only for -indep
-binary-indep: doc-stamp
-binary: binary-arch binary-indep
-
+#override_dh_python2:
+#	: # Move platform-specific libraries into -lib
+#	for lib in $$(find $(PACKAGE_ROOT_DIR)/usr -name '*.so'); do \
+#	   sdir=$$(dirname $$lib) ; \
+#	   tdir=$(PACKAGE_ROOT_DIR)-lib/$${sdir#*$(PACKAGE_NAME)/} ; \
+#	   mkdir -p $$tdir ; \
+#	   echo "I: Moving '$$lib' into '$$tdir'." ; \
+#	   mv $$lib $$tdir ; \
+#	done
 
 get-orig-source:
 	uscan --upstream-version 0 --rename
-- 
2.1.4

Reply via email to