libraries/python-spidermonkey: Updated for version 0.0.8

This commit is contained in:
Larry Hajali 2010-05-13 00:33:21 +02:00 committed by Robby Workman
parent df44105425
commit bd9e4588c6
5 changed files with 108 additions and 34 deletions

View file

@ -1,4 +1,7 @@
Python/JavaScript bridge module, making use of Mozilla's spidermonkey
JavaScript implementation.
JavaScript implementation. Allows implementation of JavaScript classes,
objects and functions in Python, and evaluation and calling of JavaScript
scripts and functions respectively. Borrows heavily from Claes Jacobssen's
Javascript Perl module, in turn based on Mozilla's 'PerlConnect' Perl binding.
This requires js and pysetuptools.
This requires pysetuptools, nose, and js.

View file

@ -1,10 +1,34 @@
Execute arbitrary JavaScript code from Python. Allows you to reference
arbitrary Python objects and functions in the JavaScript VM
Having issues?
==============
The project support site can be found at [lighthouseapp.com][lh].
Requirements
============
Pkg-Config
----------
Mac OS X:
This should be installed by default. If not there is a port package:
$ sudo port install pkgconfig
Debian/Ubuntu:
This is also generally installed by default, but I have reports of it being
otherwise.
$ sudo apt-get install pkg-config
Gentoo:
$ sudo emerge dev-util/pkgconfig
Python Development Files
------------------------
@ -21,6 +45,10 @@ Debian/Ubuntu:
Where X.X is the version of Python you are using. I have not tested
python-spidermonkey on Py3K so it may be horribly broken there.
Gentoo:
If you have python installed, then the headers should already be installed.
Netscape Portable Runtime (nspr)
--------------------------------
@ -35,11 +63,40 @@ Mac OS X:
Debian/Ubuntu:
$ sudo apt-get install libnspr4-dev
Gentoo:
$ sudo emerge dev-libs/nspr
Alternatively you can build from [source][nspr]. If you choose this route make
sure that the nspr-config command is on your $PATH when running the install
commands below.
If you choose this route make
sure that the pkg-config command is on your `$PATH` when running the install
commands below. Additionally, make sure that `$PKG_CONFIG_PATH` is properly
set.
XULRunner (optional)
--------------------
You can optionally build the extension linked to your system's spidermonkey
library, which is installed with XULRunner. You should be able to grab it from
your package manager of choice with something like the following:
Mac OS X:
$ sudo port install xulrunner
Debian/Ubuntu:
$ sudo apt-get install xulrunner-1.9-dev
Gentoo:
$ sudo emerge net-libs/xulrunner
As with [nspr][nspr], you can also build [xulrunner][xulrunner] from source. And as with [nspr][nspr] you need to make sure hat `$PATH` and `$PKG_CONFIG_PATH` are properly set when building the module.
Installation
============
@ -54,11 +111,10 @@ Installation
$ sudo python setup.py develop
Having Issues?
==============
Add issues to the Lighthouse project [here][lh].
If you want to build with the system spidermonkey library, replace the build
command with the following:
$ python setup.py --system-library build
Examples
========
@ -78,7 +134,8 @@ Basics
>>> fruit = Orange()
>>> cx.add_global("apple", fruit)
>>> cx.execute('"Show me the " + apple.is_ripe("raisin");')
Show me the ripe raisin
u'Show me the ripe raisin'
Playing with Classes
--------------------
@ -92,13 +149,14 @@ Playing with Classes
...
>>> rt = spidermonkey.Runtime()
>>> cx = rt.new_context()
>>> cx.add_global(Monkey)
>>> cx.add_global("Monkey", Monkey)
>>> monkey = cx.execute('var x = new Monkey(); x.baz = "schmammo"; x;')
>>> monkey.baz
'schmammo'
u'schmammo'
>>> monkey.__class__.__name__
'Monkey'
JavaScript Functions
--------------------
@ -107,7 +165,29 @@ JavaScript Functions
>>> cx = rt.new_context()
>>> func = cx.execute('function(val) {return "whoosh: " + val;}')
>>> func("zipper!");
'whoosh: zipper!'
u'whoosh: zipper!'
Filtering access to Python
--------------------------
>>> import spidermonkey
>>> rt = spidermonkey.Runtime()
>>> def checker(obj, name):
... return not name.startswith("_")
...
>>> cx = rt.new_context(access=checker)
>>> # Alternatively:
>>> cx.set_access() #doctest: +ELLIPSIS
<function checker at ...>
>>> cx.set_access(checker) #doctest: +ELLIPSIS
<function checker at ...>
>>> cx.add_global("fish", {"gold": "gone", "_old_lady": "huzza"})
>>> cx.execute('fish["_old_lady"];')
Traceback (most recent call last):
...
JSError: Error executing JavaScript.
Previous Authors
================
@ -117,3 +197,4 @@ Previous Authors
[lh]: http://davisp.lighthouseapp.com/projects/26898-python-spidermonkey/overview
[nspr]: ftp://ftp.mozilla.org/pub/mozilla.org/nspr/releases
[xulrunner]: ftp://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases

