예제 #1
0
def create_config(module, template, macros):
    """Create the SIP configuration module so that it can be imported by build
    scripts.

    module is the module file name.
    template is the template file name.
    macros is the dictionary of build macros.
    """
    siputils.inform("Creating %s..." % module)

    content = {
        "sip_config_args": sys.argv[1:],
        "sip_version": sip_version,
        "sip_version_str": sip_version_str,
        "platform": build_platform,
        "sip_bin": os.path.join(sip_bin_dir, "sip"),
        "sip_inc_dir": sip_inc_dir,
        "sip_mod_dir": sip_module_dir,
        "default_bin_dir": plat_bin_dir,
        "default_mod_dir": plat_py_site_dir,
        "default_sip_dir": sip_sip_dir,
        "py_version": py_version,
        "py_inc_dir": plat_py_inc_dir,
        "py_conf_inc_dir": plat_py_conf_inc_dir,
        "py_lib_dir": plat_py_lib_dir,
        "universal": opts.universal,
        "arch": opts.arch,
        "deployment_target": opts.deployment_target,
        "qt_framework": 0
    }

    siputils.create_config_module(module, template, content, macros)
예제 #2
0
파일: configure.py 프로젝트: h4ck3rm1k3/sip
def create_config(module, template, macros):
    """Create the SIP configuration module so that it can be imported by build
    scripts.

    module is the module file name.
    template is the template file name.
    macros is the dictionary of build macros.
    """
    siputils.inform("Creating %s..." % module)

    content = {
        "sip_config_args":  sys.argv[1:],
        "sip_version":      sip_version,
        "sip_version_str":  sip_version_str,
        "platform":         opts.platform,
        "sip_bin":          os.path.join(opts.sipbindir, "sip"),
        "sip_inc_dir":      opts.sipincdir,
        "sip_mod_dir":      opts.sipmoddir,
        "default_bin_dir":  plat_bin_dir,
        "default_mod_dir":  plat_py_site_dir,
        "default_sip_dir":  opts.sipsipdir,
        "py_version":       py_version,
        "py_inc_dir":       plat_py_inc_dir,
        "py_conf_inc_dir":  plat_py_conf_inc_dir,
        "py_lib_dir":       plat_py_lib_dir,
        "universal":        opts.universal
    }

    siputils.create_config_module(module, template, content, macros)
예제 #3
0
def patch_files():
    """Patch any files that need it."""

    patched = (("siplib", "sip.h"), ("siplib", "siplib.c"), ("siplib",
                                                             "siplib.sbf"))

    # The siplib directory may not exist if we are building away from the
    # source directory.
    try:
        os.mkdir("siplib")
    except OSError:
        pass

    for f in patched:
        dst_fn = os.path.join(*f)
        src_fn = os.path.join(src_dir, dst_fn + ".in")

        siputils.inform("Creating %s..." % dst_fn)

        dst = open(dst_fn, "w")
        src = open(src_fn)

        for line in src:
            line = line.replace("@CFG_MODULE_NAME@", opts.sip_module)
            line = line.replace("@CFG_MODULE_BASENAME@", sip_module_base)

            dst.write(line)

        dst.close()
        src.close()
예제 #4
0
파일: configure.py 프로젝트: Kanma/sip
def patch_files():
    """Patch any files that need it."""

    patched = (
        ("siplib", "sip.h"),
        ("siplib", "siplib.c"),
        ("siplib", "siplib.sbf")
    )

    for f in patched:
        dst_fn = os.path.join(*f)
        src_fn = os.path.join(src_dir, dst_fn + ".in")

        siputils.inform("Creating %s..." % dst_fn)

        dst = open(dst_fn, "w")
        src = open(src_fn)

        for line in src:
            line = line.replace("@CFG_MODULE_NAME@", opts.sip_module)
            line = line.replace("@CFG_MODULE_BASENAME@", sip_module_base)

            dst.write(line)

        dst.close()
        src.close()
