-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from dstein64/issue2/build_fails_with_anaconda
Add '-stdlib=libc++' so the code can compile on macOS with Anaconda.
- Loading branch information
Showing
2 changed files
with
39 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.2.0 | ||
0.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,31 @@ | ||
import os | ||
import setuptools | ||
from setuptools import Extension, setup | ||
from setuptools.command.build_ext import build_ext | ||
|
||
extension = Extension( | ||
'kmeans1d._core', ["kmeans1d/_core.cpp"], extra_compile_args=['-std=c++11']) | ||
|
||
class BuildExt(build_ext): | ||
"""A custom build extension for adding -stdlib arguments for clang++.""" | ||
|
||
def build_extensions(self): | ||
# '-std=c++11' is added to `extra_compile_args` so the code can compile | ||
# with clang++. This works across compilers (ignored by MSVC). | ||
for extension in self.extensions: | ||
extension.extra_compile_args.append('-std=c++11') | ||
|
||
try: | ||
build_ext.build_extensions(self) | ||
except setuptools.distutils.errors.CompileError: | ||
# Workaround Issue #2. | ||
# '-stdlib=libc++' is added to `extra_compile_args` and `extra_link_args` | ||
# so the code can compile on macOS with Anaconda. | ||
for extension in self.extensions: | ||
extension.extra_compile_args.append('-stdlib=libc++') | ||
extension.extra_link_args.append('-stdlib=libc++') | ||
build_ext.build_extensions(self) | ||
|
||
|
||
extension = Extension('kmeans1d._core', ['kmeans1d/_core.cpp']) | ||
|
||
version_txt = os.path.join(os.path.dirname(__file__), 'kmeans1d', 'version.txt') | ||
with open(version_txt, 'r') as f: | ||
|
@@ -12,19 +35,20 @@ | |
author='Daniel Steinberg', | ||
author_email='[email protected]', | ||
classifiers=[ | ||
'Development Status :: 4 - Beta', | ||
'Intended Audience :: Developers', | ||
'Intended Audience :: Science/Research', | ||
'Topic :: Scientific/Engineering', | ||
'Topic :: Scientific/Engineering :: Artificial Intelligence', | ||
'Topic :: Scientific/Engineering :: Information Analysis', | ||
'License :: OSI Approved :: MIT License', | ||
'Operating System :: Unix', | ||
'Operating System :: POSIX :: Linux', | ||
'Operating System :: MacOS', | ||
'Operating System :: Microsoft :: Windows', | ||
'Programming Language :: Python :: 3', | ||
'Development Status :: 4 - Beta', | ||
'Intended Audience :: Developers', | ||
'Intended Audience :: Science/Research', | ||
'Topic :: Scientific/Engineering', | ||
'Topic :: Scientific/Engineering :: Artificial Intelligence', | ||
'Topic :: Scientific/Engineering :: Information Analysis', | ||
'License :: OSI Approved :: MIT License', | ||
'Operating System :: Unix', | ||
'Operating System :: POSIX :: Linux', | ||
'Operating System :: MacOS', | ||
'Operating System :: Microsoft :: Windows', | ||
'Programming Language :: Python :: 3', | ||
], | ||
cmdclass={'build_ext': BuildExt}, | ||
description='A Python package for optimal 1D k-means clustering', | ||
ext_modules=[extension], | ||
keywords=['k-means', 'machine learning', 'optimization'], | ||
|