Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install NodeBox for console

I'm working on OS X Mavericks and want to use the NodeBox modules in Python scripts.

The post about how to install the modules for console is from 2009 and doesn't work anymore as this refers to version 1.9.x (current is 3.0.40). Also the SVN source isn't there anymore. The sources are available at GitHub.

By cloning the project and running:

ant run

all I get is a build of the desktop version.

How do I properly install and run the up to date NodeBox modules in Python scripts?

like image 523
jurihandl Avatar asked Jun 19 '14 09:06

jurihandl


1 Answers

As said in the docs here in section 2. Installing the NodeBox module:

If you want to use NodeBox from the command line, you will have to install it. We currently recommend using Subversion to grab a copy:

svn co http://dev.nodebox.net/svn/nodebox/trunk/ nodebox
...
cd src
python setup.py install

we should be installing the usual way from the source, but as you say the procedure is rather outdated. The source apparently moved from SVN to GitHub at https://github.com/nodebox/nodebox-pyobjc as mentioned on the download page and the source package structure changed too.

Let's grab the source and try to install it:

$ git clone https://github.com/nodebox/nodebox-pyobjc.git
$ cd nodebox-pyobjc
$ python nodebox/setup.py install

Traceback (most recent call last):
  File "nodebox/setup.py", line 17, in <module>
    import nodebox
ImportError: No module named nodebox

So setup.py needs to import the nodebox package, let's add the project root dir to Python path, so that the nodebox package can be found and try again:

$ export PYTHONPATH=$PYTHONPATH:.
$ python nodebox/setup.py install

...
clang: error: no such file or directory: 'nodebox/ext/cGeo.c'
clang: error: no input files
error: command 'clang' failed with exit status 1

Now it turns out some lib paths in setup.py are wrong, no one probably used this for some time while the libs moved around, but we can fix it:

# ext_modules = [
#     Extension('cGeo', ['nodebox/ext/cGeo.c']),
#     Extension('cPathmatics', ['nodebox/ext/cPathmatics.c']),
#     Extension('cPolymagic', ['nodebox/ext/gpc.c', 'nodebox/ext/cPolymagic.m'], extra_link_args=['-framework', 'AppKit', '-framework', 'Foundation'])
#     ]

ext_modules = [
    Extension('cGeo', ['libs/cGeo/cGeo.c']),
    Extension('cPathmatics', ['libs/pathmatics/pathmatics.c']),
    Extension('cPolymagic', ['libs/polymagic/gpc.c', 'libs/polymagic/polymagic.m'], extra_link_args=['-framework', 'AppKit', '-framework', 'Foundation'])
    ]

Try install again:

$ python nodebox/setup.py install
...
running install_egg_info
Writing <python>/lib/python2.7/site-packages/NodeBox-1.9.7rc2-py2.7.egg-info

$ pip list
...
NodeBox (1.9.7rc2)
...

Now the package installed successfully and we should be able to use it:

$ python
>>> import nodebox
>>> dir(nodebox)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__version__', 'get_version']
>>> nodebox.__version__
'1.9.7rc2'

Also, you may still need to manually install some of the dependencies for everything to work correctly, as noted in setup.py itself:

# We require some dependencies:
# - PyObjC
# - psyco
# - py2app
# - cPathMatics (included in the "libs" folder)
# - polymagic (included in the "libs" folder)
# - Numeric (included in the "libs" folder)
# - Numpy (installable using "easy_install numpy")

I already created a pull request with fixed setup.py lib paths, see here.

Tested on OS X Mavericks (System Version: OS X 10.9.3 (13D65), Kernel Version: Darwin 13.2.0) using Homebrew Python 2.7.6.

like image 71
famousgarkin Avatar answered Oct 31 '22 21:10

famousgarkin