diff --git a/bindings/bindings.py b/bindings/bindings.py index b46357d7..6a74d281 100644 --- a/bindings/bindings.py +++ b/bindings/bindings.py @@ -23,10 +23,16 @@ import os import re -from six import print_ +from six import print_, PY3 import sys from utils import * +if PY3: + do_open = lambda *args, **kwargs: open(*args, encoding='utf-8', **kwargs) +else: + do_open = open + + from optparse import OptionParser try: @@ -160,10 +166,10 @@ class BindingData: if not 'Makefile.am' in filenames: # not a source dir continue - makefile_am = open(os.path.join(base, 'Makefile.am')).read() + makefile_am = do_open(os.path.join(base, 'Makefile.am')).read() filenames = [x for x in filenames if x.endswith('.c') if x in makefile_am] for filename in filenames: - s = open(os.path.join(base, filename)).read() + s = do_open(os.path.join(base, filename)).read() docstrings = regex.findall(s) for d in docstrings: docstring = '\n'.join([x[3:] for x in d.splitlines()]) @@ -406,7 +412,7 @@ def parse_header(header_file): in_struct_private = False in_ifdef_zero = False - lines = open(header_file).readlines() + lines = do_open(header_file).readlines() i = 0 while i < len(lines): line = lines[i] diff --git a/debian-jessie/rules b/debian-jessie/rules index bbd34115..9e6598a4 100644 --- a/debian-jessie/rules +++ b/debian-jessie/rules @@ -26,10 +26,8 @@ ifneq ($(DEB_TARGET_ARCH),i386) endif endif -PYDEF := $(shell pyversions -vd) -PYVERS := $(shell pyversions -vr debian/control) +PYVERS := $(shell pyversions -vr) PY3VERS := $(shell py3versions -vr '>= 3.0') -OTHERPYVERS := $(filter-out $(PYDEF), $(PYVERS)) CFLAGS = `dpkg-buildflags --get CFLAGS` CFLAGS += -Wall @@ -66,7 +64,11 @@ config.status: configure dh_testdir # Add here commands to configure the package. autoreconf -fi - CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) $(CONFIGURE_ARGS) + for v in $(PYVERS) $(PY3VERS); do \ + CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --with-python=/usr/bin/python$$v $(CONFIGURE_ARGS); \ + rm -rf bindings/python$$v; \ + cp -a bindings/python bindings/python$$v; \ + done build: build-stamp @@ -76,19 +78,9 @@ build-stamp: config.status # Add here commands to compile the package. $(MAKE) set -e; \ - for v in $(OTHERPYVERS); do \ - rm -rf bindings/python$$v; \ - cp -a bindings/python bindings/python$$v; \ - sed "s/$(PYDEF)/$$v/g" bindings/python/Makefile > bindings/python$$v/Makefile; \ + for v in $(PYVERS) $(PY3VERS); do \ $(MAKE) -C bindings/python$$v clean; \ - $(MAKE) -C bindings/python$$v; \ - done - for v in $(PY3VERS); do \ - rm -rf bindings/python$$v; \ - cp -a bindings/python bindings/python$$v; \ - sed "s/$(PYDEF)/$$v/g" bindings/python/Makefile > bindings/python$$v/Makefile; \ - $(MAKE) -C bindings/python$$v clean; \ - $(MAKE) -C bindings/python$$v; \ + $(MAKE) -C bindings/python$$v V=1; \ done touch build-stamp @@ -106,10 +98,7 @@ endif [ ! -f Makefile ] || $(MAKE) distclean - for v in $(OTHERPYVERS); do \ - rm -rf bindings/python$$v; \ - done - for v in $(PY3VERS); do \ + for v in $(PYVERS) $(PY3VERS); do \ rm -rf bindings/python$$v; \ done @@ -128,10 +117,7 @@ install: build $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp \ GACUTIL="/usr/bin/gacutil -root $(CURDIR)/debian/tmp/usr/lib" set -e; \ - for v in $(OTHERPYVERS); do \ - $(MAKE) -C bindings/python$$v install DESTDIR=$(CURDIR)/debian/tmp; \ - done - for v in $(PY3VERS); do \ + for v in $(PYVERS) $(PY3VERS); do \ $(MAKE) -C bindings/python$$v install DESTDIR=$(CURDIR)/debian/tmp; \ done diff --git a/debian-stretch/rules b/debian-stretch/rules index 2ada60de..5408bc76 100755 --- a/debian-stretch/rules +++ b/debian-stretch/rules @@ -28,10 +28,8 @@ endif with_php := no -PYDEF := $(shell pyversions -vd) -PYVERS := $(shell pyversions -vr debian/control) +PYVERS := $(shell pyversions -vr) PY3VERS := $(shell py3versions -vr '>= 3.0') -OTHERPYVERS := $(filter-out $(PYDEF), $(PYVERS)) CFLAGS = `dpkg-buildflags --get CFLAGS` CFLAGS += -Wall @@ -63,9 +61,9 @@ else endif ifeq ($(with_php),yes) - CONFIGURE_ARGS += --enable-php --with-php5-config-dir=/etc/php5/mods-available/ + CONFIGURE_ARGS += --enable-php5 --with-php5-config-dir=/etc/php5/mods-available/ else - CONFIGURE_ARGS += --disable-php + CONFIGURE_ARGS += --disable-php5 endif @@ -74,7 +72,11 @@ config.status: configure dh_testdir # Add here commands to configure the package. dh_autoreconf - CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) $(CONFIGURE_ARGS) + for v in $(PYVERS) $(PY3VERS); do \ + CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --with-python=/usr/bin/python$$v $(CONFIGURE_ARGS); \ + rm -rf bindings/python$$v; \ + cp -a bindings/python bindings/python$$v; \ + done build: build-stamp @@ -84,19 +86,9 @@ build-stamp: config.status # Add here commands to compile the package. $(MAKE) V=1 set -e; \ - for v in $(OTHERPYVERS); do \ - rm -rf bindings/python$$v; \ - cp -a bindings/python bindings/python$$v; \ - sed "s/$(PYDEF)/$$v/g" bindings/python/Makefile > bindings/python$$v/Makefile; \ + for v in $(PYVERS) $(PY3VERS); do \ $(MAKE) -C bindings/python$$v clean; \ - $(MAKE) -C bindings/python$$v; \ - done - for v in $(PY3VERS); do \ - rm -rf bindings/python$$v; \ - cp -a bindings/python bindings/python$$v; \ - sed "s/$(PYDEF)/$$v/g" bindings/python/Makefile > bindings/python$$v/Makefile; \ - $(MAKE) -C bindings/python$$v clean; \ - $(MAKE) -C bindings/python$$v; \ + $(MAKE) -C bindings/python$$v V=1; \ done touch build-stamp @@ -121,10 +113,7 @@ endif [ ! -f Makefile ] || $(MAKE) distclean - for v in $(OTHERPYVERS); do \ - rm -rf bindings/python$$v; \ - done - for v in $(PY3VERS); do \ + for v in $(PY2VERS) $(PY3VERS); do \ rm -rf bindings/python$$v; \ done @@ -144,10 +133,7 @@ install: build $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp \ GACUTIL="/usr/bin/gacutil -root $(CURDIR)/debian/tmp/usr/lib" set -e; \ - for v in $(OTHERPYVERS); do \ - $(MAKE) -C bindings/python$$v install DESTDIR=$(CURDIR)/debian/tmp; \ - done - for v in $(PY3VERS); do \ + for v in $(PYVERS) $(PY3VERS); do \ $(MAKE) -C bindings/python$$v install DESTDIR=$(CURDIR)/debian/tmp; \ done