Back to index

python3.2  3.2.2
Classes | Functions | Variables
distutils.emxccompiler Namespace Reference

Classes

class  EMXCCompiler

Functions

def check_config_h
def get_versions

Variables

string CONFIG_H_OK = "ok"
string CONFIG_H_NOTOK = "not ok"
string CONFIG_H_UNCERTAIN = "uncertain"

Detailed Description

distutils.emxccompiler

Provides the EMXCCompiler class, a subclass of UnixCCompiler that
handles the EMX port of the GNU C compiler to OS/2.

Function Documentation

Check if the current Python installation (specifically, pyconfig.h)
appears amenable to building extensions with GCC.  Returns a tuple
(status, details), where 'status' is one of the following constants:
  CONFIG_H_OK
    all is well, go ahead and compile
  CONFIG_H_NOTOK
    doesn't look good
  CONFIG_H_UNCERTAIN
    not sure -- unable to read pyconfig.h
'details' is a human-readable string explaining the situation.

Note there are two ways to conclude "OK": either 'sys.version' contains
the string "GCC" (implying that this Python was built with GCC), or the
installed "pyconfig.h" contains the string "__GNUC__".

Definition at line 239 of file emxccompiler.py.

00239 
00240 def check_config_h():
00241 
00242     """Check if the current Python installation (specifically, pyconfig.h)
00243     appears amenable to building extensions with GCC.  Returns a tuple
00244     (status, details), where 'status' is one of the following constants:
00245       CONFIG_H_OK
00246         all is well, go ahead and compile
00247       CONFIG_H_NOTOK
00248         doesn't look good
00249       CONFIG_H_UNCERTAIN
00250         not sure -- unable to read pyconfig.h
00251     'details' is a human-readable string explaining the situation.
00252 
00253     Note there are two ways to conclude "OK": either 'sys.version' contains
00254     the string "GCC" (implying that this Python was built with GCC), or the
00255     installed "pyconfig.h" contains the string "__GNUC__".
00256     """
00257 
00258     # XXX since this function also checks sys.version, it's not strictly a
00259     # "pyconfig.h" check -- should probably be renamed...
00260 
00261     from distutils import sysconfig
00262     # if sys.version contains GCC then python was compiled with
00263     # GCC, and the pyconfig.h file should be OK
00264     if sys.version.find("GCC") >= 0:
00265         return (CONFIG_H_OK, "sys.version mentions 'GCC'")
00266 
00267     fn = sysconfig.get_config_h_filename()
00268     try:
00269         # It would probably better to read single lines to search.
00270         # But we do this only once, and it is fast enough
00271         f = open(fn)
00272         try:
00273             s = f.read()
00274         finally:
00275             f.close()
00276 
00277     except IOError as exc:
00278         # if we can't read this file, we cannot say it is wrong
00279         # the compiler will complain later about this file as missing
00280         return (CONFIG_H_UNCERTAIN,
00281                 "couldn't read '%s': %s" % (fn, exc.strerror))
00282 
00283     else:
00284         # "pyconfig.h" contains an "#ifdef __GNUC__" or something similar
00285         if s.find("__GNUC__") >= 0:
00286             return (CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn)
00287         else:
00288             return (CONFIG_H_NOTOK, "'%s' does not mention '__GNUC__'" % fn)
00289 

Here is the call graph for this function:

Here is the caller graph for this function:

Try to find out the versions of gcc and ld.
    If not possible it returns None for it.

Definition at line 290 of file emxccompiler.py.

00290 
00291 def get_versions():
00292     """ Try to find out the versions of gcc and ld.
00293         If not possible it returns None for it.
00294     """
00295     from distutils.version import StrictVersion
00296     from distutils.spawn import find_executable
00297     import re
00298 
00299     gcc_exe = find_executable('gcc')
00300     if gcc_exe:
00301         out = os.popen(gcc_exe + ' -dumpversion','r')
00302         try:
00303             out_string = out.read()
00304         finally:
00305             out.close()
00306         result = re.search('(\d+\.\d+\.\d+)', out_string, re.ASCII)
00307         if result:
00308             gcc_version = StrictVersion(result.group(1))
00309         else:
00310             gcc_version = None
00311     else:
00312         gcc_version = None
00313     # EMX ld has no way of reporting version number, and we use GCC
00314     # anyway - so we can link OMF DLLs
00315     ld_version = None
00316     return (gcc_version, ld_version)

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 236 of file emxccompiler.py.

Definition at line 235 of file emxccompiler.py.

Definition at line 237 of file emxccompiler.py.