build_tools/install_cexts.py
def parse_package_page(files, pk_version, index_url):  # noqa C901
    """
    Parse the PYPI and Piwheels link for the package and install the desired wheel files.
    """

    for file in files.find_all("a"):
        # We are not going to install the packages if they are:
        #   * not a whl file
        #   * not the version specified in requirements.txt
        #   * not python versions that kolibri supports
        #   * not macosx or win_x64 platforms,
        #     since the process of setup wizard has been fast enough

        file_name_chunks = file.string.split("-")

        # When the length of file_name_chunks is 2, it means the file is tar.gz.
        if len(file_name_chunks) == 2:
            continue

        package_version = file_name_chunks[1]
        package_name = file_name_chunks[0]
        python_version = file_name_chunks[2][2:]
        platform = file_name_chunks[4].split(".")[0]
        implementation = file_name_chunks[2][:2]
        abi = file_name_chunks[3]

        if package_version != pk_version:
            continue
        if python_version == "26":
            continue
        if "macosx" in platform:
            continue
        if "win_amd64" in platform and python_version != "34":
            continue

        print("Installing {}...".format(file.string))

        version_path = os.path.join(DIST_CEXT, file_name_chunks[2])
        package_path = get_path_with_arch(
            platform, version_path, abi, implementation, python_version
        )

        download_return = download_package(
            package_path,
            platform,
            python_version,
            implementation,
            abi,
            package_name,
            pk_version,
            index_url,
            file.string,
        )

        # Successfully download package
        if download_return == 0:
            install_package_by_wheel(package_path)
        # Download failed
        else:
            # see https://github.com/learningequality/kolibri/issues/4656
            print("\nDownload failed for package {}.\n".format(file.string))

            # We still need to have the program exit with error
            # if something wrong with PyPi download.
            if index_url == PYPI_DOWNLOAD:
                sys.exit(1)

    # Copy the packages in cp34 to cp35, cp36, cp37 due to abi3 tag.
    # https://cryptography.io/en/latest/faq/#why-are-there-no-wheels-for-python-3-5-on-linux-or-macos
    if index_url == PYPI_DOWNLOAD:
        abi3_src = os.path.join(DIST_CEXT, "cp34", "Linux")
        python_versions = ["cp35", "cp36", "cp37"]
        for version in python_versions:
            abi3_dst = os.path.join(DIST_CEXT, version, "Linux")
            shutil.copytree(abi3_src, abi3_dst)

    Parse the PYPI and Piwheels link for the package and install the desired wheel files.
    
Parse the PYPI and Piwheels link for the package and install the desired wheel files.
Parse the PYPI and Piwheels link for the package and install the desired wheel files .
def parse_package_page(files, pk_version, index_url):  
    for file in files.find_all("a"):
        file_name_chunks = file.string.split("-")
        if len(file_name_chunks) == 2:
            continue
        package_version = file_name_chunks[1]
        package_name = file_name_chunks[0]
        python_version = file_name_chunks[2][2:]
        platform = file_name_chunks[4].split(".")[0]
        implementation = file_name_chunks[2][:2]
        abi = file_name_chunks[3]
        if package_version != pk_version:
            continue
        if python_version == "26":
            continue
        if "macosx" in platform:
            continue
        if "win_amd64" in platform and python_version != "34":
            continue
        print("Installing {}...".format(file.string))
        version_path = os.path.join(DIST_CEXT, file_name_chunks[2])
        package_path = get_path_with_arch(
            platform, version_path, abi, implementation, python_version
        )
        download_return = download_package(
            package_path,
            platform,
            python_version,
            implementation,
            abi,
            package_name,
            pk_version,
            index_url,
            file.string,
        )
        if download_return == 0:
            install_package_by_wheel(package_path)
        else:
            print("\nDownload failed for package {}.\n".format(file.string))
            if index_url == PYPI_DOWNLOAD:
                sys.exit(1)
    if index_url == PYPI_DOWNLOAD:
        abi3_src = os.path.join(DIST_CEXT, "cp34", "Linux")
        python_versions = ["cp35", "cp36", "cp37"]
        for version in python_versions:
            abi3_dst = os.path.join(DIST_CEXT, version, "Linux")
            shutil.copytree(abi3_src, abi3_dst)
def parse_package_page ( files , pk_version , index_url ) : for file in files . find_all ( "a" ) : file_name_chunks = file . string . split ( "-" ) if len ( file_name_chunks ) == 2 : continue package_version = file_name_chunks [ 1 ] package_name = file_name_chunks [ 0 ] python_version = file_name_chunks [ 2 ] [ 2 : ] platform = file_name_chunks [ 4 ] . split ( "." ) [ 0 ] implementation = file_name_chunks [ 2 ] [ : 2 ] abi = file_name_chunks [ 3 ] if package_version != pk_version : continue if python_version == "26" : continue if "macosx" in platform : continue if "win_amd64" in platform and python_version != "34" : continue print ( "Installing {}..." . format ( file . string ) ) version_path = os . path . join ( DIST_CEXT , file_name_chunks [ 2 ] ) package_path = get_path_with_arch ( platform , version_path , abi , implementation , python_version ) download_return = download_package ( package_path , platform , python_version , implementation , abi , package_name , pk_version , index_url , file . string , ) if download_return == 0 : install_package_by_wheel ( package_path ) else : print ( "\nDownload failed for package {}.\n" . format ( file . string ) ) if index_url == PYPI_DOWNLOAD : sys . exit ( 1 ) if index_url == PYPI_DOWNLOAD : abi3_src = os . path . join ( DIST_CEXT , "cp34" , "Linux" ) python_versions = [ "cp35" , "cp36" , "cp37" ] for version in python_versions : abi3_dst = os . path . join ( DIST_CEXT , version , "Linux" ) shutil . copytree ( abi3_src , abi3_dst )
Parse the PYPI and Piwheels link for the package and install the desired wheel files.
Parse the PYPI and Piwheels link for the package and install the desired wheel files .
# noqa C901 """
    Parse the PYPI and Piwheels link for the package and install the desired wheel files.
    """ # We are not going to install the packages if they are: #   * not a whl file #   * not the version specified in requirements.txt #   * not python versions that kolibri supports #   * not macosx or win_x64 platforms, #     since the process of setup wizard has been fast enough # When the length of file_name_chunks is 2, it means the file is tar.gz. # Successfully download package # Download failed # see https://github.com/learningequality/kolibri/issues/4656 # We still need to have the program exit with error # if something wrong with PyPi download. # Copy the packages in cp34 to cp35, cp36, cp37 due to abi3 tag. # https://cryptography.io/en/latest/faq/#why-are-there-no-wheels-for-python-3-5-on-linux-or-macos
files
pk_version
index_url