Python sys.pypy_version_info() Examples
The following are 21
code examples of sys.pypy_version_info().
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
sys
, or try the search function
.
Example #1
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 #2
Source File: plugin.py From pytest-benchmark with BSD 2-Clause "Simplified" License | 6 votes |
def pytest_benchmark_generate_machine_info(): python_implementation = platform.python_implementation() python_implementation_version = platform.python_version() if python_implementation == 'PyPy': python_implementation_version = '%d.%d.%d' % sys.pypy_version_info[:3] if sys.pypy_version_info.releaselevel != 'final': python_implementation_version += '-%s%d' % sys.pypy_version_info[3:] return { "node": platform.node(), "processor": platform.processor(), "machine": platform.machine(), "python_compiler": platform.python_compiler(), "python_implementation": python_implementation, "python_implementation_version": python_implementation_version, "python_version": platform.python_version(), "python_build": platform.python_build(), "release": platform.release(), "system": platform.system(), "cpu": get_cpu_info(), }
Example #3
Source File: utils.py From dwave-cloud-client with Apache License 2.0 | 6 votes |
def user_agent(name, version): """Return User-Agent ~ "name/version language/version interpreter/version os/version".""" def _interpreter(): name = platform.python_implementation() version = platform.python_version() bitness = platform.architecture()[0] if name == 'PyPy': version = '.'.join(map(str, sys.pypy_version_info[:3])) full_version = [version] if bitness: full_version.append(bitness) return name, "-".join(full_version) tags = [ (name, version), ("python", platform.python_version()), _interpreter(), ("machine", platform.machine() or 'unknown'), ("system", platform.system() or 'unknown'), ("platform", platform.platform() or 'unknown'), ] return ' '.join("{}/{}".format(name, version) for name, version in tags)
Example #4
Source File: igor.py From coveragepy with Apache License 2.0 | 6 votes |
def print_banner(label): """Print the version of Python.""" try: impl = platform.python_implementation() except AttributeError: impl = "Python" version = platform.python_version() if '__pypy__' in sys.builtin_module_names: version += " (pypy %s)" % ".".join(str(v) for v in sys.pypy_version_info) try: which_python = os.path.relpath(sys.executable) except ValueError: # On Windows having a python executable on a different drive # than the sources cannot be relative. which_python = sys.executable print('=== %s %s %s (%s) ===' % (impl, version, label, which_python)) sys.stdout.flush()
Example #5
Source File: igor.py From coveragepy-bbmirror with Apache License 2.0 | 6 votes |
def print_banner(label): """Print the version of Python.""" try: impl = platform.python_implementation() except AttributeError: impl = "Python" version = platform.python_version() if '__pypy__' in sys.builtin_module_names: version += " (pypy %s)" % ".".join(str(v) for v in sys.pypy_version_info) try: which_python = os.path.relpath(sys.executable) except ValueError: # On Windows having a python executable on a different drive # than the sources cannot be relative. which_python = sys.executable print('=== %s %s %s (%s) ===' % (impl, version, label, which_python)) sys.stdout.flush()
Example #6
Source File: terminal.py From python-netsurv with MIT License | 6 votes |
def pytest_sessionstart(self, session): self._session = session self._sessionstarttime = time.time() if not self.showheader: return self.write_sep("=", "test session starts", bold=True) verinfo = platform.python_version() msg = "platform {} -- Python {}".format(sys.platform, verinfo) if hasattr(sys, "pypy_version_info"): verinfo = ".".join(map(str, sys.pypy_version_info[:3])) msg += "[pypy-{}-{}]".format(verinfo, sys.pypy_version_info[3]) msg += ", pytest-{}, py-{}, pluggy-{}".format( pytest.__version__, py.__version__, pluggy.__version__ ) if ( self.verbosity > 0 or self.config.option.debug or getattr(self.config.option, "pastebin", None) ): msg += " -- " + str(sys.executable) self.write_line(msg) lines = self.config.hook.pytest_report_header( config=self.config, startdir=self.startdir ) self._write_report_lines_from_hooks(lines)
Example #7
Source File: terminal.py From python-netsurv with MIT License | 6 votes |
def pytest_sessionstart(self, session): self._session = session self._sessionstarttime = time.time() if not self.showheader: return self.write_sep("=", "test session starts", bold=True) verinfo = platform.python_version() msg = "platform {} -- Python {}".format(sys.platform, verinfo) if hasattr(sys, "pypy_version_info"): verinfo = ".".join(map(str, sys.pypy_version_info[:3])) msg += "[pypy-{}-{}]".format(verinfo, sys.pypy_version_info[3]) msg += ", pytest-{}, py-{}, pluggy-{}".format( pytest.__version__, py.__version__, pluggy.__version__ ) if ( self.verbosity > 0 or self.config.option.debug or getattr(self.config.option, "pastebin", None) ): msg += " -- " + str(sys.executable) self.write_line(msg) lines = self.config.hook.pytest_report_header( config=self.config, startdir=self.startdir ) self._write_report_lines_from_hooks(lines)
Example #8
Source File: pundle.py From pundler with BSD 2-Clause "Simplified" License | 5 votes |
def python_version_string(): """We use it to generate per python folder name, where we will install all packages. """ if platform.python_implementation() == 'PyPy': version_info = sys.pypy_version_info else: version_info = sys.version_info version_string = '{v.major}.{v.minor}.{v.micro}'.format(v=version_info) build, _ = platform.python_build() build = build.replace(':', '_') # windows do not understand `:` in path return '{}-{}-{}'.format(platform.python_implementation(), version_string, build)
Example #9
Source File: igor.py From coveragepy with Apache License 2.0 | 5 votes |
def make_env_id(tracer): """An environment id that will keep all the test runs distinct.""" impl = platform.python_implementation().lower() version = "%s%s" % sys.version_info[:2] if '__pypy__' in sys.builtin_module_names: version += "_%s%s" % sys.pypy_version_info[:2] env_id = "%s%s_%s" % (impl, version, tracer) return env_id
Example #10
Source File: base.py From apm-agent-python with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_service_info(self): if self._service_info: return self._service_info language_version = platform.python_version() if hasattr(sys, "pypy_version_info"): runtime_version = ".".join(map(str, sys.pypy_version_info[:3])) else: runtime_version = language_version result = { "name": keyword_field(self.config.service_name), "environment": keyword_field(self.config.environment), "version": keyword_field(self.config.service_version), "agent": {"name": "python", "version": elasticapm.VERSION}, "language": {"name": "python", "version": keyword_field(platform.python_version())}, "runtime": { "name": keyword_field(platform.python_implementation()), "version": keyword_field(runtime_version), }, } if self.config.framework_name: result["framework"] = { "name": keyword_field(self.config.framework_name), "version": keyword_field(self.config.framework_version), } if self.config.service_node_name: result["node"] = {"configured_name": keyword_field(self.config.service_node_name)} self._service_info = result return result
Example #11
Source File: igor.py From coveragepy-bbmirror with Apache License 2.0 | 4 votes |
def run_tests_with_coverage(tracer, *runner_args): """Run tests, but with coverage.""" # Need to define this early enough that the first import of env.py sees it. os.environ['COVERAGE_TESTING'] = "True" os.environ['COVERAGE_PROCESS_START'] = os.path.abspath('metacov.ini') os.environ['COVERAGE_HOME'] = os.getcwd() # Create the .pth file that will let us measure coverage in sub-processes. # The .pth file seems to have to be alphabetically after easy-install.pth # or the sys.path entries aren't created right? pth_dir = os.path.dirname(pytest.__file__) pth_path = os.path.join(pth_dir, "zzz_metacov.pth") with open(pth_path, "w") as pth_file: pth_file.write("import coverage; coverage.process_startup()\n") # Make names for the data files that keep all the test runs distinct. impl = platform.python_implementation().lower() version = "%s%s" % sys.version_info[:2] if '__pypy__' in sys.builtin_module_names: version += "_%s%s" % sys.pypy_version_info[:2] suffix = "%s%s_%s_%s" % (impl, version, tracer, platform.platform()) os.environ['COVERAGE_METAFILE'] = os.path.abspath(".metacov."+suffix) import coverage cov = coverage.Coverage(config_file="metacov.ini", data_suffix=False) cov._warn_unimported_source = False cov._warn_preimported_source = False cov.start() try: # Re-import coverage to get it coverage tested! I don't understand all # the mechanics here, but if I don't carry over the imported modules # (in covmods), then things go haywire (os == None, eventually). covmods = {} covdir = os.path.split(coverage.__file__)[0] # We have to make a list since we'll be deleting in the loop. modules = list(sys.modules.items()) for name, mod in modules: if name.startswith('coverage'): if getattr(mod, '__file__', "??").startswith(covdir): covmods[name] = mod del sys.modules[name] import coverage # pylint: disable=reimported sys.modules.update(covmods) # Run tests, with the arguments from our command line. status = run_tests(tracer, *runner_args) finally: cov.stop() os.remove(pth_path) cov.combine() cov.save() return status
Example #12
Source File: rest_session.py From dashboard-api-python with MIT License | 4 votes |
def user_agent_extended(be_geo_id, caller): # Generate extended portion of the User-Agent user_agent_extended = be_geo_id user_agent_extended = {} # Mimic pip system data collection per https://github.com/pypa/pip/blob/master/src/pip/_internal/network/session.py user_agent_extended['implementation'] = { "name": platform.python_implementation(), } if user_agent_extended["implementation"]["name"] in ('CPython','Jython','IronPython'): user_agent_extended["implementation"]["version"] = platform.python_version() elif user_agent_extended["implementation"]["name"] == 'PyPy': if sys.pypy_version_info.releaselevel == 'final': pypy_version_info = sys.pypy_version_info[:3] else: pypy_version_info = sys.pypy_version_info user_agent_extended["implementation"]["version"] = ".".join( [str(x) for x in pypy_version_info] ) if sys.platform.startswith("darwin") and platform.mac_ver()[0]: user_agent_extended["distro"] = {"name": "macOS", "version": platform.mac_ver()[0]} if platform.system(): user_agent_extended.setdefault("system", {})["name"] = platform.system() if platform.release(): user_agent_extended.setdefault("system", {})["release"] = platform.release() if platform.machine(): user_agent_extended["cpu"] = platform.machine() if be_geo_id: user_agent_extended["be_geo_id"] = be_geo_id if caller: user_agent_extended["caller"] = caller return urllib.parse.quote(json.dumps(user_agent_extended)) # Main module interface
Example #13
Source File: debuginfo.py From python-zhmcclient with Apache License 2.0 | 4 votes |
def as_dict(): """ Return debug information as a dictionary. """ debug_info = dict() debug_info['os_name'] = platform.system() debug_info['os_version'] = platform.release() debug_info['cpu_arch'] = platform.machine() debug_info['bit_size'] = ctypes.sizeof(ctypes.c_void_p) * 8 char_len = len(b'\\U00010142'.decode('unicode-escape')) if char_len == 1: debug_info['unicode_size'] = 'wide' elif char_len == 2: debug_info['unicode_size'] = 'narrow' else: # Should not happen debug_info['unicode_size'] = 'unknown' impl = platform.python_implementation() debug_info['impl'] = impl if impl == 'CPython': impl_version = version_string(sys.version_info) elif impl == 'PyPy': impl_version = version_string(sys.pypy_version_info) elif impl == 'Jython': impl_version = version_string(sys.version_info) # TODO: Verify elif impl == 'IronPython': impl_version = version_string(sys.version_info) # TODO: Verify else: impl_version = 'unknown' debug_info['impl_version'] = impl_version debug_info['python_version'] = platform.python_version() debug_info['zhmcclient_version'] = zhmcclient_version return debug_info
Example #14
Source File: download.py From Flask-P2P with MIT License | 4 votes |
def user_agent(): """ Return a string representing the user agent. """ data = { "installer": {"name": "pip", "version": pip.__version__}, "python": platform.python_version(), "implementation": { "name": platform.python_implementation(), }, } if data["implementation"]["name"] == 'CPython': data["implementation"]["version"] = platform.python_version() elif data["implementation"]["name"] == 'PyPy': if sys.pypy_version_info.releaselevel == 'final': pypy_version_info = sys.pypy_version_info[:3] else: pypy_version_info = sys.pypy_version_info data["implementation"]["version"] = ".".join( [str(x) for x in pypy_version_info] ) elif data["implementation"]["name"] == 'Jython': # Complete Guess data["implementation"]["version"] = platform.python_version() elif data["implementation"]["name"] == 'IronPython': # Complete Guess data["implementation"]["version"] = platform.python_version() if sys.platform.startswith("linux"): distro = dict(filter( lambda x: x[1], zip(["name", "version", "id"], platform.linux_distribution()), )) libc = dict(filter( lambda x: x[1], zip(["lib", "version"], platform.libc_ver()), )) if libc: distro["libc"] = libc if distro: data["distro"] = distro if sys.platform.startswith("darwin") and platform.mac_ver()[0]: data["distro"] = {"name": "OS X", "version": platform.mac_ver()[0]} if platform.system(): data.setdefault("system", {})["name"] = platform.system() if platform.release(): data.setdefault("system", {})["release"] = platform.release() if platform.machine(): data["cpu"] = platform.machine() return "{data[installer][name]}/{data[installer][version]} {json}".format( data=data, json=json.dumps(data, separators=(",", ":"), sort_keys=True), )
Example #15
Source File: rest_session.py From dashboard-api-python with MIT License | 4 votes |
def user_agent_extended(be_geo_id, caller): # Generate extended portion of the User-Agent user_agent_extended = be_geo_id user_agent_extended = {} # Mimic pip system data collection per https://github.com/pypa/pip/blob/master/src/pip/_internal/network/session.py user_agent_extended['implementation'] = { "name": platform.python_implementation(), } if user_agent_extended["implementation"]["name"] in ('CPython','Jython','IronPython'): user_agent_extended["implementation"]["version"] = platform.python_version() elif user_agent_extended["implementation"]["name"] == 'PyPy': if sys.pypy_version_info.releaselevel == 'final': pypy_version_info = sys.pypy_version_info[:3] else: pypy_version_info = sys.pypy_version_info user_agent_extended["implementation"]["version"] = ".".join( [str(x) for x in pypy_version_info] ) if sys.platform.startswith("darwin") and platform.mac_ver()[0]: user_agent_extended["distro"] = {"name": "macOS", "version": platform.mac_ver()[0]} if platform.system(): user_agent_extended.setdefault("system", {})["name"] = platform.system() if platform.release(): user_agent_extended.setdefault("system", {})["release"] = platform.release() if platform.machine(): user_agent_extended["cpu"] = platform.machine() if be_geo_id: user_agent_extended["be_geo_id"] = be_geo_id if caller: user_agent_extended["caller"] = caller return urllib.parse.quote(json.dumps(user_agent_extended)) # Main module interface
Example #16
Source File: download.py From ImageFusion with MIT License | 4 votes |
def user_agent(): """ Return a string representing the user agent. """ data = { "installer": {"name": "pip", "version": pip.__version__}, "python": platform.python_version(), "implementation": { "name": platform.python_implementation(), }, } if data["implementation"]["name"] == 'CPython': data["implementation"]["version"] = platform.python_version() elif data["implementation"]["name"] == 'PyPy': if sys.pypy_version_info.releaselevel == 'final': pypy_version_info = sys.pypy_version_info[:3] else: pypy_version_info = sys.pypy_version_info data["implementation"]["version"] = ".".join( [str(x) for x in pypy_version_info] ) elif data["implementation"]["name"] == 'Jython': # Complete Guess data["implementation"]["version"] = platform.python_version() elif data["implementation"]["name"] == 'IronPython': # Complete Guess data["implementation"]["version"] = platform.python_version() if sys.platform.startswith("linux"): distro = dict(filter( lambda x: x[1], zip(["name", "version", "id"], platform.linux_distribution()), )) libc = dict(filter( lambda x: x[1], zip(["lib", "version"], platform.libc_ver()), )) if libc: distro["libc"] = libc if distro: data["distro"] = distro if sys.platform.startswith("darwin") and platform.mac_ver()[0]: data["distro"] = {"name": "OS X", "version": platform.mac_ver()[0]} if platform.system(): data.setdefault("system", {})["name"] = platform.system() if platform.release(): data.setdefault("system", {})["release"] = platform.release() if platform.machine(): data["cpu"] = platform.machine() return "{data[installer][name]}/{data[installer][version]} {json}".format( data=data, json=json.dumps(data, separators=(",", ":"), sort_keys=True), )
Example #17
Source File: download.py From ImageFusion with MIT License | 4 votes |
def user_agent(): """ Return a string representing the user agent. """ data = { "installer": {"name": "pip", "version": pip.__version__}, "python": platform.python_version(), "implementation": { "name": platform.python_implementation(), }, } if data["implementation"]["name"] == 'CPython': data["implementation"]["version"] = platform.python_version() elif data["implementation"]["name"] == 'PyPy': if sys.pypy_version_info.releaselevel == 'final': pypy_version_info = sys.pypy_version_info[:3] else: pypy_version_info = sys.pypy_version_info data["implementation"]["version"] = ".".join( [str(x) for x in pypy_version_info] ) elif data["implementation"]["name"] == 'Jython': # Complete Guess data["implementation"]["version"] = platform.python_version() elif data["implementation"]["name"] == 'IronPython': # Complete Guess data["implementation"]["version"] = platform.python_version() if sys.platform.startswith("linux"): distro = dict(filter( lambda x: x[1], zip(["name", "version", "id"], platform.linux_distribution()), )) libc = dict(filter( lambda x: x[1], zip(["lib", "version"], platform.libc_ver()), )) if libc: distro["libc"] = libc if distro: data["distro"] = distro if sys.platform.startswith("darwin") and platform.mac_ver()[0]: data["distro"] = {"name": "OS X", "version": platform.mac_ver()[0]} if platform.system(): data.setdefault("system", {})["name"] = platform.system() if platform.release(): data.setdefault("system", {})["release"] = platform.release() if platform.machine(): data["cpu"] = platform.machine() return "{data[installer][name]}/{data[installer][version]} {json}".format( data=data, json=json.dumps(data, separators=(",", ":"), sort_keys=True), )
Example #18
Source File: download.py From datafari with Apache License 2.0 | 4 votes |
def user_agent(): """ Return a string representing the user agent. """ data = { "installer": {"name": "pip", "version": pip.__version__}, "python": platform.python_version(), "implementation": { "name": platform.python_implementation(), }, } if data["implementation"]["name"] == 'CPython': data["implementation"]["version"] = platform.python_version() elif data["implementation"]["name"] == 'PyPy': if sys.pypy_version_info.releaselevel == 'final': pypy_version_info = sys.pypy_version_info[:3] else: pypy_version_info = sys.pypy_version_info data["implementation"]["version"] = ".".join( [str(x) for x in pypy_version_info] ) elif data["implementation"]["name"] == 'Jython': # Complete Guess data["implementation"]["version"] = platform.python_version() elif data["implementation"]["name"] == 'IronPython': # Complete Guess data["implementation"]["version"] = platform.python_version() if sys.platform.startswith("linux"): distro = dict(filter( lambda x: x[1], zip(["name", "version", "id"], platform.linux_distribution()), )) libc = dict(filter( lambda x: x[1], zip(["lib", "version"], platform.libc_ver()), )) if libc: distro["libc"] = libc if distro: data["distro"] = distro if sys.platform.startswith("darwin") and platform.mac_ver()[0]: data["distro"] = {"name": "OS X", "version": platform.mac_ver()[0]} if platform.system(): data.setdefault("system", {})["name"] = platform.system() if platform.release(): data.setdefault("system", {})["release"] = platform.release() if platform.machine(): data["cpu"] = platform.machine() return "{data[installer][name]}/{data[installer][version]} {json}".format( data=data, json=json.dumps(data, separators=(",", ":"), sort_keys=True), )
Example #19
Source File: download.py From Splunking-Crime with GNU Affero General Public License v3.0 | 4 votes |
def user_agent(): """ Return a string representing the user agent. """ data = { "installer": {"name": "pip", "version": pip.__version__}, "python": platform.python_version(), "implementation": { "name": platform.python_implementation(), }, } if data["implementation"]["name"] == 'CPython': data["implementation"]["version"] = platform.python_version() elif data["implementation"]["name"] == 'PyPy': if sys.pypy_version_info.releaselevel == 'final': pypy_version_info = sys.pypy_version_info[:3] else: pypy_version_info = sys.pypy_version_info data["implementation"]["version"] = ".".join( [str(x) for x in pypy_version_info] ) elif data["implementation"]["name"] == 'Jython': # Complete Guess data["implementation"]["version"] = platform.python_version() elif data["implementation"]["name"] == 'IronPython': # Complete Guess data["implementation"]["version"] = platform.python_version() if sys.platform.startswith("linux"): distro = dict(filter( lambda x: x[1], zip(["name", "version", "id"], platform.linux_distribution()), )) libc = dict(filter( lambda x: x[1], zip(["lib", "version"], platform.libc_ver()), )) if libc: distro["libc"] = libc if distro: data["distro"] = distro if sys.platform.startswith("darwin") and platform.mac_ver()[0]: data["distro"] = {"name": "OS X", "version": platform.mac_ver()[0]} if platform.system(): data.setdefault("system", {})["name"] = platform.system() if platform.release(): data.setdefault("system", {})["release"] = platform.release() if platform.machine(): data["cpu"] = platform.machine() return "{data[installer][name]}/{data[installer][version]} {json}".format( data=data, json=json.dumps(data, separators=(",", ":"), sort_keys=True), )
Example #20
Source File: rest_session.py From dashboard-api-python with MIT License | 4 votes |
def user_agent_extended(be_geo_id, caller): # Generate extended portion of the User-Agent user_agent_extended = be_geo_id user_agent_extended = {} # Mimic pip system data collection per https://github.com/pypa/pip/blob/master/src/pip/_internal/network/session.py user_agent_extended['implementation'] = { "name": platform.python_implementation(), } if user_agent_extended["implementation"]["name"] in ('CPython','Jython','IronPython'): user_agent_extended["implementation"]["version"] = platform.python_version() elif user_agent_extended["implementation"]["name"] == 'PyPy': if sys.pypy_version_info.releaselevel == 'final': pypy_version_info = sys.pypy_version_info[:3] else: pypy_version_info = sys.pypy_version_info user_agent_extended["implementation"]["version"] = ".".join( [str(x) for x in pypy_version_info] ) if sys.platform.startswith("darwin") and platform.mac_ver()[0]: user_agent_extended["distro"] = {"name": "macOS", "version": platform.mac_ver()[0]} if platform.system(): user_agent_extended.setdefault("system", {})["name"] = platform.system() if platform.release(): user_agent_extended.setdefault("system", {})["release"] = platform.release() if platform.machine(): user_agent_extended["cpu"] = platform.machine() if be_geo_id: user_agent_extended["be_geo_id"] = be_geo_id if caller: user_agent_extended["caller"] = caller return urllib.parse.quote(json.dumps(user_agent_extended)) # Main module interface
Example #21
Source File: rest_session.py From dashboard-api-python with MIT License | 4 votes |
def user_agent_extended(be_geo_id, caller): # Generate extended portion of the User-Agent user_agent_extended = be_geo_id user_agent_extended = {} # Mimic pip system data collection per https://github.com/pypa/pip/blob/master/src/pip/_internal/network/session.py user_agent_extended['implementation'] = { "name": platform.python_implementation(), } if user_agent_extended["implementation"]["name"] in ('CPython','Jython','IronPython'): user_agent_extended["implementation"]["version"] = platform.python_version() elif user_agent_extended["implementation"]["name"] == 'PyPy': if sys.pypy_version_info.releaselevel == 'final': pypy_version_info = sys.pypy_version_info[:3] else: pypy_version_info = sys.pypy_version_info user_agent_extended["implementation"]["version"] = ".".join( [str(x) for x in pypy_version_info] ) if sys.platform.startswith("darwin") and platform.mac_ver()[0]: user_agent_extended["distro"] = {"name": "macOS", "version": platform.mac_ver()[0]} if platform.system(): user_agent_extended.setdefault("system", {})["name"] = platform.system() if platform.release(): user_agent_extended.setdefault("system", {})["release"] = platform.release() if platform.machine(): user_agent_extended["cpu"] = platform.machine() if be_geo_id: user_agent_extended["be_geo_id"] = be_geo_id if caller: user_agent_extended["caller"] = caller return urllib.parse.quote(json.dumps(user_agent_extended)) # Main module interface