Can't configure node.js for make install on OS X (Snow Leopard)

浪子不回头ぞ 提交于 2019-12-10 20:14:07

问题


I cloned the node git repo but the "waf" build tool that comes with node seems to not work with the latest version of Python.

$ ./configure
Traceback (most recent call last):
  File "/Users/greim/nodestuff/node/tools/waf-light", line 157, in <module>
    import Scripting
  File "/Users/greim/nodestuff/node/tools/wafadmin/Scripting.py", line 146
    except Utils.WafError, e:
                         ^
SyntaxError: invalid syntax
$ which python
/Library/Frameworks/Python.framework/Versions/3.0/bin/python

If I understand, that comma is an outdated syntax that doesn't work on Python 3, right?

I'd rather not install an old version of Python just to do this. Ideally I'd like to be able to build and install the latest version, rather than depend on others to distribute .dmg files.

Rock and hard place? Recommendations?


[update] OK, so thanks to all who helped answer this question. Hopefully others will find this on Google. As it turns out I do have Python 2.x on my system (it comes installed by default on OS X) under /usr/bin. So the solution was to update my path (not permanently, just for this one bash session).

$ export PATH=/usr/bin:$PATH
$ ./configure
$ make
$ make install

Tada! Node is installed on my system.


回答1:


Ithe waf project page says

Compatibility from Python 2.3 to 3.1 is maintained (and Jython 2.5)

I think it currently does this by running 2to3.py when unpacking so if you had run first with python2 then it might be wrong. The waf1.6 branch I think is python3 clean

Reading the node.js code the node people expanded waf - which is not how you are meant to use waf. The idea is put the waf binary in the source code - this will expand using the correct version of python

OSX does have python 2 so a way of running the build might be to edit the root makefile and replace the first line

WAF=python tools/waf-light

by

WAF=/usr/bin/python tools/waf-light



回答2:


Yes the comma is outdated: see http://www.python.org/dev/peps/pep-3110/

Unfortunately, there's not much solution, if you stick with python3 you will have to modify the node code to make it work.



来源:https://stackoverflow.com/questions/3819313/cant-configure-node-js-for-make-install-on-os-x-snow-leopard

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!