Back to index

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

Classes

class  CygwinCCompiler
class  Mingw32CCompiler

Functions

def get_msvcr
def check_config_h
def _find_exe_version
def get_versions

Variables

string CONFIG_H_OK = "ok"
string CONFIG_H_NOTOK = "not ok"
string CONFIG_H_UNCERTAIN = "uncertain"
tuple RE_VERSION = re.compile(b'(\d+\.\d+(\.\d+)*)')

Detailed Description

distutils.cygwinccompiler

Provides the CygwinCCompiler class, a subclass of UnixCCompiler that
handles the Cygwin port of the GNU C compiler to Windows.  It also contains
the Mingw32CCompiler class which handles the mingw32 port of GCC (same as
cygwin in no-cygwin mode).

Function Documentation

Find the version of an executable by running `cmd` in the shell.

If the command is not found, or the output does not match
`RE_VERSION`, returns None.

Definition at line 365 of file cygwinccompiler.py.

00365 
00366 def _find_exe_version(cmd):
00367     """Find the version of an executable by running `cmd` in the shell.
00368 
00369     If the command is not found, or the output does not match
00370     `RE_VERSION`, returns None.
00371     """
00372     executable = cmd.split()[0]
00373     if find_executable(executable) is None:
00374         return None
00375     out = Popen(cmd, shell=True, stdout=PIPE).stdout
00376     try:
00377         out_string = out.read()
00378     finally:
00379         out.close()
00380     result = RE_VERSION.search(out_string)
00381     if result is None:
00382         return None
00383     # LooseVersion works with strings
00384     # so we need to decode our bytes
00385     return LooseVersion(result.group(1).decode())

Here is the call graph for this function:

Here is the caller graph for this function:

Check if the current Python installation 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 320 of file cygwinccompiler.py.

00320 
00321 def check_config_h():
00322     """Check if the current Python installation appears amenable to building
00323     extensions with GCC.
00324 
00325     Returns a tuple (status, details), where 'status' is one of the following
00326     constants:
00327 
00328     - CONFIG_H_OK: all is well, go ahead and compile
00329     - CONFIG_H_NOTOK: doesn't look good
00330     - CONFIG_H_UNCERTAIN: not sure -- unable to read pyconfig.h
00331 
00332     'details' is a human-readable string explaining the situation.
00333 
00334     Note there are two ways to conclude "OK": either 'sys.version' contains
00335     the string "GCC" (implying that this Python was built with GCC), or the
00336     installed "pyconfig.h" contains the string "__GNUC__".
00337     """
00338 
00339     # XXX since this function also checks sys.version, it's not strictly a
00340     # "pyconfig.h" check -- should probably be renamed...
00341 
00342     from distutils import sysconfig
00343 
00344     # if sys.version contains GCC then python was compiled with GCC, and the
00345     # pyconfig.h file should be OK
00346     if "GCC" in sys.version:
00347         return CONFIG_H_OK, "sys.version mentions 'GCC'"
00348 
00349     # let's see if __GNUC__ is mentioned in python.h
00350     fn = sysconfig.get_config_h_filename()
00351     try:
00352         config_h = open(fn)
00353         try:
00354             if "__GNUC__" in config_h.read():
00355                 return CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn
00356             else:
00357                 return CONFIG_H_NOTOK, "'%s' does not mention '__GNUC__'" % fn
00358         finally:
00359             config_h.close()
00360     except IOError as exc:
00361         return (CONFIG_H_UNCERTAIN,
00362                 "couldn't read '%s': %s" % (fn, exc.strerror))

Here is the call graph for this function:

Here is the caller graph for this function:

Include the appropriate MSVC runtime library if Python was built
with MSVC 7.0 or later.

Definition at line 62 of file cygwinccompiler.py.

00062 
00063 def get_msvcr():
00064     """Include the appropriate MSVC runtime library if Python was built
00065     with MSVC 7.0 or later.
00066     """
00067     msc_pos = sys.version.find('MSC v.')
00068     if msc_pos != -1:
00069         msc_ver = sys.version[msc_pos+6:msc_pos+10]
00070         if msc_ver == '1300':
00071             # MSVC 7.0
00072             return ['msvcr70']
00073         elif msc_ver == '1310':
00074             # MSVC 7.1
00075             return ['msvcr71']
00076         elif msc_ver == '1400':
00077             # VS2005 / MSVC 8.0
00078             return ['msvcr80']
00079         elif msc_ver == '1500':
00080             # VS2008 / MSVC 9.0
00081             return ['msvcr90']
00082         else:
00083             raise ValueError("Unknown MS Compiler version %s " % msc_ver)
00084 

Here is the caller graph for this function:

Try to find out the versions of gcc, ld and dllwrap.

If not possible it returns None for it.

Definition at line 386 of file cygwinccompiler.py.

00386 
00387 def get_versions():
00388     """ Try to find out the versions of gcc, ld and dllwrap.
00389 
00390     If not possible it returns None for it.
00391     """
00392     commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version']
00393     return tuple([_find_exe_version(cmd) for cmd in commands])

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 317 of file cygwinccompiler.py.

Definition at line 316 of file cygwinccompiler.py.

Definition at line 318 of file cygwinccompiler.py.

tuple distutils.cygwinccompiler.RE_VERSION = re.compile(b'(\d+\.\d+(\.\d+)*)')

Definition at line 363 of file cygwinccompiler.py.