Ejemplo n.º 1
0
def get_env_patch(venv):  # pragma: windows no cover
    if sys.platform == 'cygwin':  # pragma: no cover
        _, win_venv, _ = cmd_output('cygpath', '-w', venv)
        install_prefix = r'{}\bin'.format(win_venv.strip())
    elif sys.platform == 'win32':  # pragma: no cover
        install_prefix = bin_dir(venv)
    else:  # pragma: windows no cover
        install_prefix = venv
    return (
        ('NODE_VIRTUAL_ENV', venv),
        ('NPM_CONFIG_PREFIX', install_prefix),
        ('npm_config_prefix', install_prefix),
        ('NODE_PATH', os.path.join(venv, 'lib', 'node_modules')),
        ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))),
    )
Ejemplo n.º 2
0
def get_env_patch(venv):
    if sys.platform == 'cygwin':  # pragma: no cover
        _, win_venv, _ = cmd_output('cygpath', '-w', venv)
        install_prefix = r'{}\bin'.format(win_venv.strip())
    elif sys.platform == 'win32':  # pragma: no cover
        install_prefix = bin_dir(venv)
    else:
        install_prefix = venv
    return (
        ('NODE_VIRTUAL_ENV', venv),
        ('NPM_CONFIG_PREFIX', install_prefix),
        ('npm_config_prefix', install_prefix),
        ('NODE_PATH', os.path.join(venv, 'lib', 'node_modules')),
        ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))),
    )
Ejemplo n.º 3
0
def test_unhealthy_then_replaced(python_dir):
    prefix, tmpdir = python_dir

    python.install_environment(prefix, C.DEFAULT, ())

    # simulate an exe which returns an old version
    exe_name = win_exe('python')
    py_exe = prefix.path(python.bin_dir('py_env-default'), exe_name)
    os.rename(py_exe, f'{py_exe}.tmp')

    with open(py_exe, 'w') as f:
        f.write('#!/usr/bin/env bash\necho 1.2.3\n')
    make_executable(py_exe)

    # should be unhealthy due to version mismatch
    ret = python.health_check(prefix, C.DEFAULT)
    assert ret == (
        f'virtualenv python version did not match created version:\n'
        f'- actual version: 1.2.3\n'
        f'- expected version: {python._version_info(sys.executable)}\n')

    # now put the exe back and it should be healthy again
    os.replace(f'{py_exe}.tmp', py_exe)

    assert python.health_check(prefix, C.DEFAULT) is None
Ejemplo n.º 4
0
def get_env_patch(venv: str) -> PatchesT:
    if sys.platform == 'cygwin':  # pragma: no cover
        _, win_venv, _ = cmd_output('cygpath', '-w', venv)
        install_prefix = fr'{win_venv.strip()}\bin'
        lib_dir = 'lib'
    elif sys.platform == 'win32':  # pragma: no cover
        install_prefix = bin_dir(venv)
        lib_dir = 'Scripts'
    else:  # pragma: win32 no cover
        install_prefix = venv
        lib_dir = 'lib'
    return (
        ('NODE_VIRTUAL_ENV', venv),
        ('NPM_CONFIG_PREFIX', install_prefix),
        ('npm_config_prefix', install_prefix),
        ('NODE_PATH', os.path.join(venv, lib_dir, 'node_modules')),
        ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))),
    )
Ejemplo n.º 5
0
def get_env_patch(venv: str) -> PatchesT:
    if sys.platform == "cygwin":  # pragma: no cover
        _, win_venv, _ = cmd_output("cygpath", "-w", venv)
        install_prefix = fr"{win_venv.strip()}\bin"
        lib_dir = "lib"
    elif sys.platform == "win32":  # pragma: no cover
        install_prefix = bin_dir(venv)
        lib_dir = "Scripts"
    else:  # pragma: win32 no cover
        install_prefix = venv
        lib_dir = "lib"
    return (
        ("NODE_VIRTUAL_ENV", venv),
        ("NPM_CONFIG_PREFIX", install_prefix),
        ("npm_config_prefix", install_prefix),
        ("NODE_PATH", os.path.join(venv, lib_dir, "node_modules")),
        ("PATH", (bin_dir(venv), os.pathsep, Var("PATH"))),
    )
Ejemplo n.º 6
0
def test_unhealthy_python_goes_missing(python_dir):
    prefix, tmpdir = python_dir

    python.install_environment(prefix, C.DEFAULT, ())

    exe_name = 'python' if sys.platform != 'win32' else 'python.exe'
    py_exe = prefix.path(python.bin_dir('py_env-default'), exe_name)
    os.remove(py_exe)

    assert python.healthy(prefix, C.DEFAULT) is False
Ejemplo n.º 7
0
def test_unhealthy_python_goes_missing(python_dir):
    prefix, tmpdir = python_dir

    python.install_environment(prefix, C.DEFAULT, ())

    exe_name = win_exe('python')
    py_exe = prefix.path(python.bin_dir('py_env-default'), exe_name)
    os.remove(py_exe)

    ret = python.health_check(prefix, C.DEFAULT)
    assert ret == (
        f'virtualenv python version did not match created version:\n'
        f'- actual version: <<error retrieving version from {py_exe}>>\n'
        f'- expected version: {python._version_info(sys.executable)}\n')
Ejemplo n.º 8
0
def test_unhealthy_then_replaced(python_dir):
    prefix, tmpdir = python_dir

    python.install_environment(prefix, C.DEFAULT, ())

    # simulate an exe which returns an old version
    exe_name = 'python.exe' if sys.platform == 'win32' else 'python'
    py_exe = prefix.path(python.bin_dir('py_env-default'), exe_name)
    os.rename(py_exe, f'{py_exe}.tmp')

    with open(py_exe, 'w') as f:
        f.write('#!/usr/bin/env bash\necho 1.2.3\n')
    make_executable(py_exe)

    # should be unhealthy due to version mismatch
    assert python.healthy(prefix, C.DEFAULT) is False

    # now put the exe back and it should be healthy again
    os.replace(f'{py_exe}.tmp', py_exe)

    assert python.healthy(prefix, C.DEFAULT) is True