本文整理汇总了Python中platform.python_version_tuple方法的典型用法代码示例。如果您正苦于以下问题:Python platform.python_version_tuple方法的具体用法?Python platform.python_version_tuple怎么用?Python platform.python_version_tuple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platform
的用法示例。
在下文中一共展示了platform.python_version_tuple方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def get_environment():
"""
Returns a dictionary describing the environment in which tsinfer
is currently running.
"""
env = {
"libraries": {
"zarr": {"version": zarr.__version__},
"numcodecs": {"version": numcodecs.__version__},
"lmdb": {"version": lmdb.__version__},
"tskit": {"version": tskit.__version__},
},
"os": {
"system": platform.system(),
"node": platform.node(),
"release": platform.release(),
"version": platform.version(),
"machine": platform.machine(),
},
"python": {
"implementation": platform.python_implementation(),
"version": platform.python_version_tuple(),
},
}
return env
示例2: default_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def default_environment():
if hasattr(sys, "implementation"):
iver = format_full_version(sys.implementation.version)
implementation_name = sys.implementation.name
else:
iver = "0"
implementation_name = ""
return {
"implementation_name": implementation_name,
"implementation_version": iver,
"os_name": os.name,
"platform_machine": platform.machine(),
"platform_release": platform.release(),
"platform_system": platform.system(),
"platform_version": platform.version(),
"python_full_version": platform.python_version(),
"platform_python_implementaiton": platform.python_implementation(),
"python_version": ".".join(platform.python_version_tuple()[:2]),
"sys_platform": sys.platform,
}
示例3: test_python3_2_raises_exception
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def test_python3_2_raises_exception(monkeypatch):
"Test python version 3.0 through 3.2 raises an exception."
import blessed
monkeypatch.setattr('platform.python_version_tuple',
lambda: ('3', '2', '2'))
try:
imp.reload(blessed)
except ImportError as err:
assert err.args[0] == (
'Blessed needs Python 3.2.3 or greater for Python 3 '
'support due to http://bugs.python.org/issue10570.')
monkeypatch.undo()
imp.reload(blessed)
else:
assert False, 'Exception should have been raised'
示例4: _get_sesh_info_sectn
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def _get_sesh_info_sectn(self):
pf = platform.platform() + \
' (64-bit)' if sys.maxsize > 2 ** 32 else ' (32-bit)'
major, minor, _ = platform.python_version_tuple()
python_v = major + '.' + minor
now = datetime.datetime.now()
date = now.strftime('%Y-%m-%d')
return {
'Platform': pf,
'Python': python_v,
'Date': date
}
# methods used to initialize pkg_info field ---------------------------
示例5: default_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def default_environment():
if hasattr(sys, "implementation"):
iver = format_full_version(sys.implementation.version)
implementation_name = sys.implementation.name
else:
iver = "0"
implementation_name = ""
return {
"implementation_name": implementation_name,
"implementation_version": iver,
"os_name": os.name,
"platform_machine": platform.machine(),
"platform_release": platform.release(),
"platform_system": platform.system(),
"platform_version": platform.version(),
"python_full_version": platform.python_version(),
"platform_python_implementation": platform.python_implementation(),
"python_version": ".".join(platform.python_version_tuple()[:2]),
"sys_platform": sys.platform,
}
示例6: test_missing_ordereddict_uses_module
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def test_missing_ordereddict_uses_module(monkeypatch):
"ordereddict module is imported when without collections.OrderedDict."
import blessed.keyboard
if hasattr(collections, 'OrderedDict'):
monkeypatch.delattr('collections.OrderedDict')
try:
imp.reload(blessed.keyboard)
except ImportError as err:
assert err.args[0] in ("No module named ordereddict", # py2
"No module named 'ordereddict'") # py3
sys.modules['ordereddict'] = mock.Mock()
sys.modules['ordereddict'].OrderedDict = -1
imp.reload(blessed.keyboard)
assert blessed.keyboard.OrderedDict == -1
del sys.modules['ordereddict']
monkeypatch.undo()
imp.reload(blessed.keyboard)
else:
assert platform.python_version_tuple() < ('2', '7') # reached by py2.6
示例7: default_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def default_environment():
# type: () -> Dict[str, str]
if hasattr(sys, "implementation"):
# Ignoring the `sys.implementation` reference for type checking due to
# mypy not liking that the attribute doesn't exist in Python 2.7 when
# run with the `--py27` flag.
iver = format_full_version(sys.implementation.version) # type: ignore
implementation_name = sys.implementation.name # type: ignore
else:
iver = "0"
implementation_name = ""
return {
"implementation_name": implementation_name,
"implementation_version": iver,
"os_name": os.name,
"platform_machine": platform.machine(),
"platform_release": platform.release(),
"platform_system": platform.system(),
"platform_version": platform.version(),
"python_full_version": platform.python_version(),
"platform_python_implementation": platform.python_implementation(),
"python_version": ".".join(platform.python_version_tuple()[:2]),
"sys_platform": sys.platform,
}
示例8: setUp
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def setUp(self):
if self.iterator_class == chainer.iterators.MultiprocessIterator and \
int(platform.python_version_tuple()[0]) < 3:
pytest.skip('This test requires Python version >= 3')
self.communicator = chainermn.create_communicator('naive')
if self.communicator.size < 2:
pytest.skip('This test is for multinode only')
self.N = 100
if self.paired_dataset:
self.dataset = list(zip(
np.arange(self.N).astype(np.float32),
np.arange(self.N).astype(np.float32)))
else:
self.dataset = np.arange(self.N).astype(np.float32)
示例9: test_is_precisely_correct_version
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def test_is_precisely_correct_version(self):
toxenvname = 'TOX_%s' % os.environ['TOX_ENV_NAME'].upper().strip()
expected_string = os.environ[toxenvname].strip(' "\'')
print('\n\nTOX ENV NAME: %s' % toxenvname)
if platform.python_implementation() == 'PyPy':
actual_list = [str(_).strip() for _ in sys.pypy_version_info[:3]]
expected_string = expected_string.split('-')[1].strip(' "\'')
print('\nExpected version for this tox env: PyPy %s'
% expected_string)
print('Actual version for this tox env: PyPy %s'
% '.'.join(actual_list))
else:
print('\nExpected version for this tox env: Python %s'
% expected_string)
print('Actual version for this tox env: Python %s'
% platform.python_version())
actual_list = list(platform.python_version_tuple())
expected_list = expected_string.split('.')
print('\n\nPYTHON VERSION (verbose)')
print('*************************')
print(sys.version)
print('\n')
self.assertEqual(actual_list, expected_list)
示例10: custom_module_loader
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def custom_module_loader():
"""
Utility function for using different module loaders based on python version:
* :meth:`dtale.cli.loaders.get_py35_loader`
* :meth:`dtale.cli.loaders.get_py33_loader`
* :meth:`dtale.cli.loaders.get_py2_loader`
"""
major, minor, revision = [int(i) for i in platform.python_version_tuple()]
if major == 2:
return get_py2_loader
if major == 3:
if minor >= 5:
return get_py35_loader
elif minor in (3, 4):
return get_py33_loader
raise ValueError(unsupported_python_version(platform.python_version_tuple()))
示例11: get_default_library_patters
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def get_default_library_patters():
"""
Returns library paths depending on the used platform.
:return: a list of glob paths
"""
python_version = platform.python_version_tuple()
python_implementation = platform.python_implementation()
system = platform.system()
if python_implementation == "PyPy":
if python_version[0] == "2":
return ["*/lib-python/%s.%s/*" % python_version[:2], "*/site-packages/*"]
else:
return ["*/lib-python/%s/*" % python_version[0], "*/site-packages/*"]
else:
if system == "Windows":
return [r"*\lib\*"]
return ["*/lib/python%s.%s/*" % python_version[:2], "*/lib64/python%s.%s/*" % python_version[:2]]
示例12: py_versioncheck
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def py_versioncheck(function, version):
"""
:platform:
any platform + any functions in python
:param version:
The python on the OS should be >= param version.
*E.g. version=('2', '7', '0')*
OS python version should >= 2.7.0
"""
ind = 0
py_version = platform.python_version_tuple()
for i in py_version:
if int(version(ind)) < int(i):
raise cup.err.DecoratorException(
'Python version check failed. You expect version >= %s,'
'but python-version on this machine:%s' %
(version, py_version)
)
ind += 1
return function
示例13: get_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def get_environment():
"""
Returns a dictionary describing the environment in which msprime
is currently running.
"""
env = {
"libraries": {
},
"parameters" : {
"command" : []
},
"os": {
"system": platform.system(),
"node": platform.node(),
"release": platform.release(),
"version": platform.version(),
"machine": platform.machine(),
},
"python": {
"implementation": platform.python_implementation(),
"version": platform.python_version_tuple(),
}
}
return env
示例14: benchmark
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def benchmark(n):
global methods
if "--onlyself" in sys.argv[1:]:
methods = [m for m in methods if m[0].startswith("tabulate")]
else:
methods = methods
results = [
(desc, timeit(code, setup_code, number=n) / n * 1e6) for desc, code in methods
]
mintime = min(map(lambda x: x[1], results))
results = [
(desc, t, t / mintime) for desc, t in sorted(results, key=lambda x: x[1])
]
table = tabulate.tabulate(
results, ["Table formatter", "time, μs", "rel. time"], "rst", floatfmt=".1f"
)
import platform
if platform.platform().startswith("Windows"):
print(table)
elif python_version_tuple()[0] < "3":
print(codecs.encode(table, "utf-8"))
else:
print(table)
示例15: py3test_require_py3
# 需要导入模块: import platform [as 别名]
# 或者: from platform import python_version_tuple [as 别名]
def py3test_require_py3():
"Regression: py33 tests should actually use Python 3 (issue #13)"
from platform import python_version_tuple
print("Expected Python version: 3.x.x")
print("Python version used for tests: %s.%s.%s" % python_version_tuple())
assert_equal(python_version_tuple()[0], "3")