annotate manage.py @ 101:ca94f99ad55d

Merged setup.py into manage.py.
author Atul Varma <varmaa@toolness.com>
date Sat, 15 Aug 2009 16:41:48 -0700
parents 3570ab12747b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
1 #! /usr/bin/env python
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
2
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
3 import os
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
4 import sys
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
5
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
6 if __name__ == '__main__':
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
7 # This code is run if we're executed directly from the command-line.
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
8
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
9 myfile = os.path.abspath(__file__)
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
10 mydir = os.path.dirname(myfile)
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
11 sys.path.insert(0, os.path.join(mydir, 'python-modules'))
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
12
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
13 args = sys.argv[1:]
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
14 if not args:
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
15 args = ['help']
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
16
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
17 # Have paver run this very file as its pavement script.
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
18 args = ['-f', myfile] + args
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
19
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
20 import paver.tasks
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
21 paver.tasks.main(args)
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
22 sys.exit(0)
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
23
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
24 # This code is run if we're executed as a pavement script by paver.
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
25
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
26 import os
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
27 import subprocess
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
28 import shutil
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
29 import sys
49
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
30 import webbrowser
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
31 import urllib
25
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
32
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
33 from paver.easy import *
101
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
34 from paver.setuputils import setup
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
35 from distutils.core import Extension
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
36
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
37 SOURCE_FILES = ['pymonkey.cpp',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
38 'utils.cpp',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
39 'object.cpp',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
40 'function.cpp',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
41 'undefined.cpp',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
42 'context.cpp',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
43 'runtime.cpp']
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
44
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
45 SPIDERMONKEY_DIR = os.path.abspath(os.path.join('spidermonkey', 'obj'))
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
46
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
47 if not os.path.exists(SPIDERMONKEY_DIR):
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
48 print('WARNING: Spidermonkey objdir not found at %s.' % SPIDERMONKEY_DIR)
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
49 print('Some build tasks may not run properly.\n')
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
50
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
51 INCLUDE_DIRS = [os.path.join(SPIDERMONKEY_DIR, 'dist', 'include')]
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
52 LIB_DIRS = [os.path.join(SPIDERMONKEY_DIR)]
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
53
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
54 setup(name='pymonkey',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
55 version='0.0.1',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
56 description='Access SpiderMonkey from Python',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
57 author='Atul Varma',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
58 author_email='atul@mozilla.com',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
59 url='http://www.toolness.com',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
60 ext_modules=[Extension('pymonkey',
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
61 SOURCE_FILES,
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
62 include_dirs = INCLUDE_DIRS,
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
63 library_dirs = LIB_DIRS,
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
64 libraries = ['js_static'])]
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
65 )
25
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
66
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
67 @task
49
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
68 def docs(options):
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
69 """Open the Pymonkey documentation in your web browser."""
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
70
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
71 url = os.path.abspath(os.path.join("docs", "rendered", "index.html"))
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
72 url = urllib.pathname2url(url)
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
73 webbrowser.open(url)
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
74
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
75 @task
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
76 def build_docs(options):
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
77 """Build the Pymonkey documentation (requires Sphinx)."""
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
78
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
79 retval = subprocess.call(["sphinx-build",
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
80 "-b", "html",
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
81 os.path.join("docs", "src"),
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
82 os.path.join("docs", "rendered")])
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
83 if retval:
51
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
84 sys.exit(retval)
49
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
85
7401af070bb8 Moved README to Sphinx documentation. Keeping the rendered docs in the repository so that they can be viewed via HG and locally by people who don't have Sphinx installed.
Atul Varma <varmaa@toolness.com>
parents: 37
diff changeset
86 @task
101
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
87 def test(options):
ca94f99ad55d Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents: 96
diff changeset
88 """Test the Pymonkey Python C extension."""
25
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
89
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
90 print "Running test suite."
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
91
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
92 new_env = {}
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
93 new_env.update(os.environ)
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
94
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
95 result = subprocess.call(
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
96 [sys.executable,
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
97 "test_pymonkey.py"],
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
98 env = new_env
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
99 )
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
100
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
101 if result:
3c2151124cee Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
102 sys.exit(result)
51
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
103
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
104 print "Running doctests."
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
105
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
106 # We have to add our current directory to the python path so that
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
107 # our doctests can find the pymonkey module.
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
108 new_env['PYTHONPATH'] = os.path.abspath('.')
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
109 retval = subprocess.call(["sphinx-build",
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
110 "-b", "doctest",
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
111 os.path.join("docs", "src"),
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
112 "_doctest_output"],
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
113 env = new_env)
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
114 if retval:
fabd3f2271fa Added some basic, incomplete docs on the pymonkey module, which include a doctest that's run when pymonkey is built.
Atul Varma <varmaa@toolness.com>
parents: 49
diff changeset
115 sys.exit(retval)