Emscripten: OS X El Capitan python problems

Created on 24 Oct 2015  路  24Comments  路  Source: emscripten-core/emscripten

It sounds like OS X doesn't have python2, which we assume in our shebangs. And in El Capitan, adding a symlink on /usr/bin is apparently not possible. This forces people to write python emcc etc.

Perhaps we can do something better? cc @juj

OSX

Most helpful comment

We are working on an update as a priority now. Try the following steps for a dev build:

git clone https://github.com/juj/emsdk.git
cd emsdk
./emsdk install sdk-incoming-64bit --build=Release
./emsdk activate sdk-incoming-64bit
source ./emsdk_env.sh

All 24 comments

+1, experiencing the same issue.

Oh dear...

I do think our choice of setting #!/usr/bin/env python2 as the shebang is the "correct" choice, as per https://www.python.org/dev/peps/pep-0394/ . However, in this case, it sounds like correct = broken, since our use of following the advice of PEP 0394 is "too new", as OS X is not (yet(?)) following that advice.

According to wikipedia page on Shebang, it looks like it must be a full absolute path, which puts us in a bind - we can't create the symlink python2 somewhere else (e.g. under emsdk).

The first thing I can think of would be to rename emcc to emcc.py, and have emcc be a sh script which finds the python2 interpreter on the system (first search for python2, then, if not found, search for python). However, that has the problem that it will break anyone calling python emcc, which can potentially be a large number of users.

Therefore I think what we should do is to rename emcc to emcc.py (with python2 shebang), and then have emcc be a python script with #!/usr/bin/env python shebang, and have that script only detect whether we are currently running in python 2 or python 3 in a cross-pythonic manner. If we're running in python 2, then emcc directly invokes emcc.py in the same interpreter. If instead we are running in python 3, then emcc searches for python2 on the system, and runs emcc.py in the found python 2 interpreter. (or errors out if not present)

That way anyone who is using python emcc will not break, and users of emcc will automatically find the right python version. Does that sound like free from any corner cases?

That does sound good to me. Is it feasible though to have a single script that is both valid python2 and 3, that does those things?

I think it should be. Let me assign this to myself, I'll upgrade one of my setups to El Capitan and see what that looks like.

It is posible to make emcc up an running under el capitan. It is required to

  • download python2.7 from page.
  • Install it.
  • Add an alias not in /usr/bin but inside /usr/local/bin. Alias python2 should point to /Library/Frameworks/Python.framework/Versions/2.7/bin/python
  • cleanup after python installer: (could be verified by call which python)

    • remove alias 'python' if it will point to newly installed python2.7.

    • remove PATH change what python's installed adds to .bashrc or .zshrc

Possible implementation of that plan in #3888.

Pushed to incoming in d1d2b34

@juj , has this been fixed? I just installed the portable emscripten (emsdk-portable v1.35.0), and I followed the platform specific instructions. I'm seeing the following error when running em++:

env: python2: No such file or directory

From the related issues, it seems like you guys fixed the python problems. However, I'm still unable to run emscripten.

It should be fixed, but the fix will only be in next release, I think. Does sdk-incoming-64bit work for you? That should have the fix.

sdk-incoming-64bit doesn't have the python error. however, I do see the following error when running em++:

warning: unresolved symbol: throwInternalError

I get the same error on Ubuntu 16.04 LTS

... running emcc -v under emsdk_portable/emscripten/1.35.0 would still give me env: python2: No such file or directory. I am pretty sure I have the latest version of the SDK because I just installed it yesterday.

Emscripten SDK is a package and build script manager. Having the latest version of Emscripten SDK doesn't yet mean having the latest version of the Emscripten compiler toolchain itself. Try installing sdk-incoming-64bit which builds the latest Emscripten toolchain from source.

The latest hosted precompiled build is still 1.35.0 which does not yet have the fix.

This issue has been closed for almost a year and the portable version still produces this error. Is there a target for updating it? Thanks.

We are working on an update as a priority now. Try the following steps for a dev build:

git clone https://github.com/juj/emsdk.git
cd emsdk
./emsdk install sdk-incoming-64bit --build=Release
./emsdk activate sdk-incoming-64bit
source ./emsdk_env.sh

Got

Traceback (most recent call last):
  File "./emsdk", line 2113, in <module>
    sys.exit(main())
  File "./emsdk", line 2096, in main
    success = tool.install()
  File "./emsdk", line 1221, in install
    success = tool.install()
  File "./emsdk", line 1231, in install
    success = build_fastcomp_tool(self)
  File "./emsdk", line 737, in build_fastcomp_tool
    success = cmake_configure(cmake_generator, build_root, fastcomp_src_root, build_type, args)
  File "./emsdk", line 680, in cmake_configure
    ret = subprocess.check_call(cmdline, cwd=build_root, env=build_env(CMAKE_GENERATOR))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 535, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 13] Permission denied

when running

./emsdk install sdk-incoming-64bit --build=Release

even with sudo

:-(

What does which cmake give you? I.e. does cmake exist?

it gives me /Applications/CMake.app/Contents/bin/cmake

I followed all the generic & os specific installation process from https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html#all-os-installation-instructions-portable-sdk

and look around to make it work on my Mac (Mac OS Sierra 10.12.3)

Note: At least it looks like my binaryen installation is ok, ./bin/wasm-opt works well

Can you print the full logs and not just the error? In particular, what does the line "print('Running CMake: ' + str(cmdline))" give you? Does that cmdline look bad somehow, or does running the same command outside emsdk work?

Here it is
install.txt

what does the line "print('Running CMake: ' + str(cmdline))" give you?

It gives me:
Running CMake: ['cmake', '-G', 'Unix Makefiles', '-DCMAKE_BUILD_TYPE=Release', '-DPYTHON_EXECUTABLE=/usr/bin/python', '-DLLVM_TARGETS_TO_BUILD=X86;JSBackend', '-DLLVM_INCLUDE_EXAMPLES=OFF', '-DCLANG_INCLUDE_EXAMPLES=OFF', '-DLLVM_INCLUDE_TESTS=OFF', '-DCLANG_INCLUDE_TESTS=OFF', '-DLLVM_ENABLE_ASSERTIONS=OFF', '/Users/amorgaut/Documents/git/juj/emsdk/clang/fastcomp/src']

It looks like executing cmake is broken
it returns:
zsh: permission denied: cmake
but permissions look ok to me:
-rwxr-xr-x@ 1 amorgaut admin 6497540 Mar 3 14:59 /Applications/CMake.app/Contents/bin/cmake

I did run the xattr -lcommand on cmake and it appears to be flag as "com.apple.quarantine" which is meant to be related to Apple's Gatekeeper

It doesn't smell very nice ;-)

I installed CMake via its official MacOS dmg installer and did launch the CMake GUI without issue

That's good to hear. What was the original way you got CMake from? Perhaps that is no longer supported in newer OS X versions?

I got it from https://cmake.org/download/
Platform: Mac OSX 10.6 or later
File: cmake-3.8.0-rc2-Darwin-x86_64.dmg
I'm trying to make a build from its GUI hoping I'll get the dialog popup asking if I want to remove it from quarantine

Was this page helpful?
0 / 5 - 0 ratings

Related issues

surma picture surma  路  4Comments

napalm272 picture napalm272  路  4Comments

nerddan picture nerddan  路  4Comments

ShawZG picture ShawZG  路  4Comments

lokpoi888 picture lokpoi888  路  4Comments