| 38 | |
| 39 | |
| 40 | def get_env_patch( |
| 41 | venv: str, |
| 42 | language_version: str, |
| 43 | ) -> PatchesT: |
| 44 | patches: PatchesT = ( |
| 45 | ('GEM_HOME', os.path.join(venv, 'gems')), |
| 46 | ('GEM_PATH', UNSET), |
| 47 | ('BUNDLE_IGNORE_CONFIG', '1'), |
| 48 | ) |
| 49 | if language_version == 'system': |
| 50 | patches += ( |
| 51 | ( |
| 52 | 'PATH', ( |
| 53 | os.path.join(venv, 'gems', 'bin'), os.pathsep, |
| 54 | Var('PATH'), |
| 55 | ), |
| 56 | ), |
| 57 | ) |
| 58 | else: # pragma: win32 no cover |
| 59 | patches += ( |
| 60 | ('RBENV_ROOT', venv), |
| 61 | ( |
| 62 | 'PATH', ( |
| 63 | os.path.join(venv, 'gems', 'bin'), os.pathsep, |
| 64 | os.path.join(venv, 'shims'), os.pathsep, |
| 65 | os.path.join(venv, 'bin'), os.pathsep, Var('PATH'), |
| 66 | ), |
| 67 | ), |
| 68 | ) |
| 69 | if language_version not in {'system', 'default'}: # pragma: win32 no cover |
| 70 | patches += (('RBENV_VERSION', language_version),) |
| 71 | |
| 72 | return patches |
| 73 | |
| 74 | |
| 75 | @contextlib.contextmanager |