Skip to content

Commit

Permalink
Port before v0.60/virtual_environments (#849)
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
39555 committed May 26, 2024
1 parent 275a0f8 commit 840d723
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 142 deletions.
53 changes: 0 additions & 53 deletions before_v0.60/virtual_environments/README.md

This file was deleted.

45 changes: 0 additions & 45 deletions before_v0.60/virtual_environments/conda.nu

This file was deleted.

7 changes: 0 additions & 7 deletions before_v0.60/virtual_environments/conda_deactivate.nu

This file was deleted.

33 changes: 0 additions & 33 deletions before_v0.60/virtual_environments/venv.nu

This file was deleted.

4 changes: 0 additions & 4 deletions before_v0.60/virtual_environments/venv_deactivate.nu

This file was deleted.

25 changes: 25 additions & 0 deletions modules/virtual_environments/venv.nu
Original file line number Diff line number Diff line change
@@ -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

}

0 comments on commit 840d723

Please sign in to comment.