Mercurial > pymonkey
comparison 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 |
comparison
equal
deleted
inserted
replaced
105:9d4cd0803df5 | 106:1e6523de9df1 |
---|---|
56 BUILD_DIR = os.path.abspath('build') | 56 BUILD_DIR = os.path.abspath('build') |
57 | 57 |
58 SPIDERMONKEY_OBJDIR = os.path.join(BUILD_DIR, 'spidermonkey') | 58 SPIDERMONKEY_OBJDIR = os.path.join(BUILD_DIR, 'spidermonkey') |
59 | 59 |
60 SPIDERMONKEY_MAKEFILE = os.path.join(SPIDERMONKEY_OBJDIR, 'Makefile') | 60 SPIDERMONKEY_MAKEFILE = os.path.join(SPIDERMONKEY_OBJDIR, 'Makefile') |
61 | |
62 DOCTEST_OUTPUT_DIR = os.path.join(BUILD_DIR, 'doctest_output') | |
61 | 63 |
62 setup_options = dict( | 64 setup_options = dict( |
63 name='pymonkey', | 65 name='pymonkey', |
64 version='0.0.1', | 66 version='0.0.1', |
65 description='Access SpiderMonkey from Python', | 67 description='Access SpiderMonkey from Python', |
153 retval = subprocess.call(["make"], cwd = SPIDERMONKEY_OBJDIR) | 155 retval = subprocess.call(["make"], cwd = SPIDERMONKEY_OBJDIR) |
154 if retval: | 156 if retval: |
155 sys.exit(retval) | 157 sys.exit(retval) |
156 | 158 |
157 @task | 159 @task |
160 @needs('build_spidermonkey', 'setuptools.command.build') | |
161 def build(options): | |
162 """Builds the pymonkey extension.""" | |
163 | |
164 pass | |
165 | |
166 @task | |
158 def build_docs(options): | 167 def build_docs(options): |
159 """Build the Pymonkey documentation (requires Sphinx).""" | 168 """Build the Pymonkey documentation (requires Sphinx).""" |
160 | 169 |
161 retval = subprocess.call(["sphinx-build", | 170 retval = subprocess.call(["sphinx-build", |
162 "-b", "html", | 171 "-b", "html", |
163 os.path.join("docs", "src"), | 172 os.path.join("docs", "src"), |
164 os.path.join("docs", "rendered")]) | 173 os.path.join("docs", "rendered")]) |
165 if retval: | 174 if retval: |
166 sys.exit(retval) | 175 sys.exit(retval) |
167 | 176 |
168 @task | 177 def get_lib_dir(): |
178 # This is really weird and hacky; it ought to be much easier | |
179 # to figure out the default directory that distutils builds | |
180 # its C extension modules in. | |
181 return [os.path.join(BUILD_DIR, name) | |
182 for name in os.listdir(BUILD_DIR) | |
183 if name.startswith("lib.")][0] | |
184 | |
185 @task | |
186 @needs('build') | |
169 def test(options): | 187 def test(options): |
170 """Test the Pymonkey Python C extension.""" | 188 """Test the Pymonkey Python C extension.""" |
171 | 189 |
172 print "Running test suite." | 190 print "Running test suite." |
173 | 191 |
174 new_env = {} | 192 new_env = {} |
175 new_env.update(os.environ) | 193 new_env.update(os.environ) |
194 | |
195 def append_path(env_var, path): | |
196 paths = new_env.get(env_var, '').split(os.path.pathsep) | |
197 paths.append(path) | |
198 new_env[env_var] = os.path.pathsep.join(paths) | |
199 | |
200 # We have to add our build directory to the python path so that | |
201 # our tests can find the pymonkey module. | |
202 append_path('PYTHONPATH', get_lib_dir()) | |
203 | |
204 if sys.platform == 'win32': | |
205 # If we're on Windows, ensure that the SpiderMonkey DLL | |
206 # can be loaded. | |
207 append_path('PATH', SPIDERMONKEY_OBJDIR) | |
176 | 208 |
177 result = subprocess.call( | 209 result = subprocess.call( |
178 [sys.executable, | 210 [sys.executable, |
179 "test_pymonkey.py"], | 211 "test_pymonkey.py"], |
180 env = new_env | 212 env = new_env |
183 if result: | 215 if result: |
184 sys.exit(result) | 216 sys.exit(result) |
185 | 217 |
186 print "Running doctests." | 218 print "Running doctests." |
187 | 219 |
188 # We have to add our current directory to the python path so that | |
189 # our doctests can find the pymonkey module. | |
190 new_env['PYTHONPATH'] = os.path.abspath('.') | |
191 retval = subprocess.call(["sphinx-build", | 220 retval = subprocess.call(["sphinx-build", |
192 "-b", "doctest", | 221 "-b", "doctest", |
193 os.path.join("docs", "src"), | 222 os.path.join("docs", "src"), |
194 "_doctest_output"], | 223 DOCTEST_OUTPUT_DIR], |
195 env = new_env) | 224 env = new_env) |
196 if retval: | 225 if retval: |
197 sys.exit(retval) | 226 sys.exit(retval) |