Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 1 | """distutils.command.config |
| 2 | |
| 3 | Implements the Distutils 'config' command, a (mostly) empty command class |
| 4 | that exists mainly to be sub-classed by specific module distributions and |
| 5 | applications. The idea is that while every "config" command is different, |
| 6 | at least they're all named the same, and users always see "config" in the |
| 7 | list of standard commands. Also, this is a good place to put common |
| 8 | configure-like tasks: "try to compile this C code", or "figure out where |
| 9 | this header file lives". |
| 10 | """ |
| 11 | |
Martin v. Löwis | 5a6601c | 2004-11-10 22:23:15 +0000 | [diff] [blame] | 12 | # This module should be kept compatible with Python 2.1. |
Andrew M. Kuchling | d448f66 | 2002-11-19 13:12:28 +0000 | [diff] [blame] | 13 | |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 14 | __revision__ = "$Id$" |
| 15 | |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 16 | import sys, os, string, re |
Greg Ward | 2e38a50 | 2000-10-14 03:40:20 +0000 | [diff] [blame] | 17 | from types import * |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 18 | from distutils.core import Command |
| 19 | from distutils.errors import DistutilsExecError |
Andrew M. Kuchling | 679bc9f | 2003-02-18 01:28:51 +0000 | [diff] [blame] | 20 | from distutils.sysconfig import customize_compiler |
Jeremy Hylton | cd8a114 | 2002-06-04 20:14:43 +0000 | [diff] [blame] | 21 | from distutils import log |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 22 | |
| 23 | LANG_EXT = {'c': '.c', |
| 24 | 'c++': '.cxx'} |
| 25 | |
| 26 | class config (Command): |
| 27 | |
| 28 | description = "prepare to build" |
| 29 | |
| 30 | user_options = [ |
| 31 | ('compiler=', None, |
| 32 | "specify the compiler type"), |
| 33 | ('cc=', None, |
| 34 | "specify the compiler executable"), |
| 35 | ('include-dirs=', 'I', |
| 36 | "list of directories to search for header files"), |
| 37 | ('define=', 'D', |
| 38 | "C preprocessor macros to define"), |
| 39 | ('undef=', 'U', |
| 40 | "C preprocessor macros to undefine"), |
| 41 | ('libraries=', 'l', |
| 42 | "external C libraries to link with"), |
| 43 | ('library-dirs=', 'L', |
| 44 | "directories to search for external C libraries"), |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 45 | |
| 46 | ('noisy', None, |
| 47 | "show every action (compile, link, run, ...) taken"), |
| 48 | ('dump-source', None, |
| 49 | "dump generated source files before attempting to compile them"), |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 50 | ] |
| 51 | |
| 52 | |
| 53 | # The three standard command methods: since the "config" command |
| 54 | # does nothing by default, these are empty. |
| 55 | |
| 56 | def initialize_options (self): |
| 57 | self.compiler = None |
| 58 | self.cc = None |
| 59 | self.include_dirs = None |
| 60 | #self.define = None |
| 61 | #self.undef = None |
| 62 | self.libraries = None |
| 63 | self.library_dirs = None |
| 64 | |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 65 | # maximal output for now |
| 66 | self.noisy = 1 |
| 67 | self.dump_source = 1 |
| 68 | |
| 69 | # list of temporary files generated along-the-way that we have |
| 70 | # to clean at some point |
| 71 | self.temp_files = [] |
| 72 | |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 73 | def finalize_options (self): |
Greg Ward | 2e38a50 | 2000-10-14 03:40:20 +0000 | [diff] [blame] | 74 | if self.include_dirs is None: |
| 75 | self.include_dirs = self.distribution.include_dirs or [] |
| 76 | elif type(self.include_dirs) is StringType: |
| 77 | self.include_dirs = string.split(self.include_dirs, os.pathsep) |
| 78 | |
| 79 | if self.libraries is None: |
| 80 | self.libraries = [] |
| 81 | elif type(self.libraries) is StringType: |
| 82 | self.libraries = [self.libraries] |
| 83 | |
| 84 | if self.library_dirs is None: |
| 85 | self.library_dirs = [] |
| 86 | elif type(self.library_dirs) is StringType: |
| 87 | self.library_dirs = string.split(self.library_dirs, os.pathsep) |
| 88 | |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 89 | |
| 90 | def run (self): |
| 91 | pass |
| 92 | |
| 93 | |
| 94 | # Utility methods for actual "config" commands. The interfaces are |
| 95 | # loosely based on Autoconf macros of similar names. Sub-classes |
| 96 | # may use these freely. |
| 97 | |
| 98 | def _check_compiler (self): |
| 99 | """Check that 'self.compiler' really is a CCompiler object; |
| 100 | if not, make it one. |
| 101 | """ |
| 102 | # We do this late, and only on-demand, because this is an expensive |
| 103 | # import. |
| 104 | from distutils.ccompiler import CCompiler, new_compiler |
| 105 | if not isinstance(self.compiler, CCompiler): |
Greg Ward | cb1f4c4 | 2000-09-30 18:27:54 +0000 | [diff] [blame] | 106 | self.compiler = new_compiler(compiler=self.compiler, |
Jeremy Hylton | cd8a114 | 2002-06-04 20:14:43 +0000 | [diff] [blame] | 107 | dry_run=self.dry_run, force=1) |
Andrew M. Kuchling | 679bc9f | 2003-02-18 01:28:51 +0000 | [diff] [blame] | 108 | customize_compiler(self.compiler) |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 109 | if self.include_dirs: |
| 110 | self.compiler.set_include_dirs(self.include_dirs) |
| 111 | if self.libraries: |
| 112 | self.compiler.set_libraries(self.libraries) |
| 113 | if self.library_dirs: |
| 114 | self.compiler.set_library_dirs(self.library_dirs) |
| 115 | |
| 116 | |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 117 | def _gen_temp_sourcefile (self, body, headers, lang): |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 118 | filename = "_configtest" + LANG_EXT[lang] |
| 119 | file = open(filename, "w") |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 120 | if headers: |
| 121 | for header in headers: |
| 122 | file.write("#include <%s>\n" % header) |
| 123 | file.write("\n") |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 124 | file.write(body) |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 125 | if body[-1] != "\n": |
| 126 | file.write("\n") |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 127 | file.close() |
| 128 | return filename |
| 129 | |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 130 | def _preprocess (self, body, headers, include_dirs, lang): |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 131 | src = self._gen_temp_sourcefile(body, headers, lang) |
| 132 | out = "_configtest.i" |
| 133 | self.temp_files.extend([src, out]) |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 134 | self.compiler.preprocess(src, out, include_dirs=include_dirs) |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 135 | return (src, out) |
| 136 | |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 137 | def _compile (self, body, headers, include_dirs, lang): |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 138 | src = self._gen_temp_sourcefile(body, headers, lang) |
| 139 | if self.dump_source: |
| 140 | dump_file(src, "compiling '%s':" % src) |
| 141 | (obj,) = self.compiler.object_filenames([src]) |
| 142 | self.temp_files.extend([src, obj]) |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 143 | self.compiler.compile([src], include_dirs=include_dirs) |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 144 | return (src, obj) |
| 145 | |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 146 | def _link (self, body, |
| 147 | headers, include_dirs, |
| 148 | libraries, library_dirs, lang): |
| 149 | (src, obj) = self._compile(body, headers, include_dirs, lang) |
Fred Drake | 21d4535 | 2001-12-06 21:01:19 +0000 | [diff] [blame] | 150 | prog = os.path.splitext(os.path.basename(src))[0] |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 151 | self.compiler.link_executable([obj], prog, |
| 152 | libraries=libraries, |
Gustavo Niemeyer | 6b01685 | 2002-11-05 16:12:02 +0000 | [diff] [blame] | 153 | library_dirs=library_dirs, |
| 154 | target_lang=lang) |
Andrew M. Kuchling | b1d6029 | 2001-08-16 14:08:02 +0000 | [diff] [blame] | 155 | |
Just van Rossum | ca3fec7 | 2003-02-03 11:43:54 +0000 | [diff] [blame] | 156 | if self.compiler.exe_extension is not None: |
| 157 | prog = prog + self.compiler.exe_extension |
Andrew M. Kuchling | b1d6029 | 2001-08-16 14:08:02 +0000 | [diff] [blame] | 158 | self.temp_files.append(prog) |
| 159 | |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 160 | return (src, obj, prog) |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 161 | |
| 162 | def _clean (self, *filenames): |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 163 | if not filenames: |
| 164 | filenames = self.temp_files |
| 165 | self.temp_files = [] |
Jeremy Hylton | cd8a114 | 2002-06-04 20:14:43 +0000 | [diff] [blame] | 166 | log.info("removing: %s", string.join(filenames)) |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 167 | for filename in filenames: |
| 168 | try: |
| 169 | os.remove(filename) |
| 170 | except OSError: |
| 171 | pass |
| 172 | |
| 173 | |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 174 | # XXX these ignore the dry-run flag: what to do, what to do? even if |
| 175 | # you want a dry-run build, you still need some sort of configuration |
| 176 | # info. My inclination is to make it up to the real config command to |
| 177 | # consult 'dry_run', and assume a default (minimal) configuration if |
| 178 | # true. The problem with trying to do it here is that you'd have to |
| 179 | # return either true or false from all the 'try' methods, neither of |
| 180 | # which is correct. |
| 181 | |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 182 | # XXX need access to the header search path and maybe default macros. |
| 183 | |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 184 | def try_cpp (self, body=None, headers=None, include_dirs=None, lang="c"): |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 185 | """Construct a source file from 'body' (a string containing lines |
| 186 | of C/C++ code) and 'headers' (a list of header files to include) |
| 187 | and run it through the preprocessor. Return true if the |
| 188 | preprocessor succeeded, false if there were any errors. |
| 189 | ('body' probably isn't of much use, but what the heck.) |
| 190 | """ |
| 191 | from distutils.ccompiler import CompileError |
| 192 | self._check_compiler() |
| 193 | ok = 1 |
| 194 | try: |
Andrew M. Kuchling | 6fb8d3a | 2001-08-16 13:56:40 +0000 | [diff] [blame] | 195 | self._preprocess(body, headers, include_dirs, lang) |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 196 | except CompileError: |
| 197 | ok = 0 |
| 198 | |
| 199 | self._clean() |
| 200 | return ok |
| 201 | |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 202 | def search_cpp (self, pattern, body=None, |
| 203 | headers=None, include_dirs=None, lang="c"): |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 204 | """Construct a source file (just like 'try_cpp()'), run it through |
| 205 | the preprocessor, and return true if any line of the output matches |
| 206 | 'pattern'. 'pattern' should either be a compiled regex object or a |
| 207 | string containing a regex. If both 'body' and 'headers' are None, |
| 208 | preprocesses an empty file -- which can be useful to determine the |
| 209 | symbols the preprocessor and compiler set by default. |
| 210 | """ |
| 211 | |
| 212 | self._check_compiler() |
Andrew M. Kuchling | 6fb8d3a | 2001-08-16 13:56:40 +0000 | [diff] [blame] | 213 | (src, out) = self._preprocess(body, headers, include_dirs, lang) |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 214 | |
| 215 | if type(pattern) is StringType: |
| 216 | pattern = re.compile(pattern) |
| 217 | |
| 218 | file = open(out) |
| 219 | match = 0 |
| 220 | while 1: |
| 221 | line = file.readline() |
| 222 | if line == '': |
| 223 | break |
Andrew M. Kuchling | 6fb8d3a | 2001-08-16 13:56:40 +0000 | [diff] [blame] | 224 | if pattern.search(line): |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 225 | match = 1 |
| 226 | break |
| 227 | |
| 228 | file.close() |
| 229 | self._clean() |
| 230 | return match |
| 231 | |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 232 | def try_compile (self, body, headers=None, include_dirs=None, lang="c"): |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 233 | """Try to compile a source file built from 'body' and 'headers'. |
| 234 | Return true on success, false otherwise. |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 235 | """ |
| 236 | from distutils.ccompiler import CompileError |
| 237 | self._check_compiler() |
| 238 | try: |
Andrew M. Kuchling | 6fb8d3a | 2001-08-16 13:56:40 +0000 | [diff] [blame] | 239 | self._compile(body, headers, include_dirs, lang) |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 240 | ok = 1 |
| 241 | except CompileError: |
| 242 | ok = 0 |
| 243 | |
Jeremy Hylton | cd8a114 | 2002-06-04 20:14:43 +0000 | [diff] [blame] | 244 | log.info(ok and "success!" or "failure.") |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 245 | self._clean() |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 246 | return ok |
| 247 | |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 248 | def try_link (self, body, |
| 249 | headers=None, include_dirs=None, |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 250 | libraries=None, library_dirs=None, |
| 251 | lang="c"): |
| 252 | """Try to compile and link a source file, built from 'body' and |
| 253 | 'headers', to executable form. Return true on success, false |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 254 | otherwise. |
| 255 | """ |
| 256 | from distutils.ccompiler import CompileError, LinkError |
| 257 | self._check_compiler() |
| 258 | try: |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 259 | self._link(body, headers, include_dirs, |
| 260 | libraries, library_dirs, lang) |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 261 | ok = 1 |
| 262 | except (CompileError, LinkError): |
| 263 | ok = 0 |
| 264 | |
Jeremy Hylton | cd8a114 | 2002-06-04 20:14:43 +0000 | [diff] [blame] | 265 | log.info(ok and "success!" or "failure.") |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 266 | self._clean() |
| 267 | return ok |
Fred Drake | 21d4535 | 2001-12-06 21:01:19 +0000 | [diff] [blame] | 268 | |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 269 | def try_run (self, body, |
| 270 | headers=None, include_dirs=None, |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 271 | libraries=None, library_dirs=None, |
| 272 | lang="c"): |
| 273 | """Try to compile, link to an executable, and run a program |
| 274 | built from 'body' and 'headers'. Return true on success, false |
| 275 | otherwise. |
| 276 | """ |
| 277 | from distutils.ccompiler import CompileError, LinkError |
| 278 | self._check_compiler() |
| 279 | try: |
Andrew M. Kuchling | 246c425 | 2001-08-13 13:56:24 +0000 | [diff] [blame] | 280 | src, obj, exe = self._link(body, headers, include_dirs, |
| 281 | libraries, library_dirs, lang) |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 282 | self.spawn([exe]) |
| 283 | ok = 1 |
| 284 | except (CompileError, LinkError, DistutilsExecError): |
| 285 | ok = 0 |
| 286 | |
Jeremy Hylton | cd8a114 | 2002-06-04 20:14:43 +0000 | [diff] [blame] | 287 | log.info(ok and "success!" or "failure.") |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 288 | self._clean() |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 289 | return ok |
| 290 | |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 291 | |
| 292 | # -- High-level methods -------------------------------------------- |
| 293 | # (these are the ones that are actually likely to be useful |
| 294 | # when implementing a real-world config command!) |
| 295 | |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 296 | def check_func (self, func, |
| 297 | headers=None, include_dirs=None, |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 298 | libraries=None, library_dirs=None, |
| 299 | decl=0, call=0): |
| 300 | |
| 301 | """Determine if function 'func' is available by constructing a |
| 302 | source file that refers to 'func', and compiles and links it. |
| 303 | If everything succeeds, returns true; otherwise returns false. |
| 304 | |
| 305 | The constructed source file starts out by including the header |
| 306 | files listed in 'headers'. If 'decl' is true, it then declares |
| 307 | 'func' (as "int func()"); you probably shouldn't supply 'headers' |
| 308 | and set 'decl' true in the same call, or you might get errors about |
| 309 | a conflicting declarations for 'func'. Finally, the constructed |
| 310 | 'main()' function either references 'func' or (if 'call' is true) |
| 311 | calls it. 'libraries' and 'library_dirs' are used when |
| 312 | linking. |
| 313 | """ |
| 314 | |
| 315 | self._check_compiler() |
| 316 | body = [] |
| 317 | if decl: |
| 318 | body.append("int %s ();" % func) |
| 319 | body.append("int main () {") |
| 320 | if call: |
| 321 | body.append(" %s();" % func) |
| 322 | else: |
| 323 | body.append(" %s;" % func) |
| 324 | body.append("}") |
| 325 | body = string.join(body, "\n") + "\n" |
| 326 | |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 327 | return self.try_link(body, headers, include_dirs, |
| 328 | libraries, library_dirs) |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 329 | |
| 330 | # check_func () |
| 331 | |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 332 | def check_lib (self, library, library_dirs=None, |
Greg Ward | 4cd6f2a | 2000-10-14 03:56:42 +0000 | [diff] [blame] | 333 | headers=None, include_dirs=None, other_libraries=[]): |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 334 | """Determine if 'library' is available to be linked against, |
| 335 | without actually checking that any particular symbols are provided |
| 336 | by it. 'headers' will be used in constructing the source file to |
| 337 | be compiled, but the only effect of this is to check if all the |
Greg Ward | 4cd6f2a | 2000-10-14 03:56:42 +0000 | [diff] [blame] | 338 | header files listed are available. Any libraries listed in |
| 339 | 'other_libraries' will be included in the link, in case 'library' |
| 340 | has symbols that depend on other libraries. |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 341 | """ |
| 342 | self._check_compiler() |
| 343 | return self.try_link("int main (void) { }", |
Greg Ward | 4cd6f2a | 2000-10-14 03:56:42 +0000 | [diff] [blame] | 344 | headers, include_dirs, |
| 345 | [library]+other_libraries, library_dirs) |
Greg Ward | 855dab9 | 2000-06-27 01:21:22 +0000 | [diff] [blame] | 346 | |
| 347 | def check_header (self, header, include_dirs=None, |
| 348 | library_dirs=None, lang="c"): |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 349 | """Determine if the system header file named by 'header_file' |
| 350 | exists and can be found by the preprocessor; return true if so, |
| 351 | false otherwise. |
| 352 | """ |
Andrew M. Kuchling | 4013cbd | 2002-09-09 12:10:00 +0000 | [diff] [blame] | 353 | return self.try_cpp(body="/* No body */", headers=[header], |
| 354 | include_dirs=include_dirs) |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 355 | |
| 356 | |
Greg Ward | 28a5f44 | 2000-06-06 02:57:07 +0000 | [diff] [blame] | 357 | # class config |
Greg Ward | 59ac709 | 2000-06-21 03:00:50 +0000 | [diff] [blame] | 358 | |
| 359 | |
| 360 | def dump_file (filename, head=None): |
| 361 | if head is None: |
| 362 | print filename + ":" |
| 363 | else: |
| 364 | print head |
| 365 | |
| 366 | file = open(filename) |
| 367 | sys.stdout.write(file.read()) |
| 368 | file.close() |