1
Fork 0
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:
Hörmet Yiltiz 2023-06-17 02:25:30 -05:00 committed by GitHub
parent 0ca38a46f5
commit 1c19087afd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,