Python platform.python_version_tuple() Examples
The following are 30
code examples of platform.python_version_tuple().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
platform
, or try the search function
.
Example #1
Source File: test_multi_node_iterator.py From chainer with MIT License | 6 votes |
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)
Example #2
Source File: compat.py From apm-agent-python with BSD 3-Clause "New" or "Revised" License | 6 votes |
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]]
Example #3
Source File: markers.py From rules_pip with MIT License | 6 votes |
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, }
Example #4
Source File: markers.py From rules_pip with MIT License | 6 votes |
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, }
Example #5
Source File: markers.py From review-heatmap with GNU Affero General Public License v3.0 | 6 votes |
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, }
Example #6
Source File: markers.py From setuptools with MIT License | 6 votes |
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, }
Example #7
Source File: provenance.py From tsinfer with GNU General Public License v3.0 | 6 votes |
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
Example #8
Source File: markers.py From setuptools with MIT License | 6 votes |
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, }
Example #9
Source File: __init__.py From dtale with GNU Lesser General Public License v2.1 | 6 votes |
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()))
Example #10
Source File: markers.py From pip-api with Apache License 2.0 | 6 votes |
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, }
Example #11
Source File: test_tox_pyenv.py From tox-pyenv with Apache License 2.0 | 6 votes |
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)
Example #12
Source File: decorators.py From CUP with Apache License 2.0 | 6 votes |
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
Example #13
Source File: markers.py From pipenv with MIT License | 6 votes |
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, }
Example #14
Source File: markers.py From pipenv with MIT License | 6 votes |
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, }
Example #15
Source File: test_core.py From deepWordBug with Apache License 2.0 | 6 votes |
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
Example #16
Source File: test_core.py From deepWordBug with Apache License 2.0 | 6 votes |
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'
Example #17
Source File: markers.py From CogAlg with MIT License | 6 votes |
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, }
Example #18
Source File: markers.py From pex with Apache License 2.0 | 6 votes |
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, }
Example #19
Source File: markers.py From pex with Apache License 2.0 | 6 votes |
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, }
Example #20
Source File: provenance.py From pyslim with MIT License | 6 votes |
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
Example #21
Source File: markers.py From pex with Apache License 2.0 | 6 votes |
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, }
Example #22
Source File: session_info.py From reprexpy with MIT License | 6 votes |
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 ---------------------------
Example #23
Source File: pep508.py From pdm with MIT License | 6 votes |
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, }
Example #24
Source File: api_client.py From gocardless-pro-python with MIT License | 5 votes |
def _user_agent(self): python_version = '.'.join(platform.python_version_tuple()[0:2]) vm_version = '{}.{}.{}-{}{}'.format(*sys.version_info) return ' '.join([ 'gocardless-pro-python/1.19.0', 'python/{0}'.format(python_version), '{0}/{1}'.format(platform.python_implementation(), vm_version), '{0}/{1}'.format(platform.system(), platform.release()), 'requests/{0}'.format(requests.__version__), ])
Example #25
Source File: batch_decorator.py From metaflow with Apache License 2.0 | 5 votes |
def __init__(self, attributes=None, statically_defined=False): super(BatchDecorator, self).__init__(attributes, statically_defined) if not self.attributes['image']: if BATCH_CONTAINER_IMAGE: self.attributes['image'] = BATCH_CONTAINER_IMAGE else: self.attributes['image'] = 'python:%s.%s' % (platform.python_version_tuple()[0], platform.python_version_tuple()[1]) if not BatchDecorator._get_registry(self.attributes['image']): if BATCH_CONTAINER_REGISTRY: self.attributes['image'] = '%s/%s' % (BATCH_CONTAINER_REGISTRY.rstrip('/'), self.attributes['image'])
Example #26
Source File: playlist.py From metaflow with Apache License 2.0 | 5 votes |
def get_python_version(): """ A convenience function to get the python version used to run this tutorial. This ensures that the conda environment is created with an available version of python. """ import platform versions = {'2' : '2.7.15', '3' : '3.7.3'} return versions[platform.python_version_tuple()[0]] # Use the specified version of python for this flow.
Example #27
Source File: setup.py From coscmd with MIT License | 5 votes |
def requirements(): with open('requirements.txt', 'r') as fileobj: requirements = [line.strip() for line in fileobj] version = python_version_tuple() if version[0] == 2 and version[1] == 6: requirements.append("argparse==1.4.0") if version[0] == 3: requirements.append("argparse==1.1") return requirements
Example #28
Source File: codechecks.py From ffig with MIT License | 5 votes |
def _decode_terminal_output(s): '''Translate teminal output into a Python string''' if platform.python_version_tuple()[0] == '3': return s.decode("utf8") return s
Example #29
Source File: detect.py From core with GNU General Public License v3.0 | 5 votes |
def detect_platform(mapping=True): """Detect distro platform.""" base_mapping = { "gentoo base system": "gentoo", "centos linux": "centos", "mandriva linux": "mandriva", } platform_mapping = { "ubuntu": "debian", "linuxmint": "debian", "manjaro": "arch", "antergos": "arch", "bluestar": "arch", "archbang": "arch" } if platform.system() != "Linux": return platform.system().lower() dist = "" (maj, min, patch) = platform.python_version_tuple() if (int(maj) * 10 + int(min)) >= 26: dist = platform.linux_distribution()[0] else: dist = platform.dist()[0] if dist == "": try: with open("/etc/issue", "r") as f: dist = f.read().split()[0] except: dist = "unknown" res = dist.strip().lower() if res in base_mapping: res = base_mapping[res] if mapping and res in platform_mapping: res = platform_mapping[res] return res
Example #30
Source File: common.py From OrangeAssassin with Apache License 2.0 | 5 votes |
def can_compile(): """Check if compiling is supported or not on this environment.""" logger = logging.getLogger("oa-logger") if "pypy" in platform.python_implementation().lower(): logger.warning("Compiler is not available on PyPy") return False major, minor, patch = platform.python_version_tuple() if int(major) >= 3 and int(minor) < 5: logger.warning("Compiler is not available on 3.4 or lower.") return False # There's not going to be a Python 2.8 so this is safe. if int(major) <= 2 and (int(minor) < 7 or int(patch) < 11): logger.warning("Compiler is not available on 2.7.10 or lower.") return False return True