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 amaury.forgeotdarc
Recipients amaury.forgeotdarc, christian.heimes, theller
Date 2008-01-15.12:42:03
SpamBayes Score 0.038003366
Marked as misclassified No
Message-id <1200400928.25.0.569411323032.issue1793@psf.upfronthosting.co.za>
In-reply-to
Content
I found the code I wrote some time ago for the same purpose:
(in pypy, which uses ctypes a lot)

import sys
if sys.platform == 'win32':
    # Parses sys.version and deduces the version of the compiler
    import distutils.msvccompiler
    version = distutils.msvccompiler.get_build_version()
    if version is None:
        # This logic works with official builds of Python.
        if sys.version_info < (2, 4):
            clibname = 'msvcrt'
        else:
            clibname = 'msvcr71'
    else:
        if version <= 6:
            clibname = 'msvcrt'
        else:
            clibname = 'msvcr%d' % (version * 10)

    # If python was built with in debug mode
    import imp
    if imp.get_suffixes()[0][0] == '_d.pyd':
        clibname += 'd'

    standard_c_lib = ctypes.cdll.LoadLibrary(clibname+'.dll')

This code works on all pythons I have on my machine: official builds,
custom builds (relase/debug) with several MS compilers...
I did not test it with other compiled vendors (mingw32...).

But to me this seems more robust than a text search in the executable.
History
Date User Action Args
2008-01-15 12:42:08amaury.forgeotdarcsetspambayes_score: 0.0380034 -> 0.038003366
recipients: + amaury.forgeotdarc, theller, christian.heimes
2008-01-15 12:42:08amaury.forgeotdarcsetspambayes_score: 0.0380034 -> 0.0380034
messageid: <1200400928.25.0.569411323032.issue1793@psf.upfronthosting.co.za>
2008-01-15 12:42:04amaury.forgeotdarclinkissue1793 messages
2008-01-15 12:42:03amaury.forgeotdarccreate