Skip to content

Commit

Permalink
maint: improve handling installation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mirca committed Oct 12, 2019
1 parent 7409763 commit 23348f4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ method proposed by [Feng & Palomar (2015)](https://doi.org/10.1109/TSP.2015.2452

**R version:** [**https://mirca.github.io/riskParityPortfolio**](https://mirca.github.io/riskParityPortfolio)

## Installation

``pip install riskparityportfolio``


## License

Copyright 2019 Ze Vinicius and Daniel Palomar
Expand Down
32 changes: 18 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import setuptools
import os

__version__ = '0.1.0dev'
__version__ = '0.1.1'

# Prepare and send a new release to PyPI
if "release" in sys.argv[-1]:
Expand Down Expand Up @@ -61,33 +61,36 @@ def has_flag(compiler, flagname):


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):
"""A custom build extension for adding compiler-specific options."""
c_opts = {
'msvc': ['/EHsc'],
'unix': [],
}

l_opts = {
'msvc': [],
'unix': [],
}
if sys.platform == 'darwin':
c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7']
darwin_opts = ['-stdlib=libc++', '-mmacosx-version-min=10.7']
c_opts['unix'] += darwin_opts
l_opts['unix'] += darwin_opts

def build_extensions(self):
# compiler flags
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
link_opts = self.l_opts.get(ct, [])
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
Expand All @@ -97,6 +100,7 @@ def build_extensions(self):
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = opts
ext.extra_link_args = link_opts
# third-party libraries flags
localincl = "third-party"
if not os.path.exists(os.path.join(localincl, "eigen_3.3.7", "Eigen",
Expand Down

0 comments on commit 23348f4

Please sign in to comment.