Mercurial > pymonkey
annotate setup.py @ 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.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 16 Aug 2009 12:53:46 -0700 |
parents | 9d4cd0803df5 |
children | e6c6bf209444 |
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") |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
146 retval = subprocess.call([configure, |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
147 "--enable-static", |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
148 "--disable-tests"], |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
149 cwd = SPIDERMONKEY_OBJDIR) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
150 if retval: |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
151 sys.exit(retval) |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
152 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
153 print "Running make." |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
154 |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
155 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
|
156 if retval: |
9d4cd0803df5
Added a 'build_spidermonkey' target to setup.py.
Atul Varma <varmaa@toolness.com>
parents:
103
diff
changeset
|
157 sys.exit(retval) |
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 @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
|
160 @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
|
161 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
|
162 """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
|
163 |
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 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
|
165 |
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 @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
|
167 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
|
168 """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
|
169 |
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
|
170 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
|
171 "-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
|
172 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
|
173 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
|
174 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
|
175 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
|
176 |
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
|
177 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
|
178 # 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
|
179 # 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
|
180 # 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
|
181 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
|
182 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
|
183 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
|
184 |
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
|
185 @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
|
186 @needs('build') |
101
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
187 def test(options): |
ca94f99ad55d
Merged setup.py into manage.py.
Atul Varma <varmaa@toolness.com>
parents:
96
diff
changeset
|
188 """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
|
189 |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
190 print "Running test suite." |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
191 |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
192 new_env = {} |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
193 new_env.update(os.environ) |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
194 |
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
|
195 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
|
196 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
|
197 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
|
198 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
|
199 |
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 # 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
|
201 # 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
|
202 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
|
203 |
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 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
|
205 # 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
|
206 # 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
|
207 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
|
208 |
25
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
209 result = subprocess.call( |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
210 [sys.executable, |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
211 "test_pymonkey.py"], |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
212 env = new_env |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
213 ) |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
214 |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
215 if result: |
3c2151124cee
Converted pavement.py to manage.py and added a README.
Atul Varma <varmaa@toolness.com>
parents:
diff
changeset
|
216 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
|
217 |
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
|
218 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
|
219 |
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
|
220 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
|
221 "-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
|
222 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
|
223 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
|
224 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
|
225 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
|
226 sys.exit(retval) |