From cdcf5f101523ca2edc497a8de559b2c538ddbd89 Mon Sep 17 00:00:00 2001 From: Bryn Keller Date: Wed, 30 Nov 2016 20:26:34 -0800 Subject: Moved setup.py to root so that we could avoid need for symbolic link. Updated readme.rst and other files to reflect this change, added requirement for enum34 when using python 2.7. Also added explanation that the system python 2.7.10 on Mac OS X is to be avoided. --- python/README.rst | 24 +++++++++++------- python/setup.py | 68 --------------------------------------------------- setup.py | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 77 deletions(-) delete mode 100644 python/setup.py create mode 100644 setup.py diff --git a/python/README.rst b/python/README.rst index 9436ae1..7d9a1e6 100644 --- a/python/README.rst +++ b/python/README.rst @@ -45,26 +45,31 @@ Installation Suppose you have checked out the PHAT repository at location $PHAT. Then you can:: - cd $PHAT/python + cd $PHAT - ln -s ../include include # (or copy, we just need $PHAT/include to be in the current folder as well) + pip install . - pip install pybind11 - - python setup.py install - -This will install PHAT for whatever Python installation your ``python`` executable is associated with. +This will install PHAT for whatever Python installation your ``pip`` 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: * Linux with Python 2.7 (tested on Ubuntu 14.04 with system Python) * Linux with Python 3.5 (tested on Ubuntu 14.04 with Anaconda) -* Mac OS X with Python 2.7 (tested on El Capitan with Anaconda) -* Mac OS X with Python 3.5 (tested on El Capitan with Anaconda) +* Mac OS X with Python 2.7.12 (tested on Sierra with homebrew) +* Mac OS X with Python 3.5 (tested on Sierra with homebrew) Other configurations are untested. +Please note that this package DOES NOT work with the Python 2.7.10 that ships with the operating +system in Mac OS X. These words of wisdom from `python.org`_ are worth heeding: + + The version of Python that ships with OS X is great for learning but it’s not good for development. + The version shipped with OS X may be out of date from the official current Python release, + which is considered the stable production version. + +We recommend installing Python on Mac OS X using either homebrew or Anaconda, according to your taste. + Please let us know if there is a platform you'd like us to support, we will do so if we can. Sample usage @@ -128,3 +133,4 @@ References: .. [4] U.Bauer, M.Kerber, J.Reininghaus: Clear and Compress: Computing Persistent Homology in Chunks. arXiv:1303.0477_ .. _arXiv:1303.0477: http://arxiv.org/pdf/1303.0477.pdf .. _`Persistent Homology Algorithm Toolkit`: https://bitbucket.org/phat/phat-code +.. _`python.org`:http://docs.python-guide.org/en/latest/starting/install/osx/ diff --git a/python/setup.py b/python/setup.py deleted file mode 100644 index f366e88..0000000 --- a/python/setup.py +++ /dev/null @@ -1,68 +0,0 @@ -from setuptools import setup, Extension, find_packages -from setuptools.command.build_ext import build_ext -import sys -import os.path -from io import open - -if sys.version_info < (2, 7, 11): - print("Sorry, PHAT requires Python 2.7.11 or later") - sys.exit(1) - - -ext_modules = [ - Extension( - '_phat', - ['_phat.cpp'], - include_dirs=['include', - '../include'], - language='c++', - ), -] - -here = os.path.abspath(os.path.dirname(__file__)) - -# Get the long description from the README file -with open(os.path.join(here, 'README.rst'), encoding = 'utf8') as f: - long_description = f.read() - -class BuildExt(build_ext): - """A custom build extension for adding compiler-specific options.""" - c_opts = { - 'msvc': ['/EHsc'], - 'unix': ['-std=c++11'], - } - - if sys.platform == 'darwin': - c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7'] - - 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()) - ext.include_dirs.append(pybind11.get_include(user=True)) - build_ext.build_extensions(self) - -setup( - name='phat', - version='0.0.1', - author='Bryn Keller', - author_email='bryn.keller@intel.com', - url='https://bitbucket.org/phat-code/phat', - description='Python bindings for PHAT', - license = 'LGPL', - keywords='algebraic-topology PHAT distributed topology persistent-homology', - long_description=long_description, - ext_modules=ext_modules, - install_requires=['pybind11'], - cmdclass={'build_ext': BuildExt}, - py_modules = ['phat'], - # packages = find_packages(exclude = ['doc', 'test']) - ) - - - - - diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..6d082d7 --- /dev/null +++ b/setup.py @@ -0,0 +1,73 @@ +from setuptools import setup, Extension, find_packages +from setuptools.command.build_ext import build_ext +import sys +import os.path +from io import open + +if sys.version_info < (2, 7, 12): + print("Sorry, PHAT requires Python 2.7.12 or later") + sys.exit(1) + + +ext_modules = [ + Extension( + '_phat', + ['python/_phat.cpp'], + include_dirs=['include'], + language='c++', + ), +] + +here = os.path.abspath(os.path.dirname(__file__)) + +# Get the long description from the README file +with open(os.path.join(here, 'python', 'README.rst'), encoding = 'utf8') as f: + long_description = f.read() + +class BuildExt(build_ext): + """A custom build extension for adding compiler-specific options.""" + c_opts = { + 'msvc': ['/EHsc'], + 'unix': ['-std=c++11'], + } + + if sys.platform == 'darwin': + c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7'] + + 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()) + ext.include_dirs.append(pybind11.get_include(user=True)) + build_ext.build_extensions(self) + +requires = ['pybind11'] + +if sys.version_info < (3,4,0): + requires.append('enum34') + +setup( + name='phat', + version='0.0.1', + author='Bryn Keller', + author_email='bryn.keller@intel.com', + url='https://bitbucket.org/phat-code/phat', + description='Python bindings for PHAT', + license = 'LGPL', + keywords='algebraic-topology PHAT distributed topology persistent-homology', + long_description=long_description, + ext_modules=ext_modules, + install_requires=requires, + cmdclass={'build_ext': BuildExt}, + package_dir={'':'python'}, + py_modules = ['phat'], + # packages = find_packages(exclude = ['doc', 'test']) + ) + + + + + -- cgit v1.2.3