コード例 #1
0
def main():
    """Main"""
    usage = "usage: %prog [options] [/path/to/framework/destination]"
    parser = optparse.OptionParser(usage=usage)
    parser.add_option(
        "--destination",
        default=".",
        help="Directory destination for the Python.framework",
    )
    parser.add_option(
        "--baseurl",
        default=get.DEFAULT_BASEURL,
        help="Override the base URL used to download the framework.",
    )
    parser.add_option(
        "--os-version",
        default=get.DEFAULT_OS_VERSION,
        help="Override the macOS version of the downloaded pkg. "
        'Current supported versions are "10.6" and "10.9". '
        "Not all Python version and macOS version combinations are valid.",
    )
    parser.add_option(
        "--python-version",
        default=get.DEFAULT_PYTHON_VERSION,
        help="Override the version of the Python framework to be downloaded. "
        "See available versions at "
        "https://www.python.org/downloads/mac-osx/",
    )
    parser.add_option(
        "--pip-requirements",
        default=None,
        help="Path to a pip freeze requirements.txt file that describes extra "
        "Python modules to be installed. If not provided, certain useful "
        "modules for macOS will be installed.",
    )
    options, _arguments = parser.parse_args()

    framework_path = get.FrameworkGetter(
        python_version=options.python_version,
        os_version=options.os_version,
        base_url=options.baseurl,
    ).download_and_extract(destination=options.destination)

    if framework_path:
        relocatablize(framework_path)
        short_version = ".".join(options.python_version.split(".")[0:2])
        install_extras(
            framework_path,
            version=short_version,
            requirements_file=options.pip_requirements,
        )
        if fix_other_things(framework_path, short_version):
            print()
            print("Done!")
            print("Customized, relocatable framework is at %s" %
                  framework_path)
def main():
    """Main"""
    usage = "usage: %prog [options]"
    parser = optparse.OptionParser(usage=usage)
    parser.add_option(
        "--destination",
        default=".",
        help="Directory destination for the Python.framework",
    )
    parser.add_option(
        "--baseurl",
        default=get.DEFAULT_BASEURL,
        help="Override the base URL used to download the framework.",
    )
    parser.add_option(
        "--install-wheel",
        default=False,
        action="store_true",
        help="Install wheel prior to installing extra python modules.")
    parser.add_option(
        "--os-version",
        default=get.DEFAULT_OS_VERSION,
        help="Override the macOS version of the downloaded pkg. "
        'Current supported versions are "10.6" and "10.9". '
        "Not all Python version and macOS version combinations are valid.",
    )
    parser.add_option(
        "--python-version",
        default=get.DEFAULT_PYTHON_VERSION,
        help="Override the version of the Python framework to be downloaded. "
        "See available versions at "
        "https://www.python.org/downloads/mac-osx/",
    )
    parser.add_option(
        "--pip-requirements",
        default=None,
        help="Path to a pip freeze requirements.txt file that describes extra "
        "Python modules to be installed. If not provided, certain useful "
        "modules for macOS will be installed.",
    )
    parser.add_option(
        "--no-unsign",
        dest="unsign",
        action="store_false",
        help=
        "Do not unsign binaries and libraries after they are relocatablized.")
    parser.add_option(
        "--upgrade-pip",
        default=False,
        action="store_true",
        help="Upgrade pip prior to installing extra python modules.")
    parser.set_defaults(unsign=True)
    options, _arguments = parser.parse_args()

    framework_path = get.FrameworkGetter(
        python_version=options.python_version,
        os_version=options.os_version,
        base_url=options.baseurl,
    ).download_and_extract(destination=options.destination)

    if framework_path:
        files_relocatablized = relocatablize(framework_path)
        if options.unsign:
            fix_broken_signatures(files_relocatablized)
        short_version = ".".join(options.python_version.split(".")[0:2])
        install_extras(
            framework_path,
            version=short_version,
            requirements_file=options.pip_requirements,
            install_wheel=options.install_wheel,
            upgrade_pip=options.upgrade_pip,
        )
        if fix_other_things(framework_path, short_version):
            print()
            print("Done!")
            print("Customized, relocatable framework is at %s" %
                  framework_path)