ified" elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
           xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
           xmlns:t="http://schemas.microsoft.com/appx/manifest/types"
           xmlns:f="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
           xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
           xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
           xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
           xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
           xmlns:uap6="http://schemas.microsoft.com/appx/manifest/uap/windows10/6"
           xmlns:uap7="http://schemas.microsoft.com/appx/manifest/uap/windows10/7"
           xmlns:uap8="http://schemas.microsoft.com/appx/manifest/uap/windows10/8"
           xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
           xmlns:wincap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/windowscapabilities"
           xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
           xmlns:rescap6="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/6"
           xmlns:phone="http://schemas.microsoft.com/appx/2014/phone/manifest"
           xmlns:serverpreview="http://schemas.microsoft.com/appx/manifest/serverpreview/windows10"
           xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
           xmlns:iot2="http://schemas.microsoft.com/appx/manifest/iot/windows10/2"
           xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
           xmlns:com2="http://schemas.microsoft.com/appx/manifest/com/windows10/2"
           xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2"
           xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
           xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"
           >

  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/types"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/uap/windows10"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/2014/phone/manifest"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/uap/windows10/6"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/uap/windows10/7"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/uap/windows10/8"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/iot/windows10/2"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/6"/>
  
  <xs:element name="Package">
    <xs:complexType>
      <xs:all>
        <xs:element name="Identity" type="CT_Identity"/>
        <xs:element ref="phone:PhoneIdentity" minOccurs="0"/>
        <xs:element name="Properties" type="CT_Properties"/>
        <xs:element name="Resources" type="CT_Resources" minOccurs="0"/>
        <xs:element name="Dependencies" type="CT_Dependencies"/>
        <xs:element name="Capabilities" type="CT_Capabilities" minOccurs="0"/>
        <xs:element name="Extensions" type="CT_PackageExtensions" minOccurs="0"/>
        <xs:element name="Applications" type="CT_Applications" minOccurs="0"/>
        <xs:element ref="ComExtensions" minOccurs="0"/>
      </xs:all>
      <xs:attribute name="IgnorableNamespaces" type="t:ST_NonEmptyString" use="optional"/>
    </xs:complexType>
    <xs:unique name="Resource_Language">
      <xs:selector xpath="f:Resources/f:Resource"/>
      <xs:field xpath="@Language"/>
    </xs:unique>
    <xs:unique name="Resource_Scale">
      <xs:selector xpath="f:Resources/f:Resource"/>
      <xs:field xpath="@uap:Scale"/>
    </xs:unique>
    <xs:unique name="Resource_DXFeatureLevel">
      <xs:selector xpath="f:Resources/f:Resource"/>
      <xs:field xpath="@uap:DXFeatureLevel"/>
    </xs:unique>
    <xs:unique name="Application_Id">
      <xs:selector xpath="f:Applications/f:Application"/>
      <xs:field xpath="@Id"/>
    </xs:unique>
    <xs:unique name="Capability_Name">
      <xs:selector xpath="f:Capabilities/f:Capability | f:Capabilities/uap:Capability | f:Capabilities/wincap:Capability | f:Capabilities/rescap:Capability"/>
      <xs:field xpath="@Name"/>
    </xs:unique>
    <xs:unique name="DeviceCapability_Name">
      <xs:selector xpath="f:Capabilities/f:DeviceCapability"/>
      <xs:field xpath="@Name"/>
    </xs:unique>
    <xs:unique name="CustomCapability_Name">
      <xs:selector xpath="f:Capabilities/uap4:CustomCapability"/>
      <xs:field xpath="@Name"/>
    </xs:unique>
    <xs:unique name="Extension_FileType_Name">
      <xs:selector xpath="f:Applications/f:Application/f:Extensions/uap:Extension/uap:FileTypeAssociation"/>
      <xs:field xpath="@Name"/>
    </xs:unique>
    <xs:unique name="Extension_FileType">
      <xs:selector xpath="f:Applications/f:Application/f:Extensions/uap:Extension/uap:FileTypeAssociation/uap:SupportedFileTypes/uap:FileType | f:Applications/f:Application/f:Extensions/uap:Extension/uap:FileTypeAssociation/uap:SupportedFileTypes/uap10:FileType"/>
      <xs:field xpath="."/>
    </xs:unique>
    <xs:unique name="Extension_Protocol">
      <xs:selector xpath="f:Applications/f:Application/f:Extensions/uap:Extension/uap:Protocol"/>
      <xs:field xpath="@Name"/>
    </xs:unique>
    <xs:unique name="Extension_DialProtocol">
      <xs:selector xpath="f:Applications/f:Application/f:Extensions/uap:Extension/uap:DialProtocol"/>
      <xs:field xpath="@Name"/>
    </xs:unique>
    <xs:unique name="Extension_StartupTask">
      <xs:selector xpath="f:Applications/f:Application/f:Extensions/desktop:Extension/desktop:StartupTask"/>
      <xs:field xpath="@TaskId"/>
    </xs:unique>
    <xs:unique name="Extension_AppExecutionAlias">
      <xs:selector xpath="f:Applications/f:Application/f:Extensions/uap3:Extension/uap3:AppExecutionAlias/desktop:ExecutionAlias | f:Applications/f:Application/f:Extensions/uap3:Extension/uap3:AppExecutionAlias/uap8:ExecutionAlias | f:Applications/f:Application/f:Extensions/uap5:Extension/uap5:AppExecutionAlias/uap5:ExecutionAlias |
      f:Applications/f:Application/f:Extensions/uap5:Extension/uap5:AppExecutionAlias/uap8:ExecutionAlias"/>
      <xs:field xpath="@Alias"/>
    </xs:unique>
    <xs:unique name="Class_Id">
      <xs:selector xpath="f:Applications/f:Application/f:Extensions/com:Extension/com:ComServer/com:ExeServer/com:Class | f:Applications/f:Application/f:Extensions/com:Extension/com:ComServer/com:SurrogateServer/com:Class | f:Applications/f:Application/f:Extensions/com:Extension/com:ComServer/com:TreatAsClass | f:Applications/f:Application/f:Extensions/com:Extension/com:ComInterface/com:ProxyStub | f:Extensions/com:Extension/com:ComInterface/com:ProxyStub | f:Applications/f:Application/f:Extensions/com2:Extension/com2:ComServer/com:ExeServer/com:Class | f:Applications/f:Application/f:Extensions/com2:Extension/com2:ComServer/com:SurrogateServer/com:Class | f:Applications/f:Application/f:Extensions/com2:Extension/com2:ComServer/com:TreatAsClass | f:Applications/f:Application/f:Extensions/com2:Extension/com2:ComInterface/com:ProxyStub | f:Extensions/com2:Extension/com2:ComInterface/com:ProxyStub"/>
      <xs:field xpath="@Id"/>
    </xs:unique>
    <xs:unique name="ProgId_Id">
      <xs:selector xpath="# The following comment should be removed at some point in the future.
