Пример #1
0
    def get_exe_bytes(self):
        # If a target-version other than the current version has been
        # specified, then using the MSVC version from *this* build is no good.
        # Without actually finding and executing the target version and parsing
        # its sys.version, we just hard-code our knowledge of old versions.
        # NOTE: Possible alternative is to allow "--target-version" to
        # specify a Python executable rather than a simple version string.
        # We can then execute this program to obtain any info we need, such
        # as the real sys.version string for the build.
        cur_version = get_python_version()

        # If the target version is *later* than us, then we assume they
        # use what we use
        # string compares seem wrong, but are what sysconfig.py itself uses
        if self.target_version and self.target_version < cur_version:
            if self.target_version < "2.4":
                bv = 6.0
            elif self.target_version == "2.4":
                bv = 7.1
            elif self.target_version == "2.5":
                bv = 8.0
            elif self.target_version <= "3.2":
                bv = 9.0
            elif self.target_version <= "3.4":
                bv = 10.0
            else:
                bv = 14.0
        else:
            # for current version - use authoritative check.
            try:
                from msvcrt import CRT_ASSEMBLY_VERSION
            except ImportError:
                # cross-building, so assume the latest version
                bv = 14.0
            else:
                bv = float('.'.join(CRT_ASSEMBLY_VERSION.split('.', 2)[:2]))


        # wininst-x.y.exe is in the same directory as this file
        directory = os.path.dirname(__file__)
        # we must use a wininst-x.y.exe built with the same C compiler
        # used for python.  XXX What about mingw, borland, and so on?

        # if plat_name starts with "win" but is not "win32"
        # we want to strip "win" and leave the rest (e.g. -amd64)
        # for all other cases, we don't want any suffix
        if self.plat_name != 'win32' and self.plat_name[:3] == 'win':
            sfix = self.plat_name[3:]
        else:
            sfix = ''

        filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix))
        try:
            f = open(filename, "rb")
        except IOError as e:
            raise DistutilsFileError(str(e) + ', %s not included in the Debian packages.' % filename)
        try:
            return f.read()
        finally:
            f.close()
Пример #2
0
    def get_exe_bytes(self):
        # If a target-version other than the current version has been
        # specified, then using the MSVC version from *this* build is no good.
        # Without actually finding and executing the target version and parsing
        # its sys.version, we just hard-code our knowledge of old versions.
        # NOTE: Possible alternative is to allow "--target-version" to
        # specify a Python executable rather than a simple version string.
        # We can then execute this program to obtain any info we need, such
        # as the real sys.version string for the build.
        cur_version = get_python_version()

        # If the target version is *later* than us, then we assume they
        # use what we use
        # string compares seem wrong, but are what sysconfig.py itself uses
        if self.target_version and self.target_version < cur_version:
            if self.target_version < "2.4":
                bv = '6.0'
            elif self.target_version == "2.4":
                bv = '7.1'
            elif self.target_version == "2.5":
                bv = '8.0'
            elif self.target_version <= "3.2":
                bv = '9.0'
            elif self.target_version <= "3.4":
                bv = '10.0'
            else:
                bv = '14.0'
        else:
            # for current version - use authoritative check.
            try:
                from msvcrt import CRT_ASSEMBLY_VERSION
            except ImportError:
                # cross-building, so assume the latest version
                bv = '14.0'
            else:
                # as far as we know, CRT is binary compatible based on
                # the first field, so assume 'x.0' until proven otherwise
                major = CRT_ASSEMBLY_VERSION.partition('.')[0]
                bv = major + '.0'


        # wininst-x.y.exe is in the same directory as this file
        directory = os.path.dirname(__file__)
        # we must use a wininst-x.y.exe built with the same C compiler
        # used for python.  XXX What about mingw, borland, and so on?

        # if plat_name starts with "win" but is not "win32"
        # we want to strip "win" and leave the rest (e.g. -amd64)
        # for all other cases, we don't want any suffix
        if self.plat_name != 'win32' and self.plat_name[:3] == 'win':
            sfix = self.plat_name[3:]
        else:
            sfix = ''

        filename = os.path.join(directory, "wininst-%s%s.exe" % (bv, sfix))
        f = open(filename, "rb")
        try:
            return f.read()
        finally:
            f.close()
Пример #3
0
 def get_exe_bytes(self):
     cur_version = get_python_version()
     if self.target_version and self.target_version < cur_version:
         if self.target_version < '2.4':
             bv = 6.0
         elif self.target_version == '2.4':
             bv = 7.1
         elif self.target_version == '2.5':
             bv = 8.0
         elif self.target_version <= '3.2':
             bv = 9.0
         elif self.target_version <= '3.4':
             bv = 10.0
         else:
             bv = 14.0
     else:
         try:
             from msvcrt import CRT_ASSEMBLY_VERSION
         except ImportError:
             bv = 14.0
         else:
             bv = float('.'.join(CRT_ASSEMBLY_VERSION.split('.', 2)[:2]))
     directory = os.path.dirname(__file__)
     if self.plat_name != 'win32' and self.plat_name[:3] == 'win':
         sfix = self.plat_name[3:]
     else:
         sfix = ''
     filename = os.path.join(directory, 'wininst-%.1f%s.exe' % (bv, sfix))
     f = open(filename, 'rb')
     try:
         return f.read()
     finally:
         f.close()