mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
Port before v0.60/virtual_environments
(#849)
This PR is part of porting all old scripts #221 and includes the `virtual_environments` module ## 5 files changed - `conda.nu`: removed, already in `modules/virtual_enviromnents/conda/nu_conda.nu` - `conda_deactivate.nu`: also removed, has already been merged with `nu_conda.nu` - `README.nu`: removed, similar info in `modules/virtual_enviromnents/README.md` - `venv.nu`: ported to `modules/virtual_enviromnents/venv/venv.nu` - `venv_deactivate.nu`: ported to `modules/virtual_enviromnents/venv/venv_deactivate.nu`
This commit is contained in:
parent
275a0f8f26
commit
840d723d89
6 changed files with 25 additions and 142 deletions
25
modules/virtual_environments/venv.nu
Normal file
25
modules/virtual_environments/venv.nu
Normal file
|
@ -0,0 +1,25 @@
|
|||
export def --env activate [venv_dir] {
|
||||
let venv_abs_dir = ($venv_dir | path expand)
|
||||
let venv_name = ($venv_abs_dir | path basename)
|
||||
let old_path = $env.PATH
|
||||
let new_path = (venv-path $venv_abs_dir)
|
||||
let new_env = ({VENV_OLD_PATH: $old_path, VIRTUAL_ENV: $venv_name} | merge $new_path)
|
||||
load-env $new_env
|
||||
}
|
||||
|
||||
def "venv-path" [venv_dir] {
|
||||
let env_path = [
|
||||
$venv_dir,
|
||||
([$venv_dir, "bin"] | path join)
|
||||
]
|
||||
return {
|
||||
PATH: ($env.PATH | prepend $env_path)
|
||||
}
|
||||
}
|
||||
|
||||
export def --env deactivate [] {
|
||||
$env.PATH = $env.VENV_OLD_PATH
|
||||
hide-env VIRTUAL_ENV
|
||||
hide-env VENV_OLD_PATH
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue