当前位置: 首页>>代码示例>>Python>>正文


Python Platform.create方法代码示例

本文整理汇总了Python中pex.platforms.Platform.create方法的典型用法代码示例。如果您正苦于以下问题:Python Platform.create方法的具体用法?Python Platform.create怎么用?Python Platform.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pex.platforms.Platform的用法示例。


在下文中一共展示了Platform.create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_platform_supported_tags_abi3

# 需要导入模块: from pex.platforms import Platform [as 别名]
# 或者: from pex.platforms.Platform import create [as 别名]
def test_platform_supported_tags_abi3():
  tags = Platform.create('linux-x86_64-cp-37-m').supported_tags()
  expected_tags = [
    ('cp37', 'cp37m', 'linux_x86_64'),
    ('cp37', 'cp37m', 'manylinux1_x86_64'),
    ('cp37', 'abi3', 'linux_x86_64'),
    ('cp37', 'abi3', 'manylinux1_x86_64'),
    ('cp37', 'none', 'linux_x86_64'),
    ('cp37', 'none', 'manylinux1_x86_64'),
    ('cp36', 'abi3', 'linux_x86_64'),
    ('cp36', 'abi3', 'manylinux1_x86_64'),
    ('cp35', 'abi3', 'linux_x86_64'),
    ('cp35', 'abi3', 'manylinux1_x86_64'),
    ('cp34', 'abi3', 'linux_x86_64'),
    ('cp34', 'abi3', 'manylinux1_x86_64'),
    ('cp33', 'abi3', 'linux_x86_64'),
    ('cp33', 'abi3', 'manylinux1_x86_64'),
    ('cp32', 'abi3', 'linux_x86_64'),
    ('cp32', 'abi3', 'manylinux1_x86_64'),
    ('py3', 'none', 'linux_x86_64'),
    ('py3', 'none', 'manylinux1_x86_64'),
    ('cp37', 'none', 'any'),
    ('cp3', 'none', 'any'),
    ('py37', 'none', 'any'),
    ('py3', 'none', 'any'),
    ('py36', 'none', 'any'),
    ('py35', 'none', 'any'),
    ('py34', 'none', 'any'),
    ('py33', 'none', 'any'),
    ('py32', 'none', 'any'),
    ('py31', 'none', 'any'),
    ('py30', 'none', 'any'),
  ]
  assert expected_tags == tags
开发者ID:jsirois,项目名称:pex,代码行数:36,代码来源:test_platform.py

示例2: expand_and_maybe_adjust_platform

# 需要导入模块: from pex.platforms import Platform [as 别名]
# 或者: from pex.platforms.Platform import create [as 别名]
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
开发者ID:foursquare,项目名称:pants,代码行数:49,代码来源:pex_util.py

示例3: _maybe_expand_platform

# 需要导入模块: from pex.platforms import Platform [as 别名]
# 或者: from pex.platforms.Platform import create [as 别名]
  def _maybe_expand_platform(interpreter, platform=None):
    # Expands `platform` if it is 'current' and abbreviated.
    #
    # IE: If we're on linux and handed a platform of `None`, 'current', or 'linux_x86_64', we expand
    # the platform to an extended platform matching the given interpreter's abi info, eg:
    # 'linux_x86_64-cp-27-cp27mu'.

    cur_plat = Platform.current()
    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

    if platform in (None, 'current'):
      # Always expand the default local (abbreviated) platform to the given interpreter.
      return expand_platform()
    else:
      given_platform = Platform.create(platform)
      if given_platform.is_extended:
        # Always respect an explicit extended platform.
        return given_platform
      elif given_platform.platform != cur_plat.platform:
        # IE: Say we're on OSX and platform was 'linux-x86_64'; we can't expand a non-local
        # platform so we leave as-is.
        return given_platform
      else:
        # IE: Say we're on 64 bit linux and platform was 'linux-x86_64'; ie: the abbreviated local
        # platform.
        return expand_platform()
开发者ID:jsirois,项目名称:pex,代码行数:48,代码来源:resolver.py

示例4: assert_tags

# 需要导入模块: from pex.platforms import Platform [as 别名]
# 或者: from pex.platforms.Platform import create [as 别名]
def assert_tags(platform, expected_tags, manylinux=None):
  tags = Platform.create(platform).supported_tags(force_manylinux=manylinux)
  for expected_tag in expected_tags:
    assert expected_tag in tags
开发者ID:jsirois,项目名称:pex,代码行数:6,代码来源:test_platform.py

示例5: test_platform_current

# 需要导入模块: from pex.platforms import Platform [as 别名]
# 或者: from pex.platforms.Platform import create [as 别名]
def test_platform_current():
  assert Platform.create('current') == Platform.current()
开发者ID:jsirois,项目名称:pex,代码行数:4,代码来源:test_platform.py

示例6: test_platform_create_noop

# 需要导入模块: from pex.platforms import Platform [as 别名]
# 或者: from pex.platforms.Platform import create [as 别名]
def test_platform_create_noop():
  existing = Platform.create('linux-x86_64')
  assert Platform.create(existing) == existing
开发者ID:jsirois,项目名称:pex,代码行数:5,代码来源:test_platform.py

示例7: test_platform_create

# 需要导入模块: from pex.platforms import Platform [as 别名]
# 或者: from pex.platforms.Platform import create [as 别名]
def test_platform_create():
  assert Platform.create('linux-x86_64') == ('linux_x86_64', None, None, None)
  assert Platform.create('linux-x86_64-cp-27-cp27mu') == ('linux_x86_64', 'cp', '27', 'cp27mu')
  assert Platform.create('linux-x86_64-cp-27-mu') == ('linux_x86_64', 'cp', '27', 'cp27mu')
  assert Platform.create(
    'macosx-10.4-x86_64-cp-27-m') == ('macosx_10_4_x86_64', 'cp', '27', 'cp27m')
开发者ID:jsirois,项目名称:pex,代码行数:8,代码来源:test_platform.py


注:本文中的pex.platforms.Platform.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。