Mercurial > pymonkey
annotate setup.py @ 108:7f3a91323a88
If 'setup.py build --debug' is run and a spidermonkey build doesn't exist, then spidermonkey is built with debugging enabled.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 16 Aug 2009 13:37:13 -0700 |
parents | e6c6bf209444 |
children | 204cac15c06a |
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 |
105
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
32 import urllib2 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
33 import StringIO |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
34 import tarfile |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
35 import distutils.dir_util |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
36 import distutils.core |
25
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
37 |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
38 from paver.easy import * |
101
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
39 from paver.setuputils import setup |
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
40 |
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
41 SOURCE_FILES = ['pymonkey.cpp', |
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
42 'utils.cpp', |
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
43 'object.cpp', |
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
44 'function.cpp', |
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
45 'undefined.cpp', |
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
46 'context.cpp', |
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
47 'runtime.cpp'] |
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
48 |
105
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
49 SPIDERMONKEY_TAG = "1.8.1pre" |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
50 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
51 SPIDERMONKEY_SRC_URL = ("http://hg.toolness.com/spidermonkey/archive/" |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
52 "%s.tar.bz2" % SPIDERMONKEY_TAG) |
101
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
53 |
105
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
54 SPIDERMONKEY_DIR = os.path.abspath('spidermonkey-%s' % SPIDERMONKEY_TAG) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
55 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
56 BUILD_DIR = os.path.abspath('build') |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
57 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
58 SPIDERMONKEY_OBJDIR = os.path.join(BUILD_DIR, 'spidermonkey') |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
59 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
60 SPIDERMONKEY_MAKEFILE = os.path.join(SPIDERMONKEY_OBJDIR, 'Makefile') |
101
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
61 |
106
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
62 DOCTEST_OUTPUT_DIR = os.path.join(BUILD_DIR, 'doctest_output') |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
63 |
103
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
64 setup_options = dict( |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
65 name='pymonkey', |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
66 version='0.0.1', |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
67 description='Access SpiderMonkey from Python', |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
68 author='Atul Varma', |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
69 author_email='atul@mozilla.com', |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
70 url='http://www.toolness.com' |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
71 ) |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
72 |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
73 ext_options = dict( |
105
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
74 include_dirs = [os.path.join(SPIDERMONKEY_OBJDIR, 'dist', 'include')], |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
75 library_dirs = [SPIDERMONKEY_OBJDIR] |
103
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
76 ) |
101
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
77 |
103
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
78 if sys.platform == 'win32': |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
79 # MSVC can't find the js_static.lib SpiderMonkey library, even though |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
80 # it exists and distutils is trying to tell it to link to it, so |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
81 # we'll just link to the DLL on Windows platforms and install |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
82 # it in a place where Windows can find it at runtime. |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
83 ext_options['libraries'] = ['js3250'] |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
84 ext_options['define_macros'] = [('XP_WIN', 1)] |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
85 # TODO: This is almost certainly not the ideal way to distribute |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
86 # a DLL used by a C extension module. |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
87 setup_options['data_files'] = [ |
105
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
88 ('Lib\\site-packages', [os.path.join(SPIDERMONKEY_OBJDIR, |
103
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
89 'js3250.dll')]) |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
90 ] |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
91 else: |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
92 ext_options['libraries'] = ['js_static'] |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
93 |
105
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
94 setup_options['ext_modules'] = [ |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
95 distutils.core.Extension('pymonkey', |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
96 SOURCE_FILES, |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
97 **ext_options) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
98 ] |
103
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
99 |
257de12e58c4
Added windows build support to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
102
diff
changeset
|
100 setup(**setup_options) |
25
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
101 |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
102 @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
|
103 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
|
104 """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
|
105 |
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
|
106 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
|
107 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
|
108 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
|
109 |
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
|
110 @task |
105
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
111 def build_spidermonkey(options): |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
112 """Fetch and build SpiderMonkey.""" |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
113 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
114 if not os.path.exists(SPIDERMONKEY_DIR): |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
115 print("SpiderMonkey source directory not found, " |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
116 "fetching from %s." % SPIDERMONKEY_SRC_URL) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
117 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
118 urlfile = urllib2.urlopen(SPIDERMONKEY_SRC_URL) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
119 output = StringIO.StringIO() |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
120 done = False |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
121 while not done: |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
122 stuff = urlfile.read(65536) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
123 if stuff: |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
124 output.write(stuff) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
125 sys.stdout.write(".") |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
126 sys.stdout.flush() |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
127 else: |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
128 done = True |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
129 sys.stdout.write("\n") |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
130 urlfile.close() |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
131 output.seek(0) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
132 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
133 print "Extracting files." |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
134 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
135 tar = tarfile.open("", fileobj = output, mode = "r:bz2") |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
136 tar.extractall() |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
137 output.close() |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
138 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
139 distutils.dir_util.mkpath(SPIDERMONKEY_OBJDIR) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
140 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
141 if not os.path.exists(SPIDERMONKEY_MAKEFILE): |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
142 print "Running configure." |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
143 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
144 configure = os.path.join(SPIDERMONKEY_DIR, "js", "src", |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
145 "configure") |
108
7f3a91323a88
If 'setup.py build --debug' is run and a spidermonkey build doesn't exist, then spidermonkey is built with debugging enabled.
Atul Varma <varmaa@toolness.com>
parents:
107
diff
changeset
|
146 cmdline = [configure, |
7f3a91323a88
If 'setup.py build --debug' is run and a spidermonkey build doesn't exist, then spidermonkey is built with debugging enabled.
Atul Varma <varmaa@toolness.com>
parents:
107
diff
changeset
|
147 "--enable-static", |
7f3a91323a88
If 'setup.py build --debug' is run and a spidermonkey build doesn't exist, then spidermonkey is built with debugging enabled.
Atul Varma <varmaa@toolness.com>
parents:
107
diff
changeset
|
148 "--disable-tests"] |
7f3a91323a88
If 'setup.py build --debug' is run and a spidermonkey build doesn't exist, then spidermonkey is built with debugging enabled.
Atul Varma <varmaa@toolness.com>
parents:
107
diff
changeset
|
149 if options.get("build") and options.build.get("debug"): |
7f3a91323a88
If 'setup.py build --debug' is run and a spidermonkey build doesn't exist, then spidermonkey is built with debugging enabled.
Atul Varma <varmaa@toolness.com>
parents:
107
diff
changeset
|
150 cmdline.extend(["--enable-debug", |
7f3a91323a88
If 'setup.py build --debug' is run and a spidermonkey build doesn't exist, then spidermonkey is built with debugging enabled.
Atul Varma <varmaa@toolness.com>
parents:
107
diff
changeset
|
151 "--enable-gczeal"]) |
7f3a91323a88
If 'setup.py build --debug' is run and a spidermonkey build doesn't exist, then spidermonkey is built with debugging enabled.
Atul Varma <varmaa@toolness.com>
parents:
107
diff
changeset
|
152 retval = subprocess.call(cmdline, |
105
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
153 cwd = SPIDERMONKEY_OBJDIR) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
154 if retval: |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
155 sys.exit(retval) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
156 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
157 print "Running make." |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
158 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
159 retval = subprocess.call(["make"], cwd = SPIDERMONKEY_OBJDIR) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
160 if retval: |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
161 sys.exit(retval) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
162 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
163 @task |
106
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
164 @needs('build_spidermonkey', 'setuptools.command.build') |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
165 def build(options): |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
166 """Builds the pymonkey extension.""" |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
167 |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
168 pass |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
169 |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
170 @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
|
171 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
|
172 """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
|
173 |
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
|
174 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
|
175 "-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
|
176 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
|
177 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
|
178 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
|
179 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
|
180 |
107 | 181 def maybe_clean(dirname, only_if_empty = False): |
182 if os.path.exists(dirname): | |
183 if not (only_if_empty and os.listdir(dirname)): | |
184 distutils.dir_util.remove_tree(dirname) | |
185 | |
186 @task | |
187 @needs('setuptools.command.clean') | |
188 def clean(options): | |
189 """Clean up intermediate files, and optionally other files too.""" | |
190 | |
191 maybe_clean(DOCTEST_OUTPUT_DIR) | |
192 | |
193 if options.clean.get("all"): | |
194 maybe_clean(SPIDERMONKEY_OBJDIR) | |
195 | |
196 maybe_clean(BUILD_DIR, only_if_empty = True) | |
197 | |
106
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
198 def get_lib_dir(): |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
199 # This is really weird and hacky; it ought to be much easier |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
200 # to figure out the default directory that distutils builds |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
201 # its C extension modules in. |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
202 return [os.path.join(BUILD_DIR, name) |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
203 for name in os.listdir(BUILD_DIR) |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
204 if name.startswith("lib.")][0] |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
205 |
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
|
206 @task |
106
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
207 @needs('build') |
101
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
208 def test(options): |
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
209 """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
|
210 |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
211 print "Running test suite." |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
212 |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
213 new_env = {} |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
214 new_env.update(os.environ) |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
215 |
106
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
216 def append_path(env_var, path): |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
217 paths = new_env.get(env_var, '').split(os.path.pathsep) |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
218 paths.append(path) |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
219 new_env[env_var] = os.path.pathsep.join(paths) |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
220 |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
221 # We have to add our build directory to the python path so that |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
222 # our tests can find the pymonkey module. |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
223 append_path('PYTHONPATH', get_lib_dir()) |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
224 |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
225 if sys.platform == 'win32': |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
226 # If we're on Windows, ensure that the SpiderMonkey DLL |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
227 # can be loaded. |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
228 append_path('PATH', SPIDERMONKEY_OBJDIR) |
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
229 |
25
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
230 result = subprocess.call( |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
231 [sys.executable, |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
232 "test_pymonkey.py"], |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
233 env = new_env |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
234 ) |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
235 |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
236 if result: |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
237 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
|
238 |
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
|
239 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
|
240 |
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
|
241 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
|
242 "-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
|
243 os.path.join("docs", "src"), |
106
1e6523de9df1
Fixed docs to represent the much-simplified build process, fixed the test target to work w/ default build options, moved doctest output dir into build dir.
Atul Varma <varmaa@toolness.com>
parents:
105
diff
changeset
|
244 DOCTEST_OUTPUT_DIR], |
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
|
245 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
|
246 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
|
247 sys.exit(retval) |