# mypy: strict-optional=False

from __future__ import absolute_import

import os
import sys

from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
    from typing import Optional, Tuple


def glibc_version_string():
    # type: () -> Optional[str]
    "Returns glibc version string, or None if not using glibc."
    return glibc_version_string_confstr() or glibc_version_string_ctypes()


def glibc_version_string_confstr():
    # type: () -> Optional[str]
    "Primary implementation of glibc_version_string using os.confstr."
    # os.confstr is quite a bit faster than ctypes.DLL. It's also less likely
    # to be broken or missing. This strategy is used in the standard library
    # platform module:
    # https://github.com/python/cpython/blob/fcf1d003bf4f0100c9d0921ff3d70e1127ca1b71/Lib/platform.py#L175-L183
    if sys.platform == "win32":
        return None
    try:
        # os.confstr("CS_GNU_LIBC_VERSION") returns a string like "glibc 2.17":
        _, version = os.confstr("CS_GNU_LIBC_VERSION").split()
    except (AttributeError, OSError, ValueError):
        # os.confstr() or CS_GNU_LIBC_VERSION not available (or a bad value)...
        return None
    return version


def glibc_version_string_ctypes():
    # type: () -> Optional[str]
    "Fallback implementation of glibc_version_string using ctypes."

    try:
        import ctypes
    except ImportError:
        return None

    # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
    # manpage says, "If filename is NULL, then the returned handle is for the
    # main program". This way we can let the linker do the work to figure out
    # which libc our process is actually using.
    process_namespace = ctypes.CDLL(None)
    try:
        gnu_get_libc_version = process_namespace.gnu_get_libc_version
    except AttributeError:
        # Symbol doesn't exist -> therefore, we are not linked to
        # glibc.
        return None

    # Call gnu_get_libc_version, which returns a string like "2.5"
    gnu_get_libc_version.restype = ctypes.c_char_p
    version_str = gnu_get_libc_version()
    # py2 / py3 compatibility:
    if not isinstance(version_str, str):
        version_str = version_str.decode("ascii")

    return version_str


# platform.libc_ver regularly returns completely nonsensical glibc
# versions. E.g. on my computer, platform says:
#
#   ~$ python2.7 -c 'import platform; print(platform.libc_ver())'
#   ('glibc', '2.7')
#   ~$ python3.5 -c 'import platform; print(platform.libc_ver())'
#   ('glibc', '2.9')
#
# But the truth is:
#
#   ~$ ldd --version
#   ldd (Debian GLIBC 2.22-11) 2.22
#
# This is unfortunate, because it means that the linehaul data on libc
# versions that was generated by pip 8.1.2 and earlier is useless and
# misleading. Solution: instead of using platform, use our code that actually
# works.
def libc_ver():
    # type: () -> Tuple[str, str]
    """Try to determine the glibc version

    Returns a tuple of strings (lib, version) which default to empty strings
    in case the lookup fails.
    """
    glibc_version = glibc_version_string()
    if glibc_version is None:
        return ("", "")
    else:
        return ("glibc", glibc_version)
