mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
resolve several issues in nu_conda and nu_msvs (#872)
1. fix: update `(sys).host` to `sys host` to work for 0.94.x 2. fix: handle incorrect behaviors when re-importing nu_conda or nu_msvs 3. doc: update minimum requirements of nushell in README.md
This commit is contained in:
parent
de2829091f
commit
d95857c119
4 changed files with 66 additions and 66 deletions
|
@ -3,7 +3,7 @@ A simple module for activating and deactivating Conda environments.
|
|||
|
||||
|
||||
## Prerequisites
|
||||
- [nushell](https://github.com/nushell/nushell) >= 0.83.0
|
||||
- [nushell](https://github.com/nushell/nushell) >= 0.94.0
|
||||
|
||||
|
||||
## Installation
|
||||
|
|
|
@ -1,30 +1,32 @@
|
|||
export-env {
|
||||
$env.CONDA_BASE_PATH = (if ((sys).host.name == "Windows") {$env.Path} else {$env.PATH})
|
||||
if not ("CONDA_CURR" in $env) {
|
||||
$env.CONDA_BASE_PATH = (if ((sys host).name == "Windows") {$env.Path} else {$env.PATH})
|
||||
|
||||
let info = (
|
||||
if not (which mamba | is-empty) {
|
||||
(mamba info --envs --json | from json)
|
||||
} else if not (which conda | is-empty) {
|
||||
(conda info --envs --json | from json)
|
||||
} else {
|
||||
('{"root_prefix": "", "envs": ""}' | from json)
|
||||
})
|
||||
let info = (
|
||||
if not (which mamba | is-empty) {
|
||||
(mamba info --envs --json | from json)
|
||||
} else if not (which conda | is-empty) {
|
||||
(conda info --envs --json | from json)
|
||||
} else {
|
||||
('{"root_prefix": "", "envs": ""}' | from json)
|
||||
})
|
||||
|
||||
$env.CONDA_ROOT = $info.root_prefix
|
||||
$env.CONDA_ROOT = $info.root_prefix
|
||||
|
||||
$env.CONDA_ENVS = ($info.envs | reduce -f {} {|it, acc|
|
||||
if $it == $info.root_prefix {
|
||||
$acc | upsert "base" $it
|
||||
} else {
|
||||
$acc | upsert ($it | path basename) $it
|
||||
}})
|
||||
$env.CONDA_ENVS = ($info.envs | reduce -f {} {|it, acc|
|
||||
if $it == $info.root_prefix {
|
||||
$acc | upsert "base" $it
|
||||
} else {
|
||||
$acc | upsert ($it | path basename) $it
|
||||
}})
|
||||
|
||||
$env.CONDA_CURR = null
|
||||
$env.CONDA_CURR = null
|
||||
}
|
||||
}
|
||||
|
||||
export def --env activate [name: string] {
|
||||
if ($env.CONDA_ROOT | is-empty) {
|
||||
print "Neither Conda nor Mamba is valid."
|
||||
print "Neither Conda nor Mamba is available."
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -35,7 +37,7 @@ export def --env activate [name: string] {
|
|||
}
|
||||
|
||||
let new_path = (
|
||||
if ((sys).host.name == "Windows") {
|
||||
if ((sys host).name == "Windows") {
|
||||
update-path-windows ($env.CONDA_ENVS | get $name)
|
||||
} else {
|
||||
update-path-linux ($env.CONDA_ENVS | get $name)
|
||||
|
@ -46,7 +48,7 @@ export def --env activate [name: string] {
|
|||
|
||||
export def --env deactivate [] {
|
||||
if ($env.CONDA_ROOT | is-empty) {
|
||||
print "Neither Conda nor Mamba is valid."
|
||||
print "Neither Conda nor Mamba is available."
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ A module for Using Microsoft Visual Studio (MSVS) command line tools from Nushel
|
|||
|
||||
|
||||
## Prerequisites
|
||||
- [nushell](https://github.com/nushell/nushell) >= 0.91.0
|
||||
- [nushell](https://github.com/nushell/nushell) >= 0.94.0
|
||||
- [vswhere](https://github.com/microsoft/vswhere) standalone or comes with VS
|
||||
|
||||
|
||||
|
|
|
@ -1,38 +1,42 @@
|
|||
export-env {
|
||||
$env.MSVS_BASE_PATH = $env.Path
|
||||
if not ("MSVS_ACTIVATED" in $env) {
|
||||
$env.MSVS_BASE_PATH = $env.Path
|
||||
|
||||
let info = (
|
||||
if not (which vswhere | is-empty) {
|
||||
(vswhere -format json | from json)
|
||||
} else {
|
||||
('{"installationPath": [""]}' | from json)
|
||||
}
|
||||
)
|
||||
let info = (
|
||||
if not (which vswhere | is-empty) {
|
||||
(vswhere -format json | from json)
|
||||
} else {
|
||||
('{"installationPath": [""]}' | from json)
|
||||
}
|
||||
)
|
||||
|
||||
$env.MSVS_ROOT = ($info.installationPath.0 | str replace -a '\\' '/')
|
||||
$env.MSVS_ROOT = ($info.installationPath.0 | str replace -a '\\' '/')
|
||||
|
||||
$env.MSVS_MSVC_ROOT = (
|
||||
if not ($"($env.MSVS_ROOT)/VC/Tools/MSVC/" | path exists) {
|
||||
""
|
||||
} else if (ls ($"($env.MSVS_ROOT)/VC/Tools/MSVC/*" | into glob) | is-empty) {
|
||||
""
|
||||
} else {
|
||||
((ls ($"($env.MSVS_ROOT)/VC/Tools/MSVC/*" | into glob)).name.0 | str replace -a '\\' '/')
|
||||
})
|
||||
$env.MSVS_MSVC_ROOT = (
|
||||
if not ($"($env.MSVS_ROOT)/VC/Tools/MSVC/" | path exists) {
|
||||
""
|
||||
} else if (ls ($"($env.MSVS_ROOT)/VC/Tools/MSVC/*" | into glob) | is-empty) {
|
||||
""
|
||||
} else {
|
||||
((ls ($"($env.MSVS_ROOT)/VC/Tools/MSVC/*" | into glob)).name.0 | str replace -a '\\' '/')
|
||||
})
|
||||
|
||||
$env.MSVS_MSDK_ROOT = (registry query --hklm 'SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder | get value)
|
||||
$env.MSVS_MSDK_ROOT = (registry query --hklm 'SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder | get value)
|
||||
|
||||
$env.MSVS_MSDK_VER = (registry query --hklm 'SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' ProductVersion | get value) + ".0"
|
||||
$env.MSVS_MSDK_VER = (registry query --hklm 'SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' ProductVersion | get value) + ".0"
|
||||
|
||||
$env.MSVS_INCLUDE_PATH = ([
|
||||
$"($env.MSVS_ROOT)/Include/($env.MSVS_MSDK_VER)/cppwinrt/winrt",
|
||||
$"($env.MSVS_MSVC_ROOT)/include",
|
||||
$"($env.MSVS_MSDK_ROOT)Include/($env.MSVS_MSDK_VER)/cppwinrt/winrt",
|
||||
$"($env.MSVS_MSDK_ROOT)Include/($env.MSVS_MSDK_VER)/shared",
|
||||
$"($env.MSVS_MSDK_ROOT)Include/($env.MSVS_MSDK_VER)/ucrt",
|
||||
$"($env.MSVS_MSDK_ROOT)Include/($env.MSVS_MSDK_VER)/um",
|
||||
$"($env.MSVS_MSDK_ROOT)Include/($env.MSVS_MSDK_VER)/winrt"
|
||||
] | str join ";")
|
||||
$env.MSVS_INCLUDE_PATH = ([
|
||||
$"($env.MSVS_ROOT)/Include/($env.MSVS_MSDK_VER)/cppwinrt/winrt",
|
||||
$"($env.MSVS_MSVC_ROOT)/include",
|
||||
$"($env.MSVS_MSDK_ROOT)Include/($env.MSVS_MSDK_VER)/cppwinrt/winrt",
|
||||
$"($env.MSVS_MSDK_ROOT)Include/($env.MSVS_MSDK_VER)/shared",
|
||||
$"($env.MSVS_MSDK_ROOT)Include/($env.MSVS_MSDK_VER)/ucrt",
|
||||
$"($env.MSVS_MSDK_ROOT)Include/($env.MSVS_MSDK_VER)/um",
|
||||
$"($env.MSVS_MSDK_ROOT)Include/($env.MSVS_MSDK_VER)/winrt"
|
||||
] | str join ";")
|
||||
|
||||
$env.MSVS_ACTIVATED = false
|
||||
}
|
||||
}
|
||||
|
||||
export def --env activate [
|
||||
|
@ -41,7 +45,7 @@ export def --env activate [
|
|||
--sdk (-s): string = "latest" # Version of Windows SDK, must be "latest" or a valid version string
|
||||
] {
|
||||
if (($env.MSVS_ROOT | is-empty) or ($env.MSVS_MSVC_ROOT | is-empty)) {
|
||||
print "Either Microsoft Visual Studio or MSVC is valid."
|
||||
print "Neither Microsoft Visual Studio nor MSVC is available."
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -125,17 +129,12 @@ export def --env activate [
|
|||
LIB: $lib_path
|
||||
}
|
||||
|
||||
hide-env MSVS_BASE_PATH
|
||||
hide-env MSVS_ROOT
|
||||
hide-env MSVS_MSVC_ROOT
|
||||
hide-env MSVS_MSDK_ROOT
|
||||
hide-env MSVS_MSDK_VER
|
||||
hide-env MSVS_INCLUDE_PATH
|
||||
$env.MSVS_ACTIVATED = true
|
||||
}
|
||||
|
||||
export def --env deactivate [] {
|
||||
if (($env.MSVS_ROOT | is-empty) or ($env.MSVS_MSVC_ROOT | is-empty)) {
|
||||
print "Either Microsoft Visual Studio or MSVC is valid."
|
||||
if (($env.MSVS_ROOT? | is-empty) or ($env.MSVS_MSVC_ROOT? | is-empty)) {
|
||||
print "Neither Microsoft Visual Studio nor MSVC is available."
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -144,6 +143,5 @@ export def --env deactivate [] {
|
|||
PATH: $env.MSVS_BASE_PATH
|
||||
}
|
||||
|
||||
hide-env INCLUDE
|
||||
hide-env LIB
|
||||
$env.MSVS_ACTIVATED = false
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue