[Python-checkins] r46104 - python/trunk/Lib/distutils/sysconfig.py python/trunk/Lib/distutils/unixccompiler.py python/trunk/Lib/distutils/util.py

Neal Norwitz nnorwitz at gmail.com
Wed May 24 08:37:25 CEST 2006


On 5/23/06, ronald.oussoren <python-checkins at python.org> wrote:
> Author: ronald.oussoren
> Date: Tue May 23 14:01:11 2006
> New Revision: 46104
>
> Modified:
>    python/trunk/Lib/distutils/sysconfig.py
>    python/trunk/Lib/distutils/unixccompiler.py
>    python/trunk/Lib/distutils/util.py
> Log:
> Patch #1488098.
>
> This patchs makes it possible to create a universal build on OSX 10.4 and use
> the result to build extensions on 10.3. It also makes it possible to override
> the '-arch' and '-isysroot' compiler arguments for specific extensions.
>
>
> Modified: python/trunk/Lib/distutils/unixccompiler.py
> ==============================================================================
> --- python/trunk/Lib/distutils/unixccompiler.py (original)
> +++ python/trunk/Lib/distutils/unixccompiler.py Tue May 23 14:01:11 2006
> @@ -42,6 +42,48 @@
>  #     should just happily stuff them into the preprocessor/compiler/linker
>  #     options and carry on.
>
> +def _darwin_compiler_fixup(compiler_so, cc_args):
> +    """
> +    This function will strip '-isysroot PATH' and '-arch ARCH' from the
> +    compile flags if the user has specified one them in extra_compile_flags.
> +
> +    This is needed because '-arch ARCH' adds another architecture to the
> +    build, without a way to remove an architecture. Furthermore GCC will
> +    barf if multiple '-isysroot' arguments are present.
> +    """
> +    stripArch = stripSysroot = 0

This initialization can be removed.  The variables are set below.

> +
> +    compiler_so = list(compiler_so)
> +    kernel_version = os.uname()[2] # 8.4.3
> +    major_version = int(kernel_version.split('.')[0])
> +
> +    if major_version < 8:
> +        # OSX before 10.4.0, these don't support -arch and -isysroot at
> +        # all.
> +        stripArch = stripSysroot = True
> +    else:
> +        stripArch = '-arch' in cc_args
> +        stripSysroot = '-isysroot' in cc_args

They are set in both suites.

> +    if stripArch:
> +        while 1:
> +            try:
> +                index = compiler_so.index('-arch')
> +                # Strip this argument and the next one:
> +                del compiler_so[index:index+2]
> +            except ValueError:
> +                break
> +
> +    if stripSysroot:
> +        try:
> +            index = compiler_so.index('-isysroot')
> +            # Strip this argument and the next one:

Is the comment correct or should the code below be index+2?

> +            del compiler_so[index:index+1]
> +        except ValueError:
> +            pass
> +
> +    return compiler_so


More information about the Python-checkins mailing list