[dolfin] 01/01: Enable Python 3 support
Johannes Ring
johannr-guest at moszumanska.debian.org
Tue May 30 07:37:53 UTC 2017
This is an automated email from the git hooks/post-receive script.
johannr-guest pushed a commit to branch master
in repository dolfin.
commit 15f92fda216cf464da2c3522002808ab53d017a8
Author: Johannes Ring <johannr at simula.no>
Date: Tue May 30 09:37:42 2017 +0200
Enable Python 3 support
---
debian/changelog | 4 ++
debian/control | 77 ++++++++++++++++++++++++++++---
debian/patches/python3-decode.patch | 30 ++++++++++++
debian/patches/python3-support.patch | 88 ++++++++++++++++++++++++++++++++++++
debian/patches/series | 2 +
debian/python-dolfin.install | 2 +-
debian/python3-dolfin.install | 1 +
debian/rules | 67 ++++++++++++---------------
8 files changed, 226 insertions(+), 45 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index e95663a..9c7a2b4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,14 @@
dolfin (2016.2.0-3) UNRELEASED; urgency=medium
+ [ Drew Parsons ]
* Enable petsc/slepc dependencies on kfreebsd. Note that PETSc
support in dolfin on kfreebsd is not in fact active due to linking
problems during configuration tests, but dolfin builds
successfully without it. Closes: #822971.
+ [ Johannes Ring ]
+ * Support Python 3: new packages python3-dolfin and python3-dolfin-dbg.
+
-- Drew Parsons <dparsons at debian.org> Mon, 20 Mar 2017 10:54:23 +0800
dolfin (2016.2.0-2) unstable; urgency=medium
diff --git a/debian/control b/debian/control
index 80ddb60..7aa4786 100644
--- a/debian/control
+++ b/debian/control
@@ -29,16 +29,27 @@ Build-Depends:
mpi-default-dev,
petsc-dev (>= 3.6.4.dfsg1-2),
slepc-dev (>= 3.6.3.dfsg1-6),
- python-petsc4py, python-slepc4py,
+ python-petsc4py,
+ python-slepc4py,
+ python3-petsc4py,
+ python3-slepc4py,
pkg-config,
python-dev,
+ python3-dev,
+ python-pkg-resources,
+ python3-pkg-resources,
python-ffc (>= 2016.2.0), python-ffc (<< 2016.3.0),
python-dijitso (>= 2016.2.0), python-dijitso (<< 2016.3.0),
+ python3-ffc (>= 2016.2.0), python3-ffc (<< 2016.3.0),
+ python3-dijitso (>= 2016.2.0), python3-dijitso (<< 2016.3.0),
python-numpy,
+ python3-numpy,
python-ply,
+ python3-ply,
swig3.0 (>= 3.0.3)
Standards-Version: 3.9.8
X-Python-Version: >= 2.7
+X-Python3-Version: >= 3.4
Homepage: http://fenicsproject.org
Vcs-Git: https://anonscm.debian.org/git/debian-science/packages/fenics/dolfin.git
Vcs-Browser: https://anonscm.debian.org/git/debian-science/packages/fenics/dolfin.git
@@ -67,6 +78,8 @@ Depends:
libxml2-dev,
pkg-config,
${petsc:Depends},
+ ${python-petsc4py:Depends},
+ ${python3-petsc4py:Depends},
${misc:Depends}
Conflicts:
libdolfin0-dev,
@@ -138,13 +151,13 @@ Depends:
python-six,
python-sympy,
python-ufl (>= ${source:Upstream-Version}), python-ufl (<< ${source:Next-Upstream-Version}),
- ${petsc4py:Depends},
+ ${python-petsc4py:Depends},
${misc:Depends},
${python:Depends},
${shlibs:Depends},
${swig:Depends}
Suggests: dolfin-doc
-Description: Python interface for DOLFIN
+Description: Python interface for DOLFIN (Python 2)
DOLFIN is the Python and C++ interface of the FEniCS project for the
automated solution of differential equations, providing a consistent
PSE (Problem Solving Environment) for solving ordinary and partial
@@ -153,7 +166,38 @@ Description: Python interface for DOLFIN
variational forms; automatic and efficient assembly of linear
systems; and support for general families of finite elements.
.
- This package contains the Python interface for DOLFIN.
+ This package contains the Python interface for DOLFIN (Python 2).
+
+Package: python3-dolfin
+Section: python
+Architecture: any
+Depends:
+ libdolfin-dev (= ${binary:Version}),
+ libdolfin2016.2 (= ${binary:Version}),
+ python3-ffc (>= ${source:Upstream-Version}), python3-ffc (<< ${source:Next-Upstream-Version}),
+ python3-dijitso (>= ${source:Upstream-Version}), python3-dijitso (<< ${source:Next-Upstream-Version}),
+ python3-instant (>= ${source:Upstream-Version}), python3-instant (<< ${source:Next-Upstream-Version}),
+ python3-numpy,
+ python3-ply,
+ python3-six,
+ python3-sympy,
+ python3-ufl (>= ${source:Upstream-Version}), python3-ufl (<< ${source:Next-Upstream-Version}),
+ ${python3-petsc4py:Depends},
+ ${misc:Depends},
+ ${python3:Depends},
+ ${shlibs:Depends},
+ ${swig:Depends}
+Suggests: dolfin-doc
+Description: Python interface for DOLFIN (Python 3)
+ DOLFIN is the Python and C++ interface of the FEniCS project for the
+ automated solution of differential equations, providing a consistent
+ PSE (Problem Solving Environment) for solving ordinary and partial
+ differential equations. Key features include a simple, consistent and
+ intuitive object-oriented API; automatic and efficient evaluation of
+ variational forms; automatic and efficient assembly of linear
+ systems; and support for general families of finite elements.
+ .
+ This package contains the Python interface for DOLFIN (Python 3).
Package: python-dolfin-dbg
Section: debug
@@ -164,7 +208,28 @@ Depends:
${python:Depends},
${shlibs:Depends}
Suggests: dolfin-doc
-Description: Python extension modules for DOLFIN with debugging symbols
+Description: Python 2 extension modules for DOLFIN with debugging symbols
+ DOLFIN is the Python and C++ interface of the FEniCS project for the
+ automated solution of differential equations, providing a consistent
+ PSE (Problem Solving Environment) for solving ordinary and partial
+ differential equations. Key features include a simple, consistent and
+ intuitive object-oriented API; automatic and efficient evaluation of
+ variational forms; automatic and efficient assembly of linear
+ systems; and support for general families of finite elements.
+ .
+ This package contains the Python 2 extensions modules for DOLFIN with
+ debugging symbols.
+
+Package: python3-dolfin-dbg
+Section: debug
+Architecture: any
+Depends:
+ python3-dolfin (= ${binary:Version}),
+ ${misc:Depends},
+ ${python3:Depends},
+ ${shlibs:Depends}
+Suggests: dolfin-doc
+Description: Python 3 extension modules for DOLFIN with debugging symbols
DOLFIN is the Python and C++ interface of the FEniCS project for the
automated solution of differential equations, providing a consistent
PSE (Problem Solving Environment) for solving ordinary and partial
@@ -173,7 +238,7 @@ Description: Python extension modules for DOLFIN with debugging symbols
variational forms; automatic and efficient assembly of linear
systems; and support for general families of finite elements.
.
- This package contains the Python extensions modules for DOLFIN with
+ This package contains the Python 3 extensions modules for DOLFIN with
debugging symbols.
Package: dolfin-doc
diff --git a/debian/patches/python3-decode.patch b/debian/patches/python3-decode.patch
new file mode 100644
index 0000000..70e99a1
--- /dev/null
+++ b/debian/patches/python3-decode.patch
@@ -0,0 +1,30 @@
+diff --git a/cmake/scripts/generate-swig-interface.py b/cmake/scripts/generate-swig-interface.py
+index 843a492..78bbd6f 100644
+--- a/cmake/scripts/generate-swig-interface.py
++++ b/cmake/scripts/generate-swig-interface.py
+@@ -212,8 +212,8 @@ def extract_swig_modules_dependencies(module_to_submodules, submodule_info):
+ continue
+
+ # Read code
+- with open(header_file) as f:
+- code = f.read()
++ with open(header_file, 'rb') as f:
++ code = f.read().decode('utf-8')
+
+ try:
+ # Extract type info
+diff --git a/site-packages/dolfin_utils/documentation/extractdocumentation.py b/site-packages/dolfin_utils/documentation/extractdocumentation.py
+index eeaa1b5..ca40ca3 100644
+--- a/site-packages/dolfin_utils/documentation/extractdocumentation.py
++++ b/site-packages/dolfin_utils/documentation/extractdocumentation.py
+@@ -49,8 +49,9 @@ def extract_documentation(dolfin_dir, header, module):
+ indent = 0
+
+ # Iterate over each line
+- f = open(os.path.join(dolfin_dir, "dolfin", module, header))
++ f = open(os.path.join(dolfin_dir, "dolfin", module, header), 'rb')
+ for line in f:
++ line = line.decode('utf-8')
+
+ # Check for comment
+ if "///" in line:
diff --git a/debian/patches/python3-support.patch b/debian/patches/python3-support.patch
new file mode 100644
index 0000000..0634c69
--- /dev/null
+++ b/debian/patches/python3-support.patch
@@ -0,0 +1,88 @@
+diff -Nru dolfin-2016.2.0.orig/cmake/templates/DOLFINConfig.cmake.in dolfin-2016.2.0/cmake/templates/DOLFINConfig.cmake.in
+--- dolfin-2016.2.0.orig/cmake/templates/DOLFINConfig.cmake.in 2017-05-29 18:50:27.456829890 +0200
++++ dolfin-2016.2.0/cmake/templates/DOLFINConfig.cmake.in 2017-05-29 18:55:01.685153757 +0200
+@@ -5,6 +5,14 @@
+
+ # FIXME: Check that naming conforms to CMake standards
+
++if (POLICY CMP0011)
++ cmake_policy(SET CMP0011 NEW)
++endif()
++
++if (POLICY CMP0012)
++ cmake_policy(SET CMP0012 NEW)
++endif()
++
+ # Compute path
+ get_filename_component(DOLFIN_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+@@ -34,17 +42,20 @@
+ # Third party include directories
+ set(DOLFIN_3RD_PARTY_INCLUDE_DIRS "@DOLFIN_DEP_INCLUDE_DIRECTORIES@;@DOLFIN_DEP_SYSTEM_INCLUDE_DIRECTORIES@")
+
+-# Python include directories
+-set(DOLFIN_PYTHON_INCLUDE_DIRS "@NUMPY_INCLUDE_DIR@;@PYTHON_INCLUDE_DIRS@")
+-
+-# Python definitions
+-set(DOLFIN_PYTHON_DEFINITIONS "@DOLFIN_PYTHON_DEFINITIONS@")
+-
+-# Python libraries
+-set(DOLFIN_PYTHON_LIBRARIES "@PYTHON_LIBRARIES@")
+-
+-# Python executable
+-set(DOLFIN_PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@")
++# Python variables
++if ("@DOLFIN_ENABLE_PYTHON@" AND "@PYTHON_FOUND@")
++ if (NOT PYTHON_EXECUTABLE)
++ set(PYTHON_EXECUTABLE @PYTHON_EXECUTABLE@)
++ endif()
++ # Find Python interpreter (defines PYTHON_VERSION)
++ find_package(PythonInterp)
++
++ set(DOLFIN_PYTHON_FILE
++ "${DOLFIN_CMAKE_DIR}/DOLFINPython${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.cmake")
++ if (EXISTS "${DOLFIN_PYTHON_FILE}")
++ include("${DOLFIN_PYTHON_FILE}")
++ endif()
++endif()
+
+ # SWIG executable
+ set(DOLFIN_SWIG_EXECUTABLE "@SWIG_EXECUTABLE@")
+diff -Nru dolfin-2016.2.0.orig/cmake/templates/DOLFINPythonXY.cmake.in dolfin-2016.2.0/cmake/templates/DOLFINPythonXY.cmake.in
+--- dolfin-2016.2.0.orig/cmake/templates/DOLFINPythonXY.cmake.in 1970-01-01 01:00:00.000000000 +0100
++++ dolfin-2016.2.0/cmake/templates/DOLFINPythonXY.cmake.in 2017-05-29 18:52:30.000974677 +0200
+@@ -0,0 +1,15 @@
++# - Python variables
++#
++# This file has been automatically generated.
++
++# Python include directories
++set(DOLFIN_PYTHON_INCLUDE_DIRS "@NUMPY_INCLUDE_DIR@;@PYTHON_INCLUDE_DIRS@")
++
++# Python definitions
++set(DOLFIN_PYTHON_DEFINITIONS "@DOLFIN_PYTHON_DEFINITIONS@")
++
++# Python libraries
++set(DOLFIN_PYTHON_LIBRARIES "@PYTHON_LIBRARIES@")
++
++# Python executable
++set(DOLFIN_PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@")
+diff -Nru dolfin-2016.2.0.orig/dolfin/CMakeLists.txt dolfin-2016.2.0/dolfin/CMakeLists.txt
+--- dolfin-2016.2.0.orig/dolfin/CMakeLists.txt 2017-05-29 18:50:27.460829895 +0200
++++ dolfin-2016.2.0/dolfin/CMakeLists.txt 2017-05-29 18:54:14.669098264 +0200
+@@ -324,12 +324,15 @@
+ ${CMAKE_BINARY_DIR}/dolfin/DOLFINConfigVersion.cmake @ONLY)
+ configure_file(${DOLFIN_CMAKE_DIR}/templates/UseDOLFIN.cmake.in
+ ${CMAKE_BINARY_DIR}/dolfin/UseDOLFIN.cmake @ONLY)
++configure_file(${DOLFIN_CMAKE_DIR}/templates/DOLFINPythonXY.cmake.in
++ ${CMAKE_BINARY_DIR}/dolfin/DOLFINPython${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.cmake @ONLY)
+
+ install(
+ FILES
+ ${CMAKE_BINARY_DIR}/dolfin/DOLFINConfig.cmake
+ ${CMAKE_BINARY_DIR}/dolfin/DOLFINConfigVersion.cmake
+ ${CMAKE_BINARY_DIR}/dolfin/UseDOLFIN.cmake
++ ${CMAKE_BINARY_DIR}/dolfin/DOLFINPython${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.cmake
+ DESTINATION ${DOLFIN_SHARE_DIR}/cmake
+ COMPONENT Development
+ )
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..c5d62c7
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,2 @@
+python3-support.patch
+python3-decode.patch
diff --git a/debian/python-dolfin.install b/debian/python-dolfin.install
index e3da3e7..6a53a3b 100644
--- a/debian/python-dolfin.install
+++ b/debian/python-dolfin.install
@@ -1 +1 @@
-usr/lib/python*/*-packages/*
+usr/lib/python2*/*-packages/*
diff --git a/debian/python3-dolfin.install b/debian/python3-dolfin.install
new file mode 100644
index 0000000..7aadc9c
--- /dev/null
+++ b/debian/python3-dolfin.install
@@ -0,0 +1 @@
+usr/lib/python3*/*-packages/*
diff --git a/debian/rules b/debian/rules
index 19af5f4..f72ee87 100755
--- a/debian/rules
+++ b/debian/rules
@@ -29,8 +29,9 @@ endif
BUILDDIR = $(CURDIR)/debian/build
DOLFIN_HOME = $(CURDIR)/$(DEB_SRCDIR)
USCAN_DESTDIR := $(CURDIR)
-PYVERS := $(shell pyversions --requested debian/control | tac -s' ')
-DEFAULT_PYVER := $(shell pyversions -d)
+PY2VERS := $(shell pyversions --requested debian/control | tac -s' ')
+PY3VERS := $(shell py3versions --requested debian/control | tac -s' ')
+PYVERS = $(PY2VERS) $(PY3VERS)
# extract PETSc version from petsc-dev
PETSC_DEB_VERSION=$(shell dpkg -s petsc-dev | awk '/Version:/ {print $2}')
@@ -76,44 +77,31 @@ CMAKE_OPTS := \
-D CMAKE_CXX_FLAGS:STRING="-fpermissive" \
$(DOLFIN_HOME)
-ifeq (,$(DISTRIBUTION))
- DISTRIBUTION := $(shell dpkg-parsechangelog --format rfc822 | sed -ne "s/^Distribution: //p")
-endif
-
-ifneq ($(DISTRIBUTION),$(findstring $(DISTRIBUTION),"squeeze wheezy lucid maverick natty oneiric precise quantal raring saucy"))
- DISTRIBUTION := sid
-endif
-
-ifneq (,$(findstring $(DISTRIBUTION),"raring saucy sid"))
- PYTHON_INCLUDE_DIR2 = /usr/include/$(DEB_BUILD_MULTIARCH)
- PYTHON_LIBRARY_DIR = /usr/lib/$(DEB_BUILD_MULTIARCH)
-else
- PYTHON_INCLUDE_DIR2 = /usr/include
- PYTHON_LIBRARY_DIR = /usr/lib
-endif
-
%:
- dh $@ --buildsystem=cmake \
- --builddirectory=$(BUILDDIR)-$(DEFAULT_PYVER) \
- --with python2 \
- --parallel
+ dh $@ --buildsystem=cmake --with python2,python3 --parallel
override_dh_compress:
dh_compress -X.py -X.cpp -X.h -X.pdf -X.ufl
override_dh_auto_clean:
for v in $(PYVERS); do \
- rm -rf $(BUILDDIR)-$$v; \
+ dh_auto_clean --builddirectory=$(BUILDDIR)-$$v; \
done
override_dh_auto_configure:
for v in $(PYVERS); do \
- dh_auto_configure --builddirectory=$(BUILDDIR)-$$v -- \
- -D PYTHON_EXECUTABLE:FILEPATH=/usr/bin/$$v \
- -D PYTHON_LIBRARY:FILEPATH=$(PYTHON_LIBRARY_DIR)/lib$$v.so \
- -D PYTHON_INCLUDE_DIR:PATH=/usr/include/$$v \
- -D PYTHON_INCLUDE_DIR2:PATH=$(PYTHON_INCLUDE_DIR2)/$$v \
- -- $(CMAKE_OPTS) ;\
+ $$v cmake/scripts/generate-swig-interface.py; \
+ if [ "$$v" = "python2.7" ]; then \
+ dh_auto_configure --builddirectory=$(BUILDDIR)-$$v -- \
+ -D PYTHON_EXECUTABLE:FILEPATH=/usr/bin/$$v \
+ -D DOLFIN_USE_PYTHON3:BOOL=OFF \
+ -- $(CMAKE_OPTS) ;\
+ else \
+ dh_auto_configure --builddirectory=$(BUILDDIR)-$$v -- \
+ -D PYTHON_EXECUTABLE:FILEPATH=/usr/bin/$$v \
+ -D DOLFIN_USE_PYTHON3:BOOL=ON \
+ -- $(CMAKE_OPTS) ;\
+ fi; \
done
override_dh_auto_build:
@@ -126,32 +114,35 @@ override_dh_auto_install:
dh_auto_install --builddirectory=$(BUILDDIR)-$$v; \
done
dh_numpy
- sed -i "s/-Werror=format-security//g" $(CURDIR)/debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/pkgconfig/dolfin.pc
- sed -i "s/-g -O2//g" $(CURDIR)/debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/pkgconfig/dolfin.pc
+ dh_numpy3
sed -i "s/-D_FORTIFY_SOURCE=2//g" $(CURDIR)/debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/pkgconfig/dolfin.pc
- sed -i "s/-frounding-math//g" $(CURDIR)/debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/pkgconfig/dolfin.pc
- sed -i "s/-Wformat//g" $(CURDIR)/debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/pkgconfig/dolfin.pc
- sed -i "s/-Wno-deprecated//g" $(CURDIR)/debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/pkgconfig/dolfin.pc
- sed -i "s|-I/usr/local/include||g" $(CURDIR)/debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/pkgconfig/dolfin.pc
sed -i "s|-DNDEBUG||g" $(CURDIR)/debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/pkgconfig/dolfin.pc
- sed -i "s/-Wdate-time//g" $(CURDIR)/debian/tmp/usr/lib/$(DEB_BUILD_MULTIARCH)/pkgconfig/dolfin.pc
+
+override_dh_auto_test:
+ for v in $(PYVERS); do \
+ dh_auto_test --builddirectory=$(BUILDDIR)-$$v; \
+ done
# set petsc:Depends to something like "libpetsc3.7.5-dev, libslepc3.7.3-dev, python-petsc4py (>= 3.7), python-petsc4py (<<3.8), python-slepc4py (>= 3.7), python-slepc4py (<<3.8)"
PETSC_DEV_DEPENDS="libpetsc$(PETSC_UPSTREAM_VERSION)-dev, libslepc$(SLEPC_UPSTREAM_VERSION)-dev"
# slepc4py version must match petsc4py (using the PETSc minor version, not the patch release)
PETSC4PY_DEPENDS=python-petsc4py (>= $(PETSC_VERSION)), python-petsc4py (<< $(PETSC_VERSION_NEXT)), python-slepc4py (>= $(PETSC_VERSION)), python-slepc4py (<< $(PETSC_VERSION_NEXT))
+PETSC4PY_DEPENDS_PY3=python3-petsc4py (>= $(PETSC_VERSION)), python3-petsc4py (<< $(PETSC_VERSION_NEXT)), python3-slepc4py (>= $(PETSC_VERSION)), python3-slepc4py (<< $(PETSC_VERSION_NEXT))
override_dh_gencontrol:
# We have a tight dependency on swig - #675207
set -e; \
swig_version=$$(dpkg-query -W swig3.0 | cut -f 2 | cut -d- -f 1); \
next_swig_version="$${swig_version%.*}.$$(($${swig_version##*.} + 1))"; \
echo "swig:Depends=swig3.0 (>= $$swig_version), swig3.0 (<< $$next_swig_version~)" >> debian/python-dolfin.substvars
- echo "petsc4py:Depends=$(PETSC4PY_DEPENDS)" >> debian/python-dolfin.substvars
+ echo "python-petsc4py:Depends=$(PETSC4PY_DEPENDS)" >> debian/python-dolfin.substvars
+ echo "python3-petsc4py:Depends=$(PETSC4PY_DEPENDS_PY3)" >> debian/python3-dolfin.substvars
+ echo "petsc4py:Depends=$(PETSC4PY_DEPENDS)" >> debian/libdolfin-dev.substvars
dh_gencontrol -- -Vpetsc:Depends=$(PETSC_DEV_DEPENDS) -Vsource:Next-Upstream-Version=$(FENICS_NEXT_VERSION)~
override_dh_strip:
dh_strip -a --package=libdolfin$(FENICS_VERSION) --dbg-package=libdolfin$(FENICS_VERSION)-dbg -Xpython
- dh_strip -a --package=python-dolfin --dbg-package=python-dolfin-dbg
+ dh_strip -a --package=python-dolfin --dbg-package=python-dolfin-dbg -Xpython3
+ dh_strip -a --package=python3-dolfin --dbg-package=python3-dolfin-dbg -Xpython2
override_dh_installman:
dh_installman
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/fenics/dolfin.git
More information about the debian-science-commits
mailing list