def get_env_patch( venv: str, language_version: str, ) -> PatchesT: patches: PatchesT = ( ('GEM_HOME', os.path.join(venv, 'gems')), ('GEM_PATH', UNSET), ('BUNDLE_IGNORE_CONFIG', '1'), ) if language_version == 'system': patches += ( ( 'PATH', ( os.path.join(venv, 'gems', 'bin'), os.pathsep, Var('PATH'), ), ), ) else: # pragma: win32 no cover patches += ( ('RBENV_ROOT', venv), ( 'PATH', ( os.path.join(venv, 'gems', 'bin'), os.pathsep, os.path.join(venv, 'shims'), os.pathsep, os.path.join(venv, 'bin'), os.pathsep, Var('PATH'), ), ), ) if language_version not in {'system', 'default'}: # pragma: win32 no cover patches += (('RBENV_VERSION', language_version),) return patches
def get_env_patch(venv: str) -> PatchesT: return ( ('PIP_DISABLE_PIP_VERSION_CHECK', '1'), ('PYTHONHOME', UNSET), ('VIRTUAL_ENV', venv), ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))), )
def get_env_patch(target_dir): return ( ( 'PATH', (os.path.join(target_dir, 'bin'), os.pathsep, Var('PATH')), ), )
def get_env_patch(venv: str) -> PatchesT: return ( ("PIP_DISABLE_PIP_VERSION_CHECK", "1"), ("PYTHONHOME", UNSET), ("VIRTUAL_ENV", venv), ("PATH", (bin_dir(venv), os.pathsep, Var("PATH"))), )
def get_env_patch( venv: str, language_version: str, ) -> PatchesT: # pragma: win32 no cover patches: PatchesT = ( ("GEM_HOME", os.path.join(venv, "gems")), ("GEM_PATH", UNSET), ("RBENV_ROOT", venv), ("BUNDLE_IGNORE_CONFIG", "1"), ( "PATH", ( os.path.join(venv, "gems", "bin"), os.pathsep, os.path.join(venv, "shims"), os.pathsep, os.path.join(venv, "bin"), os.pathsep, Var("PATH"), ), ), ) if language_version != C.DEFAULT: patches += (("RBENV_VERSION", language_version), ) return patches
def get_env_patch(venv): return ( ('NODE_VIRTUAL_ENV', venv), ('NPM_CONFIG_PREFIX', venv), ('npm_config_prefix', venv), ('NODE_PATH', os.path.join(venv, 'lib', 'node_modules')), ('PATH', (os.path.join(venv, 'bin'), os.pathsep, Var('PATH'))), )
def get_env_patch(venv): # pragma: windows no cover config = os.path.join(venv, 'bin') if sys.platform == 'cygwin' else venv return ( ('NODE_VIRTUAL_ENV', venv), ('NPM_CONFIG_PREFIX', config), ('npm_config_prefix', config), ('NODE_PATH', os.path.join(venv, 'lib', 'node_modules')), ('PATH', (os.path.join(venv, 'bin'), os.pathsep, Var('PATH'))), )
def get_env_patch(venv: str) -> PatchesT: return ( ('PATH', (os.path.join(venv, 'bin'), os.pathsep, Var('PATH'))), ('PERL5LIB', os.path.join(venv, 'lib', 'perl5')), ('PERL_MB_OPT', f'--install_base {shlex.quote(venv)}'), ( 'PERL_MM_OPT', (f'INSTALL_BASE={shlex.quote(venv)} ' f'INSTALLSITEMAN1DIR=none INSTALLSITEMAN3DIR=none'), ), )
def get_env_patch(venv: str) -> PatchesT: return ( ("PATH", (os.path.join(venv, "bin"), os.pathsep, Var("PATH"))), ("PERL5LIB", os.path.join(venv, "lib", "perl5")), ("PERL_MB_OPT", f"--install_base {shlex.quote(venv)}"), ( "PERL_MM_OPT", (f"INSTALL_BASE={shlex.quote(venv)} " f"INSTALLSITEMAN1DIR=none INSTALLSITEMAN3DIR=none"), ), )
def test_templated_environ_sources_from_previous(): _test( before={'foo': 'bar'}, patch=( ('foo', 'baz'), ('herp', ('foo: ', Var('foo'))), ), expected={ 'foo': 'baz', 'herp': 'foo: bar' }, )
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()) 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', (os.path.join(venv, 'bin'), os.pathsep, Var('PATH'))), )
def get_env_patch(venv, language_version): patches = ( ('GEM_HOME', os.path.join(venv, 'gems')), ('RBENV_ROOT', venv), ('PATH', ( os.path.join(venv, 'gems', 'bin'), os.pathsep, os.path.join(venv, 'shims'), os.pathsep, os.path.join(venv, 'bin'), os.pathsep, Var('PATH'), )), ) if language_version != 'default': patches += (('RBENV_VERSION', language_version),) return patches
def get_env_patch(venv, language_version): # pragma: windows no cover patches = ( ('GEM_HOME', os.path.join(venv, 'gems')), ('RBENV_ROOT', venv), ('BUNDLE_IGNORE_CONFIG', '1'), ( 'PATH', ( os.path.join(venv, 'gems', 'bin'), os.pathsep, os.path.join(venv, 'shims'), os.pathsep, os.path.join(venv, 'bin'), os.pathsep, Var('PATH'), ), ), ) if language_version != 'default': patches += (('RBENV_VERSION', language_version),) return patches
def get_env_patch(d: str) -> PatchesT: # pragma: win32 no cover version = _get_lua_version() so_ext = 'dll' if sys.platform == 'win32' else 'so' return ( ('PATH', (os.path.join(d, 'bin'), os.pathsep, Var('PATH'))), ( 'LUA_PATH', ( os.path.join(d, 'share', 'lua', version, '?.lua;'), os.path.join(d, 'share', 'lua', version, '?', 'init.lua;;'), ), ), ( 'LUA_CPATH', (os.path.join(d, 'lib', 'lua', version, f'?.{so_ext};;'),), ), )
def get_env_patch(env: str) -> PatchesT: # On non-windows systems executable live in $CONDA_PREFIX/bin, on Windows # they can be in $CONDA_PREFIX/bin, $CONDA_PREFIX/Library/bin, # $CONDA_PREFIX/Scripts and $CONDA_PREFIX. Whereas the latter only # seems to be used for python.exe. path: SubstitutionT = (os.path.join(env, 'bin'), os.pathsep, Var('PATH')) if os.name == 'nt': # pragma: no cover (platform specific) path = (env, os.pathsep, *path) path = (os.path.join(env, 'Scripts'), os.pathsep, *path) path = (os.path.join(env, 'Library', 'bin'), os.pathsep, *path) return ( ('PYTHONHOME', UNSET), ('VIRTUAL_ENV', UNSET), ('CONDA_PREFIX', env), ('PATH', path), )
def get_env_patch(env: str) -> PatchesT: # On non-windows systems executable live in $CONDA_PREFIX/bin, on Windows # they can be in $CONDA_PREFIX/bin, $CONDA_PREFIX/Library/bin, # $CONDA_PREFIX/Scripts and $CONDA_PREFIX. Whereas the latter only # seems to be used for python.exe. path: SubstitutionT = (os.path.join(env, "bin"), os.pathsep, Var("PATH")) if os.name == "nt": # pragma: no cover (platform specific) path = (env, os.pathsep, *path) path = (os.path.join(env, "Scripts"), os.pathsep, *path) path = (os.path.join(env, "Library", "bin"), os.pathsep, *path) return ( ("PYTHONHOME", UNSET), ("VIRTUAL_ENV", UNSET), ("CONDA_PREFIX", env), ("PATH", path), )
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"))), )
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'))), )
def get_env_patch( venv: str, language_version: str, ) -> PatchesT: # pragma: win32 no cover patches: PatchesT = ( ('GEM_HOME', os.path.join(venv, 'gems')), ('RBENV_ROOT', venv), ('BUNDLE_IGNORE_CONFIG', '1'), ( 'PATH', ( os.path.join(venv, 'gems', 'bin'), os.pathsep, os.path.join(venv, 'shims'), os.pathsep, os.path.join(venv, 'bin'), os.pathsep, Var('PATH'), ), ), ) if language_version != C.DEFAULT: patches += (('RBENV_VERSION', language_version), ) return patches
def get_env_patch(target_dir: str) -> PatchesT: return (("PATH", (os.path.join(target_dir, "bin"), os.pathsep, Var("PATH"))), )
def get_env_patch(venv): return ( ('PATH', (os.path.join(venv, 'bin'), os.pathsep, Var('PATH'))), )
def get_env_patch(venv): # pragma: windows no cover bin_path = os.path.join(venv, BUILD_DIR, BUILD_CONFIG) return (('PATH', (bin_path, os.pathsep, Var('PATH'))),)
def get_env_patch(target_dir: str) -> PatchesT: return ( ('PATH', (os.path.join(target_dir, 'bin'), os.pathsep, Var('PATH'))), )
def bin_on_path(): bindir = os.path.join(os.getcwd(), 'bin') with envcontext((('PATH', (bindir, os.pathsep, Var('PATH'))),)): yield
def test_templated_environment_variable_there(): _test( before={'PATH': '/usr/local/bin:/usr/bin'}, patch=[('PATH', ('~/bin:', Var('PATH')))], expected={'PATH': '~/bin:/usr/local/bin:/usr/bin'}, )
def test_templated_environment_variable_defaults(): _test( before={}, patch=[('PATH', ('~/bin:', Var('PATH', default='/bin')))], expected={'PATH': '~/bin:/bin'}, )
def test_templated_environment_variable_missing(): _test( before={}, patch=[('PATH', ('~/bin:', Var('PATH')))], expected={'PATH': '~/bin:'}, )
def get_env_patch(target_dir: str) -> PatchesT: # pragma: win32 no cover return ( ('PATH', (target_dir, os.pathsep, Var('PATH'))), )
def get_env_patch(venv: str) -> PatchesT: return (("PATH", (os.path.join(venv, "bin"), os.pathsep, Var("PATH"))), )
def get_env_patch(venv): return ( ('PYTHONHOME', UNSET), ('VIRTUAL_ENV', venv), ('PATH', (bin_dir(venv), os.pathsep, Var('PATH'))), )