Skip to content

Commit

Permalink
Merge pull request #33 from matsui528/bug_fix_setup
Browse files Browse the repository at this point in the history
fix install bug of pybind11 by updating setup.py
  • Loading branch information
matsui528 committed Jul 31, 2019
2 parents 3c97c5e + b6dfcf0 commit ae2652c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
4 changes: 4 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=============

v0.2.6 (August 1, 2019)
----------------------------
- `#33 <https://github.com/matsui528/rii/pull/33>`_ Bug fix to install pybind11 without error


v0.2.5 (August 1, 2019)
----------------------------
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pybind11>=2.2
pybind11>=2.3
nanopq

2 changes: 1 addition & 1 deletion rii/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__all__ = ['Rii']
__version__ = '0.2.5'
__version__ = '0.2.6'

from .rii import Rii

27 changes: 16 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import setuptools
import re
import subprocess

with open('README.md') as f:
readme = f.read()
Expand All @@ -24,6 +25,11 @@ class get_pybind_include(object):
method can be invoked. """

def __init__(self, user=False):
try:
import pybind11
except ImportError:
if subprocess.call([sys.executable, '-m', 'pip', 'install', 'pybind11']):
raise RuntimeError('pybind11 install failed.')
self.user = user

def __str__(self):
Expand Down Expand Up @@ -62,19 +68,17 @@ def has_flag(compiler, flagname):
return False
return True


def cpp_flag(compiler):
"""Return the -std=c++[11/14] compiler flag.
The c++14 is prefered over c++11 (when it is available).
"""Return the -std=c++[11/14/17] compiler flag.
The newer version is prefered over c++11 (when it is available).
"""
if has_flag(compiler, '-std=c++14'):
return '-std=c++14'
elif has_flag(compiler, '-std=c++11'):
return '-std=c++11'
else:
raise RuntimeError('Unsupported compiler -- at least C++11 support '
'is needed!')
flags = ['-std=c++17', '-std=c++14', '-std=c++11']

for flag in flags:
if has_flag(compiler, flag): return flag

raise RuntimeError('Unsupported compiler -- at least C++11 support '
'is needed!')


class BuildExt(build_ext):
Expand Down Expand Up @@ -122,6 +126,7 @@ def build_extensions(self):
license='MIT',
packages=find_packages(),
install_requires=requirements,
setup_requires=['pybind11>=2.3'],
ext_modules=ext_modules,
cmdclass={'build_ext': BuildExt},
zip_safe=False
Expand Down

0 comments on commit ae2652c

Please sign in to comment.