예제 #5
0
def patch_files():
    """Patch any files that need it."""

    patched = (
        ("siplib", "sip.h"),
        ("siplib", "siplib.c"),
        ("siplib", "siplib.sbf")
    )

    # The siplib directory may not exist if we are building away from the
    # source directory.
    try:
        os.mkdir("siplib")
    except OSError:
        pass

    for f in patched:
        dst_fn = os.path.join(*f)
        src_fn = os.path.join(src_dir, dst_fn + ".in")

        siputils.inform("Creating %s..." % dst_fn)

        dst = open(dst_fn, "w")
        src = open(src_fn)

        for line in src:
            line = line.replace("@CFG_MODULE_NAME@", opts.sip_module)
            line = line.replace("@CFG_MODULE_BASENAME@", sip_module_base)

            dst.write(line)

        dst.close()
        src.close()
예제 #6
0
def main(argv):
    """Create the configuration module module.

    argv is the list of command line arguments.
    """
    siputils.inform("This is SIP %s for Python %s on %s." %
                    (sip_version_str, sys.version.split()[0], sys.platform))

    global py_version, build_platform

    if py_version < 0x020300:
        siputils.error("This version of SIP requires Python v2.3 or later.")

    # Basic initialisation.
    set_platform_directories()
    set_build_platform()

    # Build up the list of valid specs.
    for s in os.listdir(os.path.join(src_dir, "specs")):
        platform_specs.append(s)

    # Determine the directory containing the default OS/X SDK.
    if sys.platform == 'darwin':
        for sdk_dir in MACOSX_SDK_DIRS:
            if os.path.isdir(sdk_dir):
                break
        else:
            sdk_dir = MACOSX_SDK_DIRS[0]
    else:
        sdk_dir = ''

    # Parse the command line.
    global opts

    p = create_optparser(sdk_dir)
    opts, args = p.parse_args()

    # Override defaults that affect subsequent configuration.
    if opts.target_py_version is not None:
        py_version = opts.target_py_version

    if opts.sysroot is not None:
        global sysroot
        sysroot = opts.sysroot

    # Make sure MacOS specific options get initialised.
    if sys.platform != 'darwin':
        opts.universal = ''
        opts.arch = []
        opts.sdk = ''
        opts.deployment_target = ''

    # Handle the query options.
    if opts.show_platforms or opts.show_build_macros:
        if opts.show_platforms:
            show_platforms()

        if opts.show_build_macros:
            show_macros()

        sys.exit()

    # Convert the list 'arch' option to a string.  Multiple architectures
    # imply a universal binary.
    if len(opts.arch) > 1:
        opts.universal = True

    opts.arch = ' '.join(opts.arch)

    # Convert the boolean 'universal' option to a string.
    if opts.universal:
        if '/' in opts.sdk:
            opts.universal = os.path.abspath(opts.sdk)
        else:
            opts.universal = sdk_dir + '/' + opts.sdk

        if not os.path.isdir(opts.universal):
            siputils.error(
                "Unable to find the SDK directory %s. Use the --sdk flag to specify the name of the SDK or its full path."
                % opts.universal)

        if opts.arch == '':
            opts.arch = DEFAULT_MACOSX_ARCH
    else:
        opts.universal = ''

    # Apply the overrides from any configuration file.
    global plat_bin_dir, plat_py_conf_inc_dir, plat_py_inc_dir
    global plat_py_lib_dir, plat_py_site_dir, plat_sip_dir
    global sip_bin_dir, sip_inc_dir, sip_module_dir, sip_sip_dir

    # Set defaults.
    sip_bin_dir = plat_bin_dir
    sip_inc_dir = plat_py_inc_dir
    sip_module_dir = plat_py_site_dir
    sip_sip_dir = plat_sip_dir

    if opts.config_file is not None:
        update_from_configuration_file(opts.config_file)
    elif sysroot != '':

        def apply_sysroot(d):
            if d.startswith(sys.prefix):
                d = sysroot + d[len(sys.prefix):]

            return d

        plat_bin_dir = apply_sysroot(plat_bin_dir)
        plat_py_conf_inc_dir = apply_sysroot(plat_py_conf_inc_dir)
        plat_py_inc_dir = apply_sysroot(plat_py_inc_dir)
        plat_py_lib_dir = apply_sysroot(plat_py_lib_dir)
        plat_py_site_dir = apply_sysroot(plat_py_site_dir)
        plat_sip_dir = apply_sysroot(plat_sip_dir)

        sip_bin_dir = apply_sysroot(sip_bin_dir)
        sip_inc_dir = apply_sysroot(sip_inc_dir)
        sip_module_dir = apply_sysroot(sip_module_dir)
        sip_sip_dir = apply_sysroot(sip_sip_dir)

    # Override from the command line.
    if opts.platform is not None:
        build_platform = opts.platform

    if opts.sipbindir is not None:
        sip_bin_dir = opts.sipbindir

    if opts.sipincdir is not None:
        sip_inc_dir = opts.sipincdir

    if opts.sipmoddir is not None:
        sip_module_dir = opts.sipmoddir

    if opts.sipsipdir is not None:
        sip_sip_dir = opts.sipsipdir

    # Get the platform specific macros for building.
    macros = siputils.parse_build_macros(
        os.path.join(src_dir, "specs", build_platform), build_macro_names,
        args)

    if macros is None:
        siputils.error(
            "Unsupported macro name specified. Use the --show-build-macros flag to see a list of supported macros."
        )
        sys.exit(2)

    # Fix the name of the sip module.
    global sip_module_base

    module_path = opts.sip_module.split(".")
    sip_module_base = module_path[-1]

    if len(module_path) > 1:
        del module_path[-1]
        module_path.insert(0, sip_module_dir)
        sip_module_dir = os.path.join(*module_path)

    # Tell the user what's been found.
    inform_user()

    # Patch any files that need it.
    patch_files()

    # Install the configuration module.
    create_config("sipconfig.py", os.path.join(src_dir, "siputils.py"), macros)

    # Create the Makefiles.
    create_makefiles(macros)
