annotate distutils_mods.py @ 3182:0c07af110477 docs-changes

Ignore Sphinx-generated files
author Thomas Kluyver <takowl@gmail.com>
date Wed, 09 Jan 2013 22:35:43 +0000
parents d319548e5eed
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
558
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
1 #purpose: a few changes to distutils to build betterer.
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
2 # - fixes up paths when using msys.
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
3 #
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
4 #
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
5
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
6 import os
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
7
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
8 import distutils.cygwinccompiler
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
9 distutils.cygwinccompiler.oldMingw32CCompiler= distutils.cygwinccompiler.Mingw32CCompiler
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
10 """
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
11 Should put the above imports at the top of your file.
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
12 and after them put
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
13
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
14 import distutils_mods
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
15 distutils.cygwinccompiler.Mingw32 = distutils_mods.mingcomp
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
16
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
17 """
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
18
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
19 from distutils.errors import DistutilsExecError
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
20
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
21
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
22 class mingcomp(distutils.cygwinccompiler.oldMingw32CCompiler):
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
23
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
24 def spawn(self, cmd):
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
25 """ Because spawn uses a straight call to the systems underlying
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
26 shell, bypassing the string handling goodness of mingw/msys
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
27 something gets fubared. So this little hack method was put
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
28 in its place.
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
29 """
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
30 self.verbose = 1
564
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
31 if self.verbose:
558
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
32 print "cmd :%s:" % cmd
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
33
564
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
34 cmpl = " ".join(cmd)
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
35 cmpl = cmpl.replace("\\", "/")
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
36 cmpl = cmpl.replace("c:", "/c")
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
37 cmpl = cmpl.replace("C:", "/c")
585
d319548e5eed some fixes for building with mingw and msys on windows
Rene Dudfield <renesd@gmail.com>
parents: 564
diff changeset
38 cmpl = cmpl.replace("gcc", "gcc -g ")
558
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
39
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
40 if self.verbose:
564
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
41 print "cmpl is :%s:" % cmpl
558
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
42
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
43 if not self.dry_run:
564
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
44 import tempfile
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
45 tmpfn = tempfile.mktemp(suffix='run_compiler')
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
46 tmpf = open(tmpfn, "w+b")
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
47 tmpf.write(cmpl)
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
48 tmpf.close()
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
49 r = os.system("sh %s" % tmpfn)
558
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
50
564
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
51 os.remove(tmpfn)
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
52 if r != 0:
558
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
53 raise DistutilsExecError, \
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
54 "command '%s' failed with exit status :%d: command was :%s:. " % (cmd[0], r, cmpl)
564
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
55
558
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
56 if self.verbose:
564
1fbf902cbef0 convert tabs to spaces
bob
parents: 558
diff changeset
57 print "return value of the compile command is :%s:" % r
558
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
58
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
59
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
60
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
61
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
62 distutils.cygwinccompiler.Mingw32CCompiler= mingcomp
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
63
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
64
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
65
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
66
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
67
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
68
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
69
dfddb58bfad0 a patching for distutils for correct paths when used with mingw and msys
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
70