Find python version name used in this virtualenv.

    For example: ``python2.7``, ``python3.4``
192480
def find_linux_venv_py_version():
    
    available_python_version = [
        "python2.6",
        "python2.7",
        "python3.3",
        "python3.4",
        "python3.5",
        "python3.6",
    ]
    dir_path = os.path.dirname(SRC)
    for basename in os.listdir(os.path.join(dir_path, BIN_SCRIPTS)):
        for python_version in available_python_version:
            if python_version in basename:
                return python_version
    raise Exception("Can't find virtualenv python version!")
327168
def version(self, v):
        
        if not isinstance(v, int) or v != 1:
            raise AttributeError
        self._version = v
827503
def pip_version(self):
        """"""
        if not self._pip_exists:
            return None
        if not hasattr(self, '_pip_version'):
            # don't call `self._execute_pip` here as that method calls this one
            output = self._execute(self._pip + ['-V'], log=False).split()[1]
            self._pip_version = tuple([int(n) for n in output.split('.')])
        return self._pip_version
1355716
def get_version(version=None):
    

    if version[4] > 0:  # 0.2.1-alpha.1
        return "%s.%s.%s-%s.%s" % (version[0], version[1], version[2], version[3], version[4])
    elif version[3] != '':  # 0.2.1-alpha
        return "%s.%s.%s-%s" % (version[0], version[1], version[2], version[3])
    elif version[2] > 0:  # 0.2.1
        return "%s.%s.%s" % (version[0], version[1], version[2])
    else:  # 0.2
        return "%s.%s" % (version[0], version[1])
981926
def version():
    '''
    
    '''
    cmd = ['znc', '--version']
    out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
    ret = out[0].split(' - ')
    return ret[0]
822210
def get_setup_version(reponame):
    """"""
    # importing self into setup.py is unorthodox, but param has no
    # required dependencies outside of python
    from param.version import Version
    return Version.setup_version(os.path.dirname(__file__),reponame,archive_commit="$Format:%h$")
482330
def read_version():
    ""
    version_file = local_file('source', 'added_value', 'version.py')
    local_vars = {}
    with open(version_file) as handle:
        exec(handle.read(), {}, local_vars)  # pylint: disable=exec-used
    return local_vars['__version__']
604943
def get_versions():
    """"""
    # 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 keywords.

    cfg = get_config()
    verbose = cfg.verbose

    try:
        return git_versions_from_keywords(get_keywords(), cfg.tag_prefix,
                                          verbose)
    except NotThisMethod:
        pass

    root = os.path.realpath(__file__)

    root_dir = os.path.dirname(root)
    if os.path.isfile(os.path.join(root_dir, 'VERSION')):
        with open(os.path.join(root_dir, 'VERSION')) as vfile:
            version = vfile.readline().strip()

        return {
            "version": version,
            "full-revisionid": None,
            "dirty": None,
            "error": None,
            "date": None
        }

    try:
        # 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 cfg.versionfile_source.split('/'):
            root = os.path.dirname(root)
    except NameError:
        return {"version": "0+unknown", "full-revisionid": None,
                "dirty": None,
                "error": "unable to find root of source tree",
                "date": None}

    try:
        pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose)
        return render(pieces, cfg.style)
    except NotThisMethod:
        pass

    try:
        if cfg.parentdir_prefix:
            return versions_from_parentdir(cfg.parentdir_prefix, root, verbose)
    except NotThisMethod:
        pass

    return {"version": "0+unknown", "full-revisionid": None,
            "dirty": None,
            "error": "unable to compute version", "date": None}
815972
def is_in_virtualenv():
    

    pipenv_active = os.environ.get("PIPENV_ACTIVE", False)
    virtual_env = None
    use_system = False
    ignore_virtualenvs = bool(os.environ.get("PIPENV_IGNORE_VIRTUALENVS", False))

    if not pipenv_active and not ignore_virtualenvs:
        virtual_env = os.environ.get("VIRTUAL_ENV")
        use_system = bool(virtual_env)
    return (use_system or virtual_env) and not (pipenv_active or ignore_virtualenvs)
355209
def check_python_version():
    """"""
    python_major, python_minor = sys.version_info[:2]

    if python_major != 2 or python_minor != 7:
        sys.stderr.write("pyGenClean requires python 2.7")
        sys.exit(1)
888843
def detect_version(env, cc):
    """"""
    cc = env.subst(cc)
    if not cc:
        return None
    version = None
    #pipe = SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['-dumpversion'],
    pipe = SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['--version'],
                                 stdin = 'devnull',
                                 stderr = 'devnull',
                                 stdout = subprocess.PIPE)
    # -dumpversion was added in GCC 3.0.  As long as we're supporting
    # GCC versions older than that, we should use --version and a
    # regular expression.
    #line = pipe.stdout.read().strip()
    #if line:
    #    version = line
    line = SCons.Util.to_str(pipe.stdout.readline())
    match = re.search(r'[0-9]+(\.[0-9]+)+', line)
    if match:
        version = match.group(0)
    # Non-GNU compiler's output (like AIX xlc's) may exceed the stdout buffer:
    # So continue with reading to let the child process actually terminate.
    while SCons.Util.to_str(pipe.stdout.readline()):
        pass
    ret = pipe.wait()
    if ret != 0:
        return None
    return version
