本文整理汇总了Python中sys.version方法的典型用法代码示例。如果您正苦于以下问题:Python sys.version方法的具体用法?Python sys.version怎么用?Python sys.version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sys
的用法示例。
在下文中一共展示了sys.version方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def main():
system_major = sys.version_info.major
if REQUIRED_PYTHON == "python":
required_major = 2
elif REQUIRED_PYTHON == "python3":
required_major = 3
else:
raise ValueError("Unrecognized python interpreter: {}".format(
REQUIRED_PYTHON))
if system_major != required_major:
raise TypeError(
"This project requires Python {}. Found: Python {}".format(
required_major, sys.version))
else:
print(">>> Development environment passes all tests!")
示例2: generate_cls_boundary
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def generate_cls_boundary(cls_input,cntr_id_field,boundary_output,cpu_core):
arcpy.env.parallelProcessingFactor=cpu_core
arcpy.SetProgressorLabel('Generating Delaunay Triangle...')
arrays=arcpy.da.FeatureClassToNumPyArray(cls_input,['SHAPE@XY',cntr_id_field])
cid_field_type=[f.type for f in arcpy.Describe(cls_input).fields if f.name==cntr_id_field][0]
delaunay=Delaunay(arrays['SHAPE@XY']).simplices.copy()
arcpy.CreateFeatureclass_management('in_memory','boundary_temp','POLYGON',spatial_reference=arcpy.Describe(cls_input).spatialReference)
fc=r'in_memory\boundary_temp'
arcpy.AddField_management(fc,cntr_id_field,cid_field_type)
cursor = arcpy.da.InsertCursor(fc, [cntr_id_field,"SHAPE@"])
arcpy.SetProgressor("step", "Copying Delaunay Triangle to Temp Layer...",0, delaunay.shape[0], 1)
for tri in delaunay:
arcpy.SetProgressorPosition()
cid=arrays[cntr_id_field][tri[0]]
if cid == arrays[cntr_id_field][tri[1]] and cid == arrays[cntr_id_field][tri[2]]:
cursor.insertRow([cid,arcpy.Polygon(arcpy.Array([arcpy.Point(*arrays['SHAPE@XY'][i]) for i in tri]))])
arcpy.SetProgressor('default','Merging Delaunay Triangle...')
if '64 bit' in sys.version:
arcpy.PairwiseDissolve_analysis(fc,boundary_output,cntr_id_field)
else:
arcpy.Dissolve_management(fc,boundary_output,cntr_id_field)
arcpy.Delete_management(fc)
return
示例3: print_cuda_statistics
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def print_cuda_statistics():
logger = logging.getLogger("Cuda Statistics")
import sys
from subprocess import call
import torch
logger.info('__Python VERSION: {}'.format(sys.version))
logger.info('__pyTorch VERSION: {}'.format(torch.__version__))
logger.info('__CUDA VERSION')
call(["nvcc", "--version"])
logger.info('__CUDNN VERSION: {}'.format(torch.backends.cudnn.version()))
logger.info('__Number CUDA Devices: {}'.format(torch.cuda.device_count()))
logger.info('__Devices')
call(["nvidia-smi", "--format=csv",
"--query-gpu=index,name,driver_version,memory.total,memory.used,memory.free"])
logger.info('Active CUDA Device: GPU {}'.format(torch.cuda.current_device()))
logger.info('Available devices {}'.format(torch.cuda.device_count()))
logger.info('Current cuda device {}'.format(torch.cuda.current_device()))
示例4: os_path_relpath
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def os_path_relpath(path, start=os.path.curdir):
"""Return a relative version of a path"""
if not path:
raise ValueError("no path specified")
start_list = [x for x in os.path.abspath(start).split(os.path.sep) if x]
path_list = [x for x in os.path.abspath(path).split(os.path.sep) if x]
# Work out how much of the filepath is shared by start and path.
i = len(os.path.commonprefix([start_list, path_list]))
rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:]
if not rel_list:
return os.path.curdir
return os.path.join(*rel_list)
示例5: get_versions
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def get_versions(default={"version": "unknown", "full": ""}, verbose=False):
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
# __file__, we can work backwards from there to the root. Some
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
# case we can only use expanded variables.
variables = { "refnames": git_refnames, "full": git_full }
ver = versions_from_expanded_variables(variables, tag_prefix, verbose)
if ver:
return ver
try:
root = os.path.abspath(__file__)
# versionfile_source is the relative path from the top of the source
# tree (where the .git directory might live) to this file. Invert
# this to find the root from __file__.
for i in range(len(versionfile_source.split("/"))):
root = os.path.dirname(root)
except NameError:
return default
return (versions_from_vcs(tag_prefix, root, verbose)
or versions_from_parentdir(parentdir_prefix, root, verbose)
or default)
示例6: parseargs
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def parseargs(argv):
'''handle --help, --version and our double-equal ==options'''
args = []
options = {}
key = None
for arg in argv:
if arg in DEFAULT_OPTION_VALUES:
key = arg.strip('=').replace('-', '_')
options[key] = ()
elif key is None:
args.append(arg)
else:
options[key] += (arg,)
if set(args) & {'-h', '--help'}:
print(__doc__, end='')
exit(0)
elif set(args) & {'-V', '--version'}:
print(__version__)
exit(0)
elif args:
exit('invalid option: %s\nTry --help for more information.' % args[0])
return options
示例7: invalid_virtualenv_reason
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def invalid_virtualenv_reason(venv_path, source_python, destination_python, options):
try:
orig_path = get_original_path(venv_path)
except CalledProcessError:
return 'could not inspect metadata'
if not samefile(orig_path, venv_path):
return 'virtualenv moved %s -> %s' % (timid_relpath(orig_path), timid_relpath(venv_path))
elif has_system_site_packages(destination_python) != options.system_site_packages:
return 'system-site-packages changed, to %s' % options.system_site_packages
if source_python is None:
return
destination_version = get_python_version(destination_python)
source_version = get_python_version(source_python)
if source_version != destination_version:
return 'python version changed %s -> %s' % (destination_version, source_version)
示例8: pip_faster
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def pip_faster(venv_path, pip_command, install, bootstrap_deps):
"""install and run pip-faster"""
# activate the virtualenv
execfile_(venv_executable(venv_path, 'activate_this.py'))
# disable a useless warning
# FIXME: ensure a "true SSLContext" is available
from os import environ
environ['PIP_DISABLE_PIP_VERSION_CHECK'] = '1'
# we always have to run the bootstrap, because the presense of an
# executable doesn't imply the right version. pip is able to validate the
# version in the fastpath case quickly anyway.
run(('pip', 'install') + bootstrap_deps)
run(pip_command + install)
示例9: intro
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def intro(self):
self.output.write('''
Welcome to Python %s! This is the interactive help utility.
If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/%s/tutorial/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".
To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics". Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".
''' % tuple([sys.version[:3]]*2))
示例10: _norm_version
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def _norm_version(version, build=''):
""" Normalize the version and build strings and return a single
version string using the format major.minor.build (or patchlevel).
"""
l = version.split('.')
if build:
l.append(build)
try:
ints = map(int,l)
except ValueError:
strings = l
else:
strings = list(map(str,ints))
version = '.'.join(strings[:3])
return version
示例11: mac_ver
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def mac_ver(release='',versioninfo=('','',''),machine=''):
""" Get MacOS version information and return it as tuple (release,
versioninfo, machine) with versioninfo being a tuple (version,
dev_stage, non_release_version).
Entries which cannot be determined are set to the parameter values
which default to ''. All tuple entries are strings.
"""
# First try reading the information from an XML file which should
# always be present
info = _mac_ver_xml()
if info is not None:
return info
# If that doesn't work for some reason fall back to reading the
# information using gestalt calls.
info = _mac_ver_gestalt()
if info is not None:
return info
# If that also doesn't work return the default values
return release,versioninfo,machine
示例12: onecmd
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def onecmd(self, line):
"""Interpret the argument as though it had been typed in response
to the prompt.
This may be overridden, but should not normally need to be;
see the precmd() and postcmd() methods for useful execution hooks.
The return value is a flag indicating whether interpretation of
commands by the interpreter should stop.
This (`cmd2`) version of `onecmd` already override's `cmd`'s `onecmd`.
"""
statement = self.parsed(line)
self.lastcmd = statement.parsed.raw
funcname = self.func_named(statement.parsed.command)
if not funcname:
return self._default(statement)
try:
func = getattr(self, funcname)
except AttributeError:
return self._default(statement)
stop = func(statement)
return stop
示例13: __init__
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def __init__(self, proxies=None, **x509):
msg = "%(class)s style of invoking requests is deprecated. " \
"Use newer urlopen functions/methods" % {'class': self.__class__.__name__}
warnings.warn(msg, DeprecationWarning, stacklevel=3)
if proxies is None:
proxies = getproxies()
assert hasattr(proxies, 'keys'), "proxies must be a mapping"
self.proxies = proxies
self.key_file = x509.get('key_file')
self.cert_file = x509.get('cert_file')
self.addheaders = [('User-Agent', self.version)]
self.__tempfiles = []
self.__unlink = os.unlink # See cleanup()
self.tempcache = None
# Undocumented feature: if you assign {} to tempcache,
# it is used to cache files retrieved with
# self.retrieve(). This is not enabled by default
# since it does not work for changing documents (and I
# haven't got the logic to check expiration headers
# yet).
self.ftpcache = ftpcache
# Undocumented feature: you can use a different
# ftp cache by assigning to the .ftpcache member;
# in case you want logically independent URL openers
# XXX This is not threadsafe. Bah.
示例14: get_pkg_info
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def get_pkg_info(pkg_path):
''' Return dict describing the context of this package
Parameters
----------
pkg_path : str
path containing __init__.py for package
Returns
-------
context : dict
with named parameters of interest
'''
src, hsh = pkg_commit_hash(pkg_path)
import numpy
return dict(
pkg_path=pkg_path,
commit_source=src,
commit_hash=hsh,
sys_version=sys.version,
sys_executable=sys.executable,
sys_platform=sys.platform,
np_version=numpy.__version__)
示例15: diagnose
# 需要导入模块: import sys [as 别名]
# 或者: from sys import version [as 别名]
def diagnose(data):
"""Diagnostic suite for isolating common problems."""
print "Diagnostic running on Beautiful Soup %s" % __version__
print "Python version %s" % sys.version
basic_parsers = ["html.parser", "html5lib", "lxml"]
for name in basic_parsers:
for builder in builder_registry.builders:
if name in builder.features:
break
else:
basic_parsers.remove(name)
print (
"I noticed that %s is not installed. Installing it may help." %
name)
if 'lxml' in basic_parsers:
basic_parsers.append(["lxml", "xml"])
try:
from lxml import etree
print "Found lxml version %s" % ".".join(map(str,etree.LXML_VERSION))
except ImportError, e:
print (
"lxml is not installed or couldn't be imported.")