View file

@ -1,9 +1,11 @@
#!/bin/sh
# Slackware build script for python-spidermonkey
# Written by Larry Hajali <larryhaja[at]gmail[dot]com>
PRGNAM=python-spidermonkey
VERSION=${VERSION:-0.0.5}
VERSION=${VERSION:-0.0.8}
ARCH=${ARCH:-i486}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
@ -29,11 +31,9 @@ find . \
-exec chmod 644 {} \;
# Get rid of ez_setup.
patch -p1 < $CWD/setuptools.diff
# Use the spidermonkey nspr.
sed -i 's|nspr-config|seamonkey-config|' setup.py
sed -i '/ez_setup/d' setup.py MANIFEST.in
python setup.py install --root="${PKG}"
python setup.py install --root=$PKG
( cd $PKG
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | \
@ -44,11 +44,12 @@ python setup.py install --root="${PKG}"
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a LICENSE $PKG/usr/doc/$PRGNAM-$VERSION
install -m 0644 $CWD/README.md $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/README.md > $PKG/usr/doc/$PRGNAM-$VERSION/README.md
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
chmod 0644 $PKG/usr/doc/$PRGNAM-$VERSION/*
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

View file

@ -1,8 +1,10 @@
PRGNAM="python-spidermonkey"
VERSION="0.0.5"
VERSION="0.0.8"
HOMEPAGE="http://pypi.python.org/pypi/python-spidermonkey"
DOWNLOAD="http://pypi.python.org/packages/source/p/python-spidermonkey/python-spidermonkey-0.0.5.tar.gz"
MD5SUM="484c882b675e6519e97e384eeff75ee3"
DOWNLOAD="http://pypi.python.org/packages/source/p/python-spidermonkey/python-spidermonkey-0.0.8.tar.gz"
MD5SUM="035ffc4650e2193a09dd4f81bc30fafd"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
MAINTAINER="Larry Hajali"
EMAIL="larryhaja[at]gmail[dot]com"
APPROVED="rworkman"

View file

@ -1,13 +0,0 @@
diff -Naur python-spidermonkey-0.0.5.orig/setup.py python-spidermonkey-0.0.5/setup.py
--- python-spidermonkey-0.0.5.orig/setup.py 2009-03-13 20:04:25.000000000 +0000
+++ python-spidermonkey-0.0.5/setup.py 2009-03-18 05:47:12.000000000 +0000
@@ -16,8 +16,7 @@
import os
import subprocess as sp
import sys
-import ez_setup
-ez_setup.use_setuptools()
+import setuptools
from setuptools import setup, Extension
def find_sources(extensions=[".c", ".cpp"]):