mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00:00
Fixed sys usage (#916)
Just as a heads up, I haven't really tested this since a lot of it is stuff I don't use or know how to set up without some reading up. I have tested the nu_conda_2 change since I have a python project that I use that for, and I could look into testing more of it if needed. I've tried finding (naively using `/sys\W/`) all the usage of the old plain `sys` calls and replacing them with alternates as appropriate, which mostly has been to swap a `(sys).host.name` call into a `$nu.os-info.name` one, since it'll be tad faster and more consistent across platforms with naming (especially as the value comes from the [rust stdlib](https://doc.rust-lang.org/std/env/consts/constant.OS.html) and is very predictable). Fixes #897
This commit is contained in:
parent
3b39ef75c9
commit
eedcd10dbb
9 changed files with 18 additions and 25 deletions
|
@ -28,8 +28,7 @@ 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 is_posix = ($nu.os-info.family == 'unix')
|
||||
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"
|
||||
|
|
|
@ -21,7 +21,7 @@ export def --env auto-venv-on-enter [
|
|||
let bin = ([$virtual_env, "bin"] | path join)
|
||||
let virtual_prompt = ""
|
||||
|
||||
let is_windows = ((sys).host.name | str downcase) == 'windows'
|
||||
let is_windows = $nu.os-info.name == 'windows'
|
||||
let path_name = if $is_windows {
|
||||
if (has-env 'Path') {
|
||||
'Path'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export-env {
|
||||
if not ("CONDA_CURR" in $env) {
|
||||
$env.CONDA_BASE_PATH = (if ((sys host).name == "Windows") {$env.Path} else {$env.PATH})
|
||||
$env.CONDA_BASE_PATH = (if $nu.os-info.name == 'windows' {$env.Path} else {$env.PATH})
|
||||
|
||||
let info = (
|
||||
if not (which mamba | is-empty) {
|
||||
|
@ -37,7 +37,7 @@ export def --env activate [name: string] {
|
|||
}
|
||||
|
||||
let new_path = (
|
||||
if ((sys host).name == "Windows") {
|
||||
if $nu.os-info.name == 'windows' {
|
||||
update-path-windows ($env.CONDA_ENVS | get $name)
|
||||
} else {
|
||||
update-path-linux ($env.CONDA_ENVS | get $name)
|
||||
|
|
|
@ -170,7 +170,7 @@ def conda-create-path-unix [env_dir: path] {
|
|||
}
|
||||
|
||||
def windows? [] {
|
||||
((sys).host.name | str downcase) == "windows"
|
||||
$nu.os-info.name == 'windows'
|
||||
}
|
||||
|
||||
def system-path [] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue