mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
Convenience wrapper for venv creation (#514)
* auto-venv python passes syntax checks * update readme.md * everything works! * convenience wrapper for venv creation * respond to feedback and (try to) be cross-platform compatible * use external command
This commit is contained in:
parent
0ca38a46f5
commit
1c19087afd
1 changed files with 14 additions and 0 deletions
|
@ -23,6 +23,20 @@ export def venv-is-active [] {
|
|||
'__auto_venv' in (overlay list)
|
||||
}
|
||||
|
||||
# Creates a virtual environment under the current directory
|
||||
export def 'venv-create' [] {
|
||||
let venv_path = $env.PWD
|
||||
let venv_name = ($env.PWD | path basename)
|
||||
|
||||
let sys_posix = ['darwin', 'linux', 'unix', 'posix', 'gnu']
|
||||
let is_posix = (((sys).host.name | str downcase) in $sys_posix)
|
||||
let python_name = if $is_posix {'python3'} else {'py.exe'}
|
||||
run-external $python_name "-m" "venv" ".venv" "--clear" "--prompt" $venv_name
|
||||
run-external $".venv/bin/($python_name)" "-m" "pip" "install" "-U" "pip" "wheel" "setuptools"
|
||||
|
||||
let trigger_file = ([$env.PWD, $env.AUTO_VENV_TRIGGER] | path join)
|
||||
ln -sf $'($env.FILE_PWD)/venvs/python-venv.nu' $trigger_file
|
||||
}
|
||||
|
||||
export def has-entered-venv [
|
||||
after: path,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue