diff options
authorBryn Keller <>2016-05-02 13:23:42 -0700
committerBryn Keller <>2016-05-02 13:23:42 -0700
commita0d647b35e2cd7702eaffbd2074cb2914c6383cd (patch)
parent83e49c569c2b53a7068f42df616ed8ee695a0fb8 (diff)
Tested with system Python 2.7 on Ubuntu as well as Anaconda Python 3.5 on Ubuntu
3 files changed, 16 insertions, 8 deletions
diff --git a/python/README.rst b/python/README.rst
index 3fd685d..9f7fe41 100644
--- a/python/README.rst
+++ b/python/README.rst
@@ -48,14 +48,18 @@ Suppose you have checked out the PHAT repository at location $PHAT. Then you can
cd $PHAT/python
-pip install .
+ln -s ../include include # (or copy, we just need $PHAT/include to be in the current folder as well)
+pip install pybind11
+python install
-This will install PHAT for whatever Python installation your `pip` executable is associated with.
-Also note that this will install dependencies (pybind11) as well.
-If you already have pybind11 installed, then `python install` will most likely work too.
+This will install PHAT for whatever Python installation your `python` executable is associated with.
+Please ensure you use the `pip` that comes from the same directory where your `python` executable lives!
-Currently, the PHAT Python bindings are known to work on Mac OS X with Python 3.5. Other configurations are untested but in progress.
+Currently, the PHAT Python bindings are known to work on Linux with Python 2.7 and Python 3.5.
+Other configurations are untested but in progress.
Please let us know if there is a platform you'd like us to support, we will do so if we can.
Sample usage
diff --git a/python/_phat.cpp b/python/_phat.cpp
index 40a9421..9883c97 100644
--- a/python/_phat.cpp
+++ b/python/_phat.cpp
@@ -227,7 +227,7 @@ void wrap_persistence_pairs(py::module &m) {
.def("__len__", &phat::persistence_pairs::get_num_pairs)
// Unlike set_pair, this takes a Python 2-tuple
- [](phat::persistence_pairs &p, int index, std::pair<phat::index,phat::index> &pair) {
+ [](phat::persistence_pairs &p, int index, std::pair<phat::index,phat::index> pair) {
phat::index idx = fix_index(p, index);
p.set_pair(idx, pair.first, pair.second);
diff --git a/python/ b/python/
index 2c6d65d..133a204 100644
--- a/python/
+++ b/python/
@@ -2,12 +2,14 @@ from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext
import sys
import os.path
+from io import open
ext_modules = [
- include_dirs=['include', '../include'],
+ include_dirs=['include',
+ '../include'],
@@ -15,7 +17,7 @@ ext_modules = [
here = os.path.abspath(os.path.dirname(__file__))
# Get the long description from the README file
-with open(os.path.join(here, 'README.rst')) as f:
+with open(os.path.join(here, 'README.rst'), encoding = 'utf8') as f:
long_description =
class BuildExt(build_ext):
@@ -31,8 +33,10 @@ class BuildExt(build_ext):
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
+ import pybind11
for ext in self.extensions:
ext.extra_compile_args = opts
+ ext.include_dirs.append(pybind11.get_include())