Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build fails with Anaconda environment #2

Closed
tsjshg opened this issue Mar 12, 2020 · 2 comments
Closed

build fails with Anaconda environment #2

tsjshg opened this issue Mar 12, 2020 · 2 comments

Comments

@tsjshg
Copy link

tsjshg commented Mar 12, 2020

Hi there,

I got an error like this.

running build
running build_py
creating build
creating build/lib.macosx-10.7-x86_64-3.7
creating build/lib.macosx-10.7-x86_64-3.7/kmeans1d
copying kmeans1d/__init__.py -> build/lib.macosx-10.7-x86_64-3.7/kmeans1d
copying kmeans1d/core.py -> build/lib.macosx-10.7-x86_64-3.7/kmeans1d
copying kmeans1d/version.txt -> build/lib.macosx-10.7-x86_64-3.7/kmeans1d
running build_ext
building 'kmeans1d._core' extension
creating build/temp.macosx-10.7-x86_64-3.7
creating build/temp.macosx-10.7-x86_64-3.7/kmeans1d
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/shingo/anaconda3/include -arch x86_64 -I/Users/shingo/anaconda3/include -arch x86_64 -I/Users/shingo/anaconda3/include/python3.7m -c kmeans1d/_core.cpp -o build/temp.macosx-10.7-x86_64-3.7/kmeans1d/_core.o -std=c++11
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
kmeans1d/_core.cpp:3:10: fatal error: 'algorithm' file not found
#include <algorithm>
         ^~~~~~~~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1

The error occurs only with Anaconda python. I got no error when I use PSF made python command.

I found a similar error and its solutions. According to this, I modified setup.py as following.

extension = Extension('kmeans1d._core', ["kmeans1d/_core.cpp"], 
                        include_dirs=['/Library/Developer/CommandLineTools/usr/include/c++/v1'],
                       extra_link_args=["-stdlib=libc++"],
                       extra_compile_args=['-std=c++11'])

Then I successfully build the package with anaconda python.

I'm sending this just for your information.

@dstein64
Copy link
Owner

Thanks for reporting this.

I was able to reproduce the problem.

I guess that a general solution would be to distribute Python wheel files with the kmeans1d C++ code already compiled. This would have the added benefit that the library would then work even when a user doesn't have a compiler toolchain for building kmeans1d.

That would be a more substantial task, since I'd prefer to automate the process. In the meantime, I put in a fix in PR #3 that allows kmeans1d to compile on Anaconda on macOS. If the initial compilation fails, a second attempt is made using the -stdlib=libc++ argument for the compiler and linker.

@dstein64
Copy link
Owner

As of version 0.3.1, kmeans1d is packaged on PyPI with pre-built wheels, which should reduce the prevalence of similar installation problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants