Back to index

python3.2  3.2.2
Functions | Variables
fixapplepython23 Namespace Reference

Functions

def findline
def fix
def makescript
def main

Variables

string MAKEFILE = '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/Makefile'
tuple CHANGES
string GCC_SCRIPT = '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc'
string GXX_SCRIPT = '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++'
string SCRIPT

Function Documentation

def fixapplepython23.findline (   lines,
  start 
)
return line starting with given string or -1

Definition at line 41 of file fixapplepython23.py.

00041 
00042 def findline(lines, start):
00043     """return line starting with given string or -1"""
00044     for i in range(len(lines)):
00045         if lines[i][:len(start)] == start:
00046             return i
00047     return -1

Here is the caller graph for this function:

def fixapplepython23.fix (   makefile,
  do_apply 
)
Fix the Makefile, if required.

Definition at line 48 of file fixapplepython23.py.

00048 
00049 def fix(makefile, do_apply):
00050     """Fix the Makefile, if required."""
00051     fixed = False
00052     lines = open(makefile).readlines()
00053 
00054     for old, new in CHANGES:
00055         i = findline(lines, new)
00056         if i >= 0:
00057             # Already fixed
00058             continue
00059         i = findline(lines, old)
00060         if i < 0:
00061             print('fixapplepython23: Python installation not fixed (appears broken)')
00062             print('fixapplepython23: missing line:', old)
00063             return 2
00064         lines[i] = new
00065         fixed = True
00066 
00067     if fixed:
00068         if do_apply:
00069             print('fixapplepython23: Fix to Apple-installed Python 2.3 applied')
00070             os.rename(makefile, makefile + '~')
00071             open(makefile, 'w').writelines(lines)
00072             return 0
00073         else:
00074             print('fixapplepython23: Fix to Apple-installed Python 2.3 should be applied')
00075             return 1
00076     else:
00077         print('fixapplepython23: No fix needed, appears to have been applied before')
00078         return 0

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 90 of file fixapplepython23.py.

00090 
00091 def main():
00092     # Check for -n option
00093     if len(sys.argv) > 1 and sys.argv[1] == '-n':
00094         do_apply = False
00095     else:
00096         do_apply = True
00097     # First check OS version
00098     if sys.byteorder == 'little':
00099         # All intel macs are fine
00100         print("fixapplypython23: no fix is needed on MacOSX on Intel")
00101         sys.exit(0)
00102 
00103     osver =  platform.mac_ver()
00104     if osver != '10.3' and os.ver < '10.3.':
00105         print('fixapplepython23: no fix needed on MacOSX < 10.3')
00106         sys.exit(0)
00107 
00108     if osver >= '10.4':
00109         print('fixapplepython23: no fix needed on MacOSX >= 10.4')
00110         sys.exit(0)
00111 
00112     # Test that a framework Python is indeed installed
00113     if not os.path.exists(MAKEFILE):
00114         print('fixapplepython23: Python framework does not appear to be installed (?), nothing fixed')
00115         sys.exit(0)
00116     # Check that we can actually write the file
00117     if do_apply and not os.access(MAKEFILE, os.W_OK):
00118         print('fixapplepython23: No write permission, please run with "sudo"')
00119         sys.exit(2)
00120     # Create the shell scripts
00121     if do_apply:
00122         if not os.access(GCC_SCRIPT, os.X_OK):
00123             makescript(GCC_SCRIPT, "gcc")
00124         if not os.access(GXX_SCRIPT, os.X_OK):
00125             makescript(GXX_SCRIPT, "g++")
00126     #  Finally fix the makefile
00127     rv = fix(MAKEFILE, do_apply)
00128     #sys.exit(rv)
00129     sys.exit(0)

Here is the call graph for this function:

def fixapplepython23.makescript (   filename,
  compiler 
)
Create a wrapper script for a compiler

Definition at line 79 of file fixapplepython23.py.

00079 
00080 def makescript(filename, compiler):
00081     """Create a wrapper script for a compiler"""
00082     dirname = os.path.split(filename)[0]
00083     if not os.access(dirname, os.X_OK):
00084         os.mkdir(dirname, 0o755)
00085     fp = open(filename, 'w')
00086     fp.write(SCRIPT % compiler)
00087     fp.close()
00088     os.chmod(filename, 0o755)
00089     print('fixapplepython23: Created', filename)

Here is the caller graph for this function:


Variable Documentation

Initial value:
00001 ((
00002     'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n',
00003     'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n'
00004     ),(
00005     'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n',
00006     'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n'
00007     ),(
00008     'CC=\t\tgcc\n',
00009     'CC=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc\n'
00010     ),(
00011     'CXX=\t\tc++\n',
00012     'CXX=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++\n'
00013 ))

Definition at line 20 of file fixapplepython23.py.

string fixapplepython23.GCC_SCRIPT = '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc'

Definition at line 34 of file fixapplepython23.py.

string fixapplepython23.GXX_SCRIPT = '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++'

Definition at line 35 of file fixapplepython23.py.

string fixapplepython23.MAKEFILE = '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/Makefile'

Definition at line 19 of file fixapplepython23.py.

Initial value:
00001 """#!/bin/sh
00002 export MACOSX_DEPLOYMENT_TARGET=10.3
00003 exec %s "${@}"
00004 """

Definition at line 36 of file fixapplepython23.py.