This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sbt
Recipients chris.jerdonek, eric.araujo, fdrake, ned.deily, ronaldoussoren, sbt, tarek
Date 2012-07-17.23:13:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1342566824.06.0.953561917143.issue15364@psf.upfronthosting.co.za>
In-reply-to
Content
> Beyond that, I don't understand why the patch behavior depends on 
> whether the srcdir is an absolute path or not.

The os.path.isabs() test is actually redundant since os.path.join(base, srcdir) == srcdir if srcdir is an absolute path.  I only added that test to be explicit about what happens if the original value is an absolute path. 

> I often use absolute paths to configure a build.  If not in a build 
> directory, 'srcdir' should always return either the proposed value 
> based on what get_makefile_filename() returns or it should return 
> None.

Removing the isabs() test would not change the calculated value as I indicated above.

Using None would be the sanest option, but I don't know if any current code depends on the value being a string.

> One other point: distutils still has its own copy of sysconfig.  
> Strong consideration should be given to making a similar change there.

For a source build, distutils.sysconfig.get_config_var('srcdir') gives the right answer as an absolute path, *except* when the current working directory contains sys.executable.  I think it should always return an absolute path.  The fact that currently it does not probably explains the "mysteriously" comment below from distutils/test/support.py:

def _get_xxmodule_path():
    srcdir = sysconfig.get_config_var('srcdir')
    candidates = [
        # use installed copy if available
        os.path.join(os.path.dirname(__file__), 'xxmodule.c'),
        # otherwise try using copy from build directory
        os.path.join(srcdir, 'Modules', 'xxmodule.c'),
        # srcdir mysteriously can be $srcdir/Lib/distutils/tests when
        # this file is run from its parent directory, so walk up the
        # tree to find the real srcdir
        os.path.join(srcdir, '..', '..', '..', 'Modules', 'xxmodule.c'),
    ]
    for path in candidates:
        if os.path.exists(path):
            return path

BTW, I was wrong in my earlier message when I claimed that srcdir == get_path('stdlib') for an installed python.  That is only true if the relative srcdir is '..'.  The attached patch removes that check from the unit tests.
History
Date User Action Args
2012-07-17 23:13:44sbtsetrecipients: + sbt, fdrake, ronaldoussoren, tarek, ned.deily, eric.araujo, chris.jerdonek
2012-07-17 23:13:44sbtsetmessageid: <1342566824.06.0.953561917143.issue15364@psf.upfronthosting.co.za>
2012-07-17 23:13:43sbtlinkissue15364 messages
2012-07-17 23:13:42sbtcreate