dropbox / djinni

A tool for generating cross-language type declarations and interface bindings.
Apache License 2.0
2.88k stars 487 forks source link

Cannot build example on macOS 10.12.5 #376

Closed jonmcclung closed 6 years ago

jonmcclung commented 6 years ago

The steps I have taken so far:

git clone https://github.com/dropbox/djinni.git
cd djinni
export ANDROID_NDK_HOME=$ANDROID_NDK_ROOT
make example_android

I get the following error:

...
djinni completed.
ANDROID_BUILD_TOP=/Users/jonmcclung/Library/Android/sdk/android-ndk-r17b deps/gyp/gyp --depth=. -f android -DOS=android -Icommon.gypi example/libtextsort.gyp --root-target=libtextsort_jni
  File "deps/gyp/gyp_main.py", line 12
    except ImportError, e:
                      ^
SyntaxError: invalid syntax
make: *** [GypAndroid.mk] Error 1

This seems to me to be related to the version of Python. That is, I believe it expects me to be using Python 2 when in fact I have both Python 2 and Python 3 installed, and Python 3 is the default. Is there a way for me to specify it should use Python 2 instead, or is there something else I'm doing wrong?

artwyman commented 6 years ago

Yeah, gyp is implemented in Python 2, and the version of it we're using is a deprecated fork so it's unlikely to change. The easiest workaround I could think of would be to edit the main gyp script to refer to python2, or wrap your Djinni build in a script to alter your path or aliases so that python maps to Python 2.

jonmcclung commented 6 years ago

That worked, thank you! For future users who may run into the same problem, manually creating a symbolic link so that the value returned by which python is pointing to python2 fixed it.