예제 #7
0
def update_from_configuration_file(config_file):
    """ Update a number of globals from values read from a configuration file.
    """

    siputils.inform("Reading configuration from %s..." % config_file)

    config = {}

    # Read the file into the dict.
    cfg = open(config_file)
    line_nr = 0

    for l in cfg:
        line_nr += 1

        # Strip comments and blank lines.
        l = l.split('#')[0].strip()
        if l == '':
            continue

        parts = l.split('=', 1)
        if len(parts) == 2:
            name = parts[0].strip()
            value = parts[1].strip()
        else:
            name = value = ''

        if name == '' or value == '':
            siputils.error("%s:%d: Invalid line." % (config_file, line_nr))

        config[name] = value
        last_name = name

    cfg.close()

    # Enforce the presets.
    version = siputils.version_to_string(py_version).split('.')
    config['py_major'] = version[0]
    config['py_minor'] = version[1]
    config['sysroot'] = sysroot

    # Override the relevent values.
    global py_platform, plat_py_conf_inc_dir, plat_py_inc_dir, plat_py_lib_dir
    global sip_bin_dir, sip_inc_dir, sip_module_dir, sip_sip_dir

    py_platform = _get_configuration_value(config, 'py_platform', py_platform)
    plat_py_inc_dir = _get_configuration_value(config, 'py_inc_dir',
                                               plat_py_inc_dir)
    plat_py_lib_dir = _get_configuration_value(config, 'py_pylib_dir',
                                               plat_py_lib_dir)

    # The pyconfig.h directory defaults to the Python.h directory.
    plat_py_conf_inc_dir = _get_configuration_value(config, 'py_conf_inc_dir',
                                                    plat_py_inc_dir)

    sip_bin_dir = _get_configuration_value(config, 'sip_bin_dir', sip_bin_dir)
    sip_module_dir = _get_configuration_value(config, 'sip_module_dir',
                                              sip_module_dir)

    # Note that this defaults to any 'py_inc_dir' specified in the
    # configuration file.
    sip_inc_dir = _get_configuration_value(config, 'sip_inc_dir',
                                           plat_py_inc_dir)

    # Note that this is only used when creating sipconfig.py.
    sip_sip_dir = _get_configuration_value(config, 'sip_sip_dir', sip_sip_dir)
