Esempio n. 1
0
def _proc_python_exe(python_requires):
    if not python_requires:
        return sys.executable
    matching = util.find_python_interpreter(python_requires)
    if not matching:
        _op_cmd_error("cannot find a python interpreter for "
                      "requirement %r" % python_requires)
    path, _ver = matching
    return path
Esempio n. 2
0
def _python_exe(opdef):
    req = opdef.python_requires or opdef.modeldef.python_requires
    if req:
        matching = util.find_python_interpreter(req)
        if not matching:
            raise OpInitError("cannot find a python interpreter for "
                              "version requirement %r" % req)
        path, _ver = matching
        return path
    return sys.executable
Esempio n. 3
0
def _suggest_python_interpreter(user_reqs):
    """Returns best guess Python interpreter.

    We look for a Python requirement in two places: a package def in
    cwd Guild file and user requirements, which includes
    requirements.txt by default.

    A Python spec can be provided in a requirements file using a
    special `python<spec>` comment. E.g. `python>=3.5`.
    """
    python_requires = util.find_apply(
        [_python_requires_for_pkg, lambda: _python_requires_for_reqs(user_reqs),]
    )
    if not python_requires:
        return None
    matching = util.find_python_interpreter(python_requires)
    if matching:
        _path, ver = matching
        return "python%s" % ver
    return None