def test_platform_create(): # type: () -> None assert Platform.create("linux-x86_64-cp-27-cp27mu") == Platform( "linux_x86_64", "cp", "27", "cp27mu") assert Platform.create("linux-x86_64-cp-27-mu") == Platform( "linux_x86_64", "cp", "27", "cp27mu") assert Platform.create("macosx-10.4-x86_64-cp-27-m") == Platform( "macosx_10_4_x86_64", "cp", "27", "cp27m", )
def expand_and_maybe_adjust_platform(interpreter, platform): """Adjusts `platform` if it is 'current' and does not match the given `interpreter` platform. :param interpreter: The target interpreter for the given `platform`. :type interpreter: :class:`pex.interpreter.PythonInterpreter` :param platform: The platform name to expand and maybe adjust. :type platform: text :returns: The `platform`, potentially adjusted. :rtype: :class:`pex.platforms.Platform` """ # TODO(John Sirois): Kill all usages when https://github.com/pantsbuild/pex/issues/511 is fixed. cur_plat = Platform.current() if cur_plat.platform != Platform.create(platform).platform: # IE: Say we're on OSX and platform was 'linux-x86_64' or 'linux_x86_64-cp-27-cp27mu'. return Platform.create(platform) ii = interpreter.identity if (ii.abbr_impl, ii.impl_ver, ii.abi_tag) == (cur_plat.impl, cur_plat.version, cur_plat.abi): # IE: Say we're on Linux and platform was 'current' or 'linux-x86_64' or # 'linux_x86_64-cp-27-cp27mu'and the current extended platform info matches the given # interpreter exactly. return cur_plat # Otherwise we need to adjust the platform to match a local interpreter different from the # currently executing interpreter. interpreter_platform = Platform(platform=cur_plat.platform, impl=ii.abbr_impl, version=ii.impl_ver, abi=ii.abi_tag) logger.debug(""" Modifying given platform of {given_platform!r}: Using the current platform of {current_platform!r} Under current interpreter {current_interpreter!r} To match given interpreter {given_interpreter!r}. Calculated platform: {calculated_platform!r}""".format( given_platform=platform, current_platform=cur_plat, current_interpreter=_interpreter_str(PythonInterpreter.get()), given_interpreter=_interpreter_str(interpreter), calculated_platform=interpreter_platform)) return interpreter_platform
def expand_platform(): expanded_platform = Platform(platform=cur_plat.platform, impl=interpreter.identity.abbr_impl, version=interpreter.identity.impl_ver, abi=interpreter.identity.abi_tag) TRACER.log(""" Modifying given platform of {given_platform!r}: Using the current platform of {current_platform!r} Under current interpreter {current_interpreter!r} To match given interpreter {given_interpreter!r}. Calculated platform: {calculated_platform!r}""".format( given_platform=platform, current_platform=cur_plat, current_interpreter=PythonInterpreter.get(), given_interpreter=interpreter, calculated_platform=expanded_platform), V=9) return expanded_platform
def test_platform(): assert Platform('linux-x86_64', 'cp', '27', 'mu') == ('linux_x86_64', 'cp', '27', 'cp27mu') assert str(Platform('linux-x86_64', 'cp', '27', 'm')) == 'linux_x86_64-cp-27-cp27m' assert str(Platform('linux-x86_64')) == 'linux_x86_64'
def test_platform(): assert Platform("linux-x86_64", "cp", "27", "mu") == ("linux_x86_64", "cp", "27", "cp27mu") assert str(Platform("linux-x86_64", "cp", "27", "m")) == "linux_x86_64-cp-27-cp27m"
def test_platform(): # type: () -> None assert Platform("linux-x86_64", "cp", "27", "mu") == Platform("linux_x86_64", "cp", "27", "cp27mu") assert str(Platform("linux-x86_64", "cp", "27", "m")) == "linux_x86_64-cp-27-cp27m"