예제 #8
0
def inform_user():
    """ Tell the user the option values that are going to be used. """

    if not opts.no_tools:
        siputils.inform("The SIP code generator will be installed in %s." %
                        sip_bin_dir)

    siputils.inform("The %s module will be installed in %s." %
                    (sip_module_base, sip_module_dir))

    if opts.static:
        siputils.inform("The %s module will be built as a static library." %
                        sip_module_base)

    siputils.inform("The sip.h header file will be installed in %s." %
                    sip_inc_dir)
    siputils.inform("The default directory to install .sip files in is %s." %
                    sip_sip_dir)

    if opts.use_qmake is None:
        siputils.inform("The platform/compiler configuration is %s." %
                        build_platform)

    if opts.arch:
        siputils.inform("MacOS/X binaries will be created for %s." %
                        (", ".join(opts.arch.split())))

    if opts.universal:
        siputils.inform(
            "MacOS/X universal binaries will be created using %s." %
            opts.universal)

    if opts.deployment_target:
        siputils.inform("MacOS/X deployment target is %s." %
                        opts.deployment_target)
예제 #9
0
def main(argv):
    """Create the configuration module module.

    argv is the list of command line arguments.
    """
    siputils.inform("This is SIP %s for Python %s on %s." % (sip_version_str, sys.version.split()[0], sys.platform))

    if py_version < 0x020300:
        siputils.error("This version of SIP requires Python v2.3 or later.")

    # Basic initialisation.
    set_platform_directories()

    # Build up the list of valid specs.
    for s in os.listdir("specs"):
        platform_specs.append(s)

    # Parse the command line.
    global opts

    set_defaults()
    p = create_optparser()
    print argv
    opts, args = p.parse_args(argv[1:])

    # Handle the query options.
    if opts.show_platforms or opts.show_build_macros:
        if opts.show_platforms:
            show_platforms()

        if opts.show_build_macros:
            show_macros()

        sys.exit()

    # Convert the boolean 'universal' option to a string.
    if opts.universal:
        if '/' in opts.sdk:
            opts.universal = os.path.abspath(opts.sdk)
        else:
            opts.universal = '/Developer/SDKs/' + opts.sdk

        if not os.path.isdir(opts.universal):
            siputils.error("Unable to find the SDK directory %s. Use the -s flag to specify the name of the SDK (e.g. %s) or its full path." % (opts.universal, DEFAULT_MACOSX_SDK))
    else:
        opts.universal = ''

    # Get the platform specific macros for building.
    macros = siputils.parse_build_macros(os.path.join("specs", opts.platform),
            build_macro_names, args)

    if macros is None:
        p.print_help()
        sys.exit(2)

    # Tell the user what's been found.
    inform_user()

    # Install the configuration module.
    create_config("sipconfig.py", "siputils.py", macros)

    # Create the Makefiles.
    create_makefiles(macros)
예제 #10
0
def inform_user():
    """Tell the user the option values that are going to be used.
    """
    siputils.inform("The SIP code generator will be installed in %s." % opts.sipbindir)
    siputils.inform("The SIP module will be installed in %s." % opts.sipmoddir)
    siputils.inform("The SIP header file will be installed in %s." % opts.sipincdir)
    siputils.inform("The default directory to install .sip files in is %s." % opts.sipsipdir)
    siputils.inform("The platform/compiler configuration is %s." % opts.platform)

    if opts.universal:
        siputils.inform("MacOS/X universal binaries will be created using %s." % opts.universal)
예제 #11
0
def main(argv):
    """Create the configuration module module.

    argv is the list of command line arguments.
    """
    siputils.inform("This is SIP %s for Python %s on %s." % (sip_version_str, sys.version.split()[0], sys.platform))

    if py_version < 0x020300:
        siputils.error("This version of SIP requires Python v2.3 or later.")

    # Basic initialisation.
    set_platform_directories()

    # Build up the list of valid specs.
    for s in os.listdir(os.path.join(src_dir, "specs")):
        platform_specs.append(s)

    # Parse the command line.
    global opts

    set_defaults()
    p = create_optparser()
    opts, args = p.parse_args()

    # Make sure MacOS specific options get initialised.
    if sys.platform != 'darwin':
        opts.universal = ''
        opts.arch = []
        opts.sdk = ''

    # Handle the query options.
    if opts.show_platforms or opts.show_build_macros:
        if opts.show_platforms:
            show_platforms()

        if opts.show_build_macros:
            show_macros()

        sys.exit()

    # Convert the list 'arch' option to a string.  Multiple architectures
    # imply a universal binary.
    if len(opts.arch) > 1:
        opts.universal = True

    opts.arch = ' '.join(opts.arch)

    # Convert the boolean 'universal' option to a string.
    if opts.universal:
        if '/' in opts.sdk:
            opts.universal = os.path.abspath(opts.sdk)
        else:
            opts.universal = MACOSX_SDK_DIR + '/' + opts.sdk

        if not os.path.isdir(opts.universal):
            siputils.error("Unable to find the SDK directory %s. Use the --sdk flag to specify the name of the SDK or its full path." % opts.universal)

        if opts.arch == '':
            opts.arch = DEFAULT_MACOSX_ARCH
    else:
        opts.universal = ''

    # Get the platform specific macros for building.
    macros = siputils.parse_build_macros(
            os.path.join(src_dir, "specs", opts.platform), build_macro_names,
            args)

    if macros is None:
        p.print_help()
        sys.exit(2)

    # Tell the user what's been found.
    inform_user()

    # Install the configuration module.
    create_config("sipconfig.py", os.path.join(src_dir, "siputils.py"),
            macros)

    # Create the Makefiles.
    create_makefiles(macros)
