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

fix building issue on macOS #107

Merged
merged 1 commit into from
Nov 14, 2019
Merged

fix building issue on macOS #107

merged 1 commit into from
Nov 14, 2019

Conversation

cadl
Copy link
Contributor

@cadl cadl commented Nov 6, 2019

Hi. I can't build libmc on my macOS, here is the environment and error log:

OS: macOS Catalina 10.15.1
python: conda python 2.7
log:

creating build/temp.macosx-10.6-x86_64-2.7/libmc
gcc -fno-strict-aliasing -I/Users/cadl/.miniconda2/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Iinclude -I/Users/cadl/.miniconda2/include/python2.7 -c src/HashkitKetama.cpp -o build/temp.macosx-10.6-x86_64-2.7/src/HashkitKetama.o -fno-strict-aliasing -fno-exceptions -fno-rtti -Wall -DMC_USE_SMALL_VECTOR -O3 -DNDEBUG
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]
In file included from src/HashkitKetama.cpp:1:
include/hashkit/ketama.h:3:10: fatal error: 'cassert' file not found
#include
^~~~~~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1

It's seem like a common issue. ref: pandas-dev/pandas#23424

the reason is:

The compiler standard library defaults to either libstdc++ or libc++, depending on the targetted macOS version - libstdc++ for 10.8 and below, and libc++ for 10.9 and above. This is determined by the environment variable MACOSX_DEPLOYMENT_TARGET or the compiler option-mmacosx-version-min, defaulting to the system version otherwise.

When distuils builds extensions on macOS, it setsMACOSX_DEPLOYMENT_TARGET to the version that python was compiled with, even if the host system / Xcode is newer.

Recent macOS versions of python have a 64-bit only variant built for 10.9 (python.org), and a universal 64/32-bit variant built for 10.6 (python.org) or 10.7 (conda). I am running the conda universal variant, so distutils targets macOS 10.7, despite my system being 10.14, with Xcode 10 which doesn't install libstdc++. Hence the failure I saw.

I copy the changes from pandas pandas-dev/pandas#24274 to solve the issue.

@everpcpc everpcpc merged commit 0b566f3 into douban:master Nov 14, 2019
current_system = LooseVersion(platform.mac_ver()[0])
python_target = LooseVersion(
get_config_var('MACOSX_DEPLOYMENT_TARGET'))
if python_target < '10.9' and current_system >= '10.9':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not good.

In [2]: '10.10' > '10.9'
Out[2]: False

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mckelvin

the type of current_system and python_target is LooseVersion

In [1]: from distutils.version import LooseVersion

In [2]: LooseVersion('10.10') > '10.9'
Out[2]: True

maybe if LooseVersion(python_target) < '10.9' and LooseVersion(current_system) >= '10.9': is a better one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we compare using the same type? Like python_target < LooseVersion('10.9')?

@cadl cadl deleted the build-on-mac branch November 14, 2019 08:02
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

Successfully merging this pull request may close these issues.

3 participants