1312712
def getVersionNumber(self):
        """"""
        print '%s call getVersionNumber' % self.port
        versionStr = self.__sendCommand(WPANCTL_CMD + 'getprop -v NCP:Version')[0]

        return self.__stripValue(versionStr)
1034818
def read_version():
    """"""
    finder = VersionFinder()
    finder.visit(ast.parse(local_file('curdling', 'version.py')))
    return finder.version
428086
def _get_system_python_executable():
    
    # This function is required by get_package_as_folder() to work
    # inside a virtualenv, since venv creation will fail with
    # the virtualenv's local python binary.
    # (venv/virtualenv incompatibility)

    # Abort if not in virtualenv or venv:
    if not hasattr(sys, "real_prefix") and (
            not hasattr(sys, "base_prefix") or
            os.path.normpath(sys.base_prefix) ==
            os.path.normpath(sys.prefix)):
        return sys.executable

    # Extract prefix we need to look in:
    if hasattr(sys, "real_prefix"):
        search_prefix = sys.real_prefix  # virtualenv
    else:
        search_prefix = sys.base_prefix  # venv

    def python_binary_from_folder(path):
        def binary_is_usable(python_bin):
            try:
                filenotfounderror = FileNotFoundError
            except NameError:  # Python 2
                filenotfounderror = OSError
            try:
                subprocess.check_output([
                    os.path.join(path, python_bin), "--version"
                ], stderr=subprocess.STDOUT)
                return True
            except (subprocess.CalledProcessError, filenotfounderror):
                return False

        python_name = "python" + sys.version
        while (not binary_is_usable(python_name) and
               python_name.find(".") > 0):
            # Try less specific binary name:
            python_name = python_name.rpartition(".")[0]
        if binary_is_usable(python_name):
            return os.path.join(path, python_name)
        return None

    # Return from sys.real_prefix if present:
    result = python_binary_from_folder(search_prefix)
    if result is not None:
        return result

    # Check out all paths in $PATH:
    bad_candidates = []
    good_candidates = []
    ever_had_nonvenv_path = False
    for p in os.environ.get("PATH", "").split(":"):
        # Skip if not possibly the real system python:
        if not os.path.normpath(p).startswith(
                os.path.normpath(search_prefix)
                ):
            continue

        # First folders might be virtualenv/venv we want to avoid:
        if not ever_had_nonvenv_path:
            sep = os.path.sep
            if ("system32" not in p.lower() and "usr" not in p) or \
                    {"home", ".tox"}.intersection(set(p.split(sep))) or \
                    "users" in p.lower():
                # Doesn't look like bog-standard system path.
                if (p.endswith(os.path.sep + "bin") or
                        p.endswith(os.path.sep + "bin" + os.path.sep)):
                    # Also ends in "bin" -> likely virtualenv/venv.
                    # Add as unfavorable / end of candidates:
                    bad_candidates.append(p)
                    continue
            ever_had_nonvenv_path = True

        good_candidates.append(p)

    # See if we can now actually find the system python:
    for p in good_candidates + bad_candidates:
        result = python_binary_from_folder(p)
        if result is not None:
            return result

    raise RuntimeError("failed to locate system python in: " +
                       sys.real_prefix)
416214
def _check_virtualenv():
    
    from os import waitpid
    from subprocess import Popen, PIPE
    penvs = Popen("source /usr/local/bin/virtualenvwrapper.sh; workon",
                 shell=True, executable="/bin/bash", stdout=PIPE, stderr=PIPE)
    waitpid(penvs.pid, 0)
    envs = penvs.stdout.readlines()
    enverr = penvs.stderr.readlines()
    result = (settings.venv + '\n') in envs and len(enverr) == 0

    vms("Find virtualenv: {}".format(' '.join(envs).replace('\n', '')))
    vms("Find virtualenv | stderr: {}".format(' '.join(enverr)))
    
    if not result:
        info(envs)
        err("The virtualenv '{}' does not exist; can't use CI server.".format(settings.venv))
        if len(enverr) > 0:
            map(err, enverr)
    return result
699308
def get_version(cls):
        
        cmd_pieces = [cls.tool, '--version']
        process = Popen(cmd_pieces, stdout=PIPE, stderr=PIPE)
        out, err = process.communicate()
        if err:
            return ''
        else:
            return out.splitlines()[0].strip()
1266828
def python_versions(self):
        
        version_re = re.compile(r"""Programming Language \:\: Python \:\: \d\.\d""")
        return [c.split(' :: ')[-1] for c in self.classifiers
                if version_re.match(c)]