예제 #12
0
def inform_user():
    """Tell the user the option values that are going to be used.
    """
    siputils.inform("The SIP code generator will be installed in %s." % opts.sipbindir)
    siputils.inform("The %s module will be installed in %s." % (sip_module_base, opts.sipmoddir))
    siputils.inform("The sip.h header file will be installed in %s." % opts.sipincdir)
    siputils.inform("The default directory to install .sip files in is %s." % opts.sipsipdir)
    siputils.inform("The platform/compiler configuration is %s." % opts.platform)

    if opts.arch:
        siputils.inform("MacOS/X binaries will be created for %s." % (", ".join(opts.arch.split())))

    if opts.universal:
        siputils.inform("MacOS/X universal binaries will be created using %s." % opts.universal)

    if opts.deployment_target:
        siputils.inform("MacOS/X deployment target is %s." % opts.deployment_target)
예제 #13
0
def main(argv):
    """Create the configuration module module.

    argv is the list of command line arguments.
    """
    siputils.inform("This is SIP %s for Python %s on %s." % (sip_version_str, sys.version.split()[0], sys.platform))

    if py_version < 0x020300:
        siputils.error("This version of SIP requires Python v2.3 or later.")

    # Basic initialisation.
    set_platform_directories()

    # Build up the list of valid specs.
    for s in os.listdir(os.path.join(src_dir, "specs")):
        platform_specs.append(s)

    # Parse the command line.
    global opts

    set_defaults()
    p = create_optparser()
    opts, args = p.parse_args()

    # Make sure MacOS specific options get initialised.
    if sys.platform != 'darwin':
        opts.universal = ''
        opts.arch = []
        opts.sdk = ''

    # Handle the query options.
    if opts.show_platforms or opts.show_build_macros:
        if opts.show_platforms:
            show_platforms()

        if opts.show_build_macros:
            show_macros()

        sys.exit()

    # Convert the list 'arch' option to a string.  Multiple architectures
    # imply a universal binary.
    if len(opts.arch) > 1:
        opts.universal = True

    opts.arch = ' '.join(opts.arch)

    # Convert the boolean 'universal' option to a string.
    if opts.universal:
        if '/' in opts.sdk:
            opts.universal = os.path.abspath(opts.sdk)
        else:
            opts.universal = MACOSX_SDK_DIR + '/' + opts.sdk

        if not os.path.isdir(opts.universal):
            siputils.error("Unable to find the SDK directory %s. Use the --sdk flag to specify the name of the SDK or its full path." % opts.universal)

        if opts.arch == '':
            opts.arch = DEFAULT_MACOSX_ARCH
    else:
        opts.universal = ''

    # Get the platform specific macros for building.
    macros = siputils.parse_build_macros(
            os.path.join(src_dir, "specs", opts.platform), build_macro_names,
            args)

    if macros is None:
        p.print_help()
        sys.exit(2)

    # Tell the user what's been found.
    inform_user()

    # Install the configuration module.
    create_config("sipconfig.py", os.path.join(src_dir, "siputils.py"),
            macros)

    # Create the Makefiles.
    create_makefiles(macros)
