Back to index

python3.2  3.2.2
Classes | Functions
distutils.tests.support Namespace Reference

Classes

class  LoggingSilencer
class  TempdirManager
class  DummyCommand
class  EnvironGuard

Functions

def copy_xxmodule_c
def _get_xxmodule_path
def fixup_build_ext

Detailed Description

Support code for distutils test cases.

Function Documentation

Definition at line 158 of file support.py.

00158 
00159 def _get_xxmodule_path():
00160     srcdir = sysconfig.get_config_var('srcdir')
00161     candidates = [
00162         # use installed copy if available
00163         os.path.join(os.path.dirname(__file__), 'xxmodule.c'),
00164         # otherwise try using copy from build directory
00165         os.path.join(srcdir, 'Modules', 'xxmodule.c'),
00166         # srcdir mysteriously can be $srcdir/Lib/distutils/tests when
00167         # this file is run from its parent directory, so walk up the
00168         # tree to find the real srcdir
00169         os.path.join(srcdir, '..', '..', '..', 'Modules', 'xxmodule.c'),
00170     ]
00171     for path in candidates:
00172         if os.path.exists(path):
00173             return path
00174 

Here is the call graph for this function:

Here is the caller graph for this function:

Helper for tests that need the xxmodule.c source file.

Example use:

        def test_compile(self):
            copy_xxmodule_c(self.tmpdir)
            self.assertIn('xxmodule.c', os.listdir(self.tmpdir)

If the source file can be found, it will be copied to *directory*.  If not,
the test will be skipped.  Errors during copy are not caught.

Definition at line 139 of file support.py.

00139 
00140 def copy_xxmodule_c(directory):
00141     """Helper for tests that need the xxmodule.c source file.
00142 
00143     Example use:
00144 
00145             def test_compile(self):
00146                 copy_xxmodule_c(self.tmpdir)
00147                 self.assertIn('xxmodule.c', os.listdir(self.tmpdir)
00148 
00149     If the source file can be found, it will be copied to *directory*.  If not,
00150     the test will be skipped.  Errors during copy are not caught.
00151     """
00152     filename = _get_xxmodule_path()
00153     if filename is None:
00154         raise unittest.SkipTest('cannot find xxmodule.c (test must run in '
00155                                 'the python build dir)')
00156     shutil.copy(filename, directory)
00157 

Here is the call graph for this function:

Here is the caller graph for this function:

Function needed to make build_ext tests pass.

When Python was build with --enable-shared on Unix, -L. is not good
enough to find the libpython<blah>.so.  This is because regrtest runs
it under a tempdir, not in the top level where the .so lives.  By the
time we've gotten here, Python's already been chdir'd to the tempdir.

When Python was built with in debug mode on Windows, build_ext commands
need their debug attribute set, and it is not done automatically for
some reason.

This function handles both of these things.  Example use:

    cmd = build_ext(dist)
    support.fixup_build_ext(cmd)
    cmd.ensure_finalized()

Definition at line 175 of file support.py.

00175 
00176 def fixup_build_ext(cmd):
00177     """Function needed to make build_ext tests pass.
00178 
00179     When Python was build with --enable-shared on Unix, -L. is not good
00180     enough to find the libpython<blah>.so.  This is because regrtest runs
00181     it under a tempdir, not in the top level where the .so lives.  By the
00182     time we've gotten here, Python's already been chdir'd to the tempdir.
00183 
00184     When Python was built with in debug mode on Windows, build_ext commands
00185     need their debug attribute set, and it is not done automatically for
00186     some reason.
00187 
00188     This function handles both of these things.  Example use:
00189 
00190         cmd = build_ext(dist)
00191         support.fixup_build_ext(cmd)
00192         cmd.ensure_finalized()
00193     """
00194     if os.name == 'nt':
00195         cmd.debug = sys.executable.endswith('_d.exe')
00196     elif sysconfig.get_config_var('Py_ENABLE_SHARED'):
00197         # To further add to the shared builds fun on Unix, we can't just add
00198         # library_dirs to the Extension() instance because that doesn't get
00199         # plumbed through to the final compiler command.
00200         runshared = sysconfig.get_config_var('RUNSHARED')
00201         if runshared is None:
00202             cmd.library_dirs = ['.']
00203         else:
00204             name, equals, value = runshared.partition('=')
00205             cmd.library_dirs = value.split(os.pathsep)

Here is the call graph for this function:

Here is the caller graph for this function: