#!/usr/bin/env python """JavaScript / Python bridge. Python/JavaScript bridge module, making use of Mozilla's spidermonkey 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. """ import os macros = [] # I've only tested on Linux, so this is guesswork if os.name == "posix": symbol = "XP_UNIX" elif os.name == "nt": symbol = "XP_PC" elif os.name == "mac": symbol = "XP_MAC" # what's XP_MAC_MPW? elif os.name == "os2": symbol = "XP_OS2" macros.append((symbol, None)) from distutils.core import Extension from Pyrex.Distutils import build_ext VERSION = "0.0.1a" NAME = "python-spidermonkey" LICENSE = "GPL" #PLATFORMS = ["any"] CLASSIFIERS = """\ Development Status :: 3 - Alpha Intended Audience :: Developers License :: OSI Approved :: GNU General Public License (GPL) Natural Language :: English Programming Language :: C Programming Language :: JavaScript Programming Language :: Other Programming Language :: Python Topic :: Internet Topic :: Internet :: WWW/HTTP Topic :: Internet :: WWW/HTTP :: Browsers Topic :: Internet :: WWW/HTTP :: Dynamic Content Topic :: Software Development :: Libraries Topic :: Software Development :: Libraries :: Python Modules """ #------------------------------------------------------- # the rest is constant for most of my released packages: # ...but it's not in this case! import sys, string from distutils.core import setup _setup = setup def setup(**kwargs): if not hasattr(sys, "version_info") or sys.version_info < (2, 3): # Python version compatibility # XXX probably download_url came in earlier than 2.3 for key in ["classifiers", "download_url"]: if kwargs.has_key(key): del kwargs[key] ## # Only want packages keyword if this is a package, ## # only want py_modules keyword if this is a single-file module, ## # so get rid of packages or py_modules keyword as appropriate. ## if kwargs["packages"] is None: ## del kwargs["packages"] ## else: ## del kwargs["py_modules"] apply(_setup, (), kwargs) ## if PACKAGE: ## packages = [NAME] ## py_modules = None ## else: ## py_modules = [NAME] ## packages = None doclines = string.split(__doc__, "\n") setup(name = NAME, version = VERSION, license = LICENSE, #platforms = PLATFORMS, # XXX dunno classifiers = filter(None, string.split(CLASSIFIERS, "\n")), author = "John J. Lee", author_email = "jjl@pobox.com", description = doclines[0], url = "http://wwwsearch.sourceforge.net/%s/" % NAME, download_url = ("http://wwwsearch.sourceforge.net/%s/src/" "%s-%s.tar.gz" % (NAME, NAME, VERSION)), long_description = string.join(doclines[2:], "\n"), ## py_modules = py_modules, ## packages = packages, # Specific to python-spidermonkey ext_modules = [Extension("spidermonkey", sources=["spidermonkey.pyx"], libraries=["js"], define_macros=macros) ], cmdclass = {'build_ext': build_ext} )