예제 #14
0
파일: configure.py 프로젝트: z80/lcu03
def main(argv):
    """Create the configuration module module.

    argv is the list of command line arguments.
    """
    siputils.inform("This is SIP %s for Python %s on %s." % (sip_version_str, sys.version.split()[0], sys.platform))

    global py_version, build_platform

    if py_version < 0x020300:
        siputils.error("This version of SIP requires Python v2.3 or later.")

    # Basic initialisation.
    set_platform_directories()
    set_build_platform()

    # Build up the list of valid specs.
    for s in os.listdir(os.path.join(src_dir, "specs")):
        platform_specs.append(s)

    # Determine the directory containing the default OS/X SDK.
    if sys.platform == "darwin":
        for sdk_dir in MACOSX_SDK_DIRS:
            if os.path.isdir(sdk_dir):
                break
        else:
            sdk_dir = MACOSX_SDK_DIRS[0]
    else:
        sdk_dir = ""

    # Parse the command line.
    global opts

    p = create_optparser(sdk_dir)
    opts, args = p.parse_args()

    # Override defaults that affect subsequent configuration.
    if opts.target_py_version is not None:
        py_version = opts.target_py_version

    if opts.sysroot is not None:
        global sysroot
        sysroot = opts.sysroot

    # Make sure MacOS specific options get initialised.
    if sys.platform != "darwin":
        opts.universal = ""
        opts.arch = []
        opts.sdk = ""
        opts.deployment_target = ""

    # Handle the query options.
    if opts.show_platforms or opts.show_build_macros:
        if opts.show_platforms:
            show_platforms()

        if opts.show_build_macros:
            show_macros()

        sys.exit()

    # Convert the list 'arch' option to a string.  Multiple architectures
    # imply a universal binary.
    if len(opts.arch) > 1:
        opts.universal = True

    opts.arch = " ".join(opts.arch)

    # Convert the boolean 'universal' option to a string.
    if opts.universal:
        if "/" in opts.sdk:
            opts.universal = os.path.abspath(opts.sdk)
        else:
            opts.universal = sdk_dir + "/" + opts.sdk

        if not os.path.isdir(opts.universal):
            siputils.error(
                "Unable to find the SDK directory %s. Use the --sdk flag to specify the name of the SDK or its full path."
                % opts.universal
            )

        if opts.arch == "":
            opts.arch = DEFAULT_MACOSX_ARCH
    else:
        opts.universal = ""

    # Apply the overrides from any configuration file.
    global plat_bin_dir, plat_py_conf_inc_dir, plat_py_inc_dir
    global plat_py_lib_dir, plat_py_site_dir, plat_sip_dir
    global sip_bin_dir, sip_inc_dir, sip_module_dir, sip_sip_dir

    # Set defaults.
    sip_bin_dir = plat_bin_dir
    sip_inc_dir = plat_py_venv_inc_dir
    sip_module_dir = plat_py_site_dir
    sip_sip_dir = plat_sip_dir

    if opts.config_file is not None:
        update_from_configuration_file(opts.config_file)
    elif sysroot != "":

        def apply_sysroot(d):
            if d.startswith(sys.prefix):
                d = sysroot + d[len(sys.prefix) :]

            return d

        plat_bin_dir = apply_sysroot(plat_bin_dir)
        plat_py_conf_inc_dir = apply_sysroot(plat_py_conf_inc_dir)
        plat_py_inc_dir = apply_sysroot(plat_py_inc_dir)
        plat_py_lib_dir = apply_sysroot(plat_py_lib_dir)
        plat_py_site_dir = apply_sysroot(plat_py_site_dir)
        plat_sip_dir = apply_sysroot(plat_sip_dir)

        sip_bin_dir = apply_sysroot(sip_bin_dir)
        sip_inc_dir = apply_sysroot(sip_inc_dir)
        sip_module_dir = apply_sysroot(sip_module_dir)
        sip_sip_dir = apply_sysroot(sip_sip_dir)

    # Override from the command line.
    if opts.platform is not None:
        build_platform = opts.platform

    if opts.sipbindir is not None:
        sip_bin_dir = opts.sipbindir

    if opts.sipincdir is not None:
        sip_inc_dir = opts.sipincdir

    if opts.sipmoddir is not None:
        sip_module_dir = opts.sipmoddir

    if opts.sipsipdir is not None:
        sip_sip_dir = opts.sipsipdir

    # Get the platform specific macros for building.
    macros = siputils.parse_build_macros(os.path.join(src_dir, "specs", build_platform), build_macro_names, args)

    if macros is None:
        siputils.error(
            "Unsupported macro name specified. Use the --show-build-macros flag to see a list of supported macros."
        )
        sys.exit(2)

    # Fix the name of the sip module.
    global sip_module_base

    module_path = opts.sip_module.split(".")
    sip_module_base = module_path[-1]

    if len(module_path) > 1:
        del module_path[-1]
        module_path.insert(0, sip_module_dir)
        sip_module_dir = os.path.join(*module_path)

    # Tell the user what's been found.
    inform_user()

    # Patch any files that need it.
    patch_files()

    # Install the configuration module.
    create_config("sipconfig.py", os.path.join(src_dir, "siputils.py"), macros)

    # Create the Makefiles.
    create_makefiles(macros)
