Beispiel #1
0
 def execute(self, command, **kwargs):
     self._install()
     env = kwargs.pop("env", {})
     env = " ".join(('%s="%s"' % (k, v) for k, v in env.items()))
     env = "%s " % env if env else ""
     return execute("%s%s/%s" % (env, self.script_directory, command),
                    **kwargs)
Beispiel #2
0
def install_virtualenv(virtualenv, directory):
    if not os.path.exists(os.path.join(directory, "bin/activate")):
        # stdout.write(format_command('Creating virtual environment'))
        if not os.path.exists(directory):
            os.makedirs(directory)

        execute("%s %s" % (virtualenv, directory))
        bin_directory = os.path.join(directory, "bin")
        execute("%s/%s" % (bin_directory, "pip install -U pip"))
        execute("%s/%s" % (bin_directory, "pip install -U setuptools"))
Beispiel #3
0
def install_runtime(version):
    if version == "system":
        # use system python version
        if "virtualenv" not in execute("pip list", capture=True):
            execute("pip install -U virtualenv")

    else:
        # use pyenv to manage versions
        install_pyenv_dependencies()
        versions = execute("pyenv versions", capture=True)
        root = get_runtime_root(version)

        if version not in versions:
            stdout.write(format_command("Installing", version))
            execute(
                'PYTHON_CONFIGURE_OPTS="--enable-shared" '
                "pyenv install %s" % version,
                verbose=True,
            )

        if "virtualenv" not in execute("%s/bin/pip list" % root, capture=True):
            execute("%s/bin/pip install -U virtualenv" % root)
Beispiel #4
0
def install_pyenv_dependencies(update=False):
    platform = get_platform_os()
    if platform == "Darwin":
        if not exists("brew"):
            stdout.write(format_command("Installing", "brew"))
            execute(
                'ruby -e "$(curl -fsSL '
                "https://raw.githubusercontent.com"
                "/Homebrew/install/master/install",
                verbose=True,
            )
        elif update:
            stdout.write(format_command("Updating", "brew"))
            execute("brew update", verbose=True)

        if not exists("pyenv"):
            stdout.write(format_command("Installing", "pyenv"))
            execute("brew install pyenv", verbose=True)
        elif update:
            stdout.write(format_command("Updating", "pyenv"))
            execute("brew install --upgrade pyenv", verbose=True)
    elif platform == "Linux":
        if not exists("curl"):
            stdout.write(format_command("Installing", "curl"))
            execute("sudo apt-get install curl")
        if not exists("pyenv"):
            stdout.write(format_command("Installing", "pyenv"))
            execute("curl -L "
                    "https://github.com/pyenv/pyenv-installer/"
                    "raw/master/bin/pyenv-installer"
                    "| bash")
        elif update:
            stdout.write(format_command("Updating", "pyenv"))
            execute("pyenv update", verbose=True)
Beispiel #5
0
def get_major_system_version():
    version = execute("python -V", capture=True).split(" ")[-1]
    return get_major_version(version)