From 4b0f010f59dadd8f82666b625e02ff1840f07dfc Mon Sep 17 00:00:00 2001
From: Christoph Groth <christoph.groth@cea.fr>
Date: Tue, 8 Dec 2015 16:38:36 +0100
Subject: [PATCH] update the previous commit for python 3

---
 INSTALL.rst | 32 +++++++++++++++++++-------------
 setup.py    |  8 ++++----
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/INSTALL.rst b/INSTALL.rst
index 2a0be39d..451724a1 100644
--- a/INSTALL.rst
+++ b/INSTALL.rst
@@ -19,8 +19,8 @@ Prerequisites
 =============
 
 Building Kwant requires
- * `Python <http://python.org>`_ 2.6 or 2.7 (Python 3 is supported by
-   Kwant 1.2 and above),
+ * `Python <http://python.org>`_ 3.4 or above (Kwant 1.1 is the last version to
+   support Python 2),
  * `SciPy <http://scipy.org>`_ 0.9 or newer,
  * `LAPACK <http://netlib.org/lapack/>`_ and `BLAS <http://netlib.org/blas/>`_,
    (For best performance we recommend the free `OpenBLAS
@@ -55,15 +55,15 @@ Kwant can be built and installed following the `usual Python conventions
 <http://docs.python.org/install/index.html>`_ by running the following commands
 in the root directory of the Kwant distribution. ::
 
-    python setup.py build
-    python setup.py install
+    python3 setup.py build
+    python3 setup.py install
 
 Depending on your system, you might have to run the second command with
 administrator privileges (e.g. prefixing it with ``sudo``).
 
 After installation, tests can be run with::
 
-    python -c 'import kwant; kwant.test()'
+    python3 -c 'import kwant; kwant.test()'
 
 The tutorial examples can be found in the directory ``tutorial`` inside the root
 directory of the Kwant source distribution.
@@ -88,7 +88,7 @@ configuration file consists of sections, one for each dependency, led by a
 [dependency-name] header and followed by name = value entries.  Possible names
 are keyword arguments for ``distutils.core.Extension`` (For a complete list,
 see its `documentation
-<http://docs.python.org/2/distutils/apiref.html#distutils.core.Extension>`_).
+<http://docs.python.org/3/distutils/apiref.html#distutils.core.Extension>`_).
 The corresponding values are whitespace-separated lists of strings.
 
 The two currently possible sections are [lapack] and [mumps].  The former
@@ -124,7 +124,7 @@ from the `libRSVG <http://live.gnome.org/LibRsvg>`_ (Debian/Ubuntu package
 ``librsvg2-bin``) are needed to convert SVG drawings into the PDF format.
 
 As a prerequisite for building the documentation, Kwant must have been built
-successfully using ``python setup.py build`` as described above (or Kwant must
+successfully using ``python3 setup.py build`` as described above (or Kwant must
 be already installed in Python's search path).  HTML documentation is built by
 entering the ``doc`` subdirectory of the Kwant package and executing ``make
 html``.  PDF documentation is generated by executing ``make latex`` followed
@@ -156,21 +156,24 @@ root.
 
 2. Unpack Tinyarray, enter its directory. To build and install, run ::
 
-       python setup.py build
-       sudo python setup.py install
+       python3 setup.py build
+       sudo python3 setup.py install
 
 3. Inside the Kwant source distribution's root directory run ::
 
-       python setup.py build
-       sudo python setup.py install
+       python3 setup.py build
+       sudo python3 setup.py install
 
-By default the package will be installed under ``/usr/local``.  Run ``python
+By default the package will be installed under ``/usr/local``.  Run ``python3
 setup.py --help install`` for installation options.
 
 
 Mac OS X: MacPorts
 ==================
 
+The following instructions are valid for Kwant 1.1 with Python 2.7.  They need
+to be updated for Kwant 1.2.  (Help is welcome.)
+
 The required dependencies of Kwant are best installed with one of the packaging
 systems. Here we only consider the case of `MacPorts
 <http://www.macports.org>`_ in detail. Some remarks for homebrew are given
@@ -193,7 +196,7 @@ below.
        python setup.py build
        sudo python setup.py install
 
-5. Unpack Kwant, go to the Kwant directory, and edit ``build.conf`` to read::
+p5. Unpack Kwant, go to the Kwant directory, and edit ``build.conf`` to read::
 
        [lapack]
        extra_link_args = -Wl,-framework -Wl,Accelerate
@@ -218,6 +221,9 @@ with the environment variables ``CC`` and ``LDSHARED`` as shown above.
 Mac OS X: homebrew
 ==================
 
+The following instructions are valid for Kwant 1.1 with Python 2.7.  They need
+to be updated for Kwant 1.2.  (Help is welcome.)
+
 It is also possible to build Kwant using homebrew. The dependencies can be
 installed as ::
 
diff --git a/setup.py b/setup.py
index 99c978c1..c97cfa66 100755
--- a/setup.py
+++ b/setup.py
@@ -13,10 +13,10 @@ from __future__ import print_function
 import sys
 
 v = sys.version_info
-if v[:2] not in [(2, 7), (2, 6)]:
-    error = "This version of Kwant requires Python 2.6 or 2.7.\n"
-    if v[0] >= 2:
-        error += "Please use Kwant 1.2 or above."
+if v[:2] < (3, 4):
+    error = "This version of Kwant requires Python 3.4 or above.\n"
+    if v[0] == 2:
+        error += "Kwant 1.1 is the last version to support Python 2."
     print(error, file=sys.stderr)
     sys.exit(1)
 
-- 
GitLab