예제 #15
0
파일: configure.py 프로젝트: z80/lcu03
def update_from_configuration_file(config_file):
    """ Update a number of globals from values read from a configuration file.
    """

    siputils.inform("Reading configuration from %s..." % config_file)

    config = {}

    # Read the file into the dict.
    cfg = open(config_file)
    line_nr = 0

    for l in cfg:
        line_nr += 1

        # Strip comments and blank lines.
        l = l.split("#")[0].strip()
        if l == "":
            continue

        parts = l.split("=", 1)
        if len(parts) == 2:
            name = parts[0].strip()
            value = parts[1].strip()
        else:
            name = value = ""

        if name == "" or value == "":
            siputils.error("%s:%d: Invalid line." % (config_file, line_nr))

        config[name] = value
        last_name = name

    cfg.close()

    # Enforce the presets.
    version = siputils.version_to_string(py_version).split(".")
    config["py_major"] = version[0]
    config["py_minor"] = version[1]
    config["sysroot"] = sysroot

    # Override the relevent values.
    global py_platform, plat_py_conf_inc_dir, plat_py_inc_dir, plat_py_lib_dir
    global sip_bin_dir, sip_inc_dir, sip_module_dir, sip_sip_dir

    py_platform = _get_configuration_value(config, "py_platform", py_platform)
    plat_py_inc_dir = _get_configuration_value(config, "py_inc_dir", plat_py_inc_dir)
    plat_py_lib_dir = _get_configuration_value(config, "py_pylib_dir", plat_py_lib_dir)

    # The pyconfig.h directory defaults to the Python.h directory.
    plat_py_conf_inc_dir = _get_configuration_value(config, "py_conf_inc_dir", plat_py_inc_dir)

    sip_bin_dir = _get_configuration_value(config, "sip_bin_dir", sip_bin_dir)
    sip_module_dir = _get_configuration_value(config, "sip_module_dir", sip_module_dir)

    # Note that this defaults to any 'py_inc_dir' specified in the
    # configuration file.
    sip_inc_dir = _get_configuration_value(config, "sip_inc_dir", plat_py_inc_dir)

    # Note that this is only used when creating sipconfig.py.
    sip_sip_dir = _get_configuration_value(config, "sip_sip_dir", sip_sip_dir)
예제 #16
0
파일: configure.py 프로젝트: z80/lcu03
def inform_user():
    """ Tell the user the option values that are going to be used. """

    if not opts.no_tools:
        siputils.inform("The SIP code generator will be installed in %s." % sip_bin_dir)

    siputils.inform("The %s module will be installed in %s." % (sip_module_base, sip_module_dir))

    if opts.static:
        siputils.inform("The %s module will be built as a static library." % sip_module_base)

    siputils.inform("The sip.h header file will be installed in %s." % sip_inc_dir)
    siputils.inform("The default directory to install .sip files in is %s." % sip_sip_dir)

    if opts.use_qmake is None:
        siputils.inform("The platform/compiler configuration is %s." % build_platform)

    if opts.arch:
        siputils.inform("MacOS/X binaries will be created for %s." % (", ".join(opts.arch.split())))

    if opts.universal:
        siputils.inform("MacOS/X universal binaries will be created using %s." % opts.universal)

    if opts.deployment_target:
        siputils.inform("MacOS/X deployment target is %s." % opts.deployment_target)