@@ -65,59 +65,59 @@ a shortcut on your own desktop for testing.
6565# ---------------------------------------------------------------------------
6666# 1. Resolve the conda environment
6767# ---------------------------------------------------------------------------
68+ # Search every plausible location and accept the first one that actually
69+ # contains the installed exe. This handles three common situations:
70+ # a. -CondaEnvPath was passed explicitly
71+ # b. $env:CONDA_PREFIX points to the named env (conda was activated)
72+ # c. $env:CONDA_PREFIX points to the base installation (base env active)
73+ # d. conda is not on PATH at all in this PowerShell session
74+
75+ $candidates = [System.Collections.Generic.List [string ]]::new()
76+
77+ # Explicit argument takes priority
78+ if ($CondaEnvPath ) { $candidates.Add ($CondaEnvPath ) }
79+
80+ # CONDA_PREFIX: try both the value itself and its envs\picasso-workflow child
81+ if ($env: CONDA_PREFIX ) {
82+ $candidates.Add ($env: CONDA_PREFIX )
83+ $candidates.Add (" $env: CONDA_PREFIX \envs\picasso-workflow" )
84+ }
6885
69- # Use $env:CONDA_PREFIX if conda is initialised for this PS session,
70- # otherwise search well-known installation directories automatically.
71- if (-not $CondaEnvPath ) { $CondaEnvPath = $env: CONDA_PREFIX }
86+ # Well-known installation directories
87+ foreach ($base in @ (
88+ " $env: USERPROFILE \miniconda3" ,
89+ " $env: USERPROFILE \anaconda3" ,
90+ " $env: USERPROFILE \AppData\Local\miniconda3" ,
91+ " $env: USERPROFILE \AppData\Local\anaconda3" ,
92+ " C:\ProgramData\Miniconda3" ,
93+ " C:\ProgramData\Anaconda3"
94+ )) {
95+ $candidates.Add (" $base \envs\picasso-workflow" )
96+ }
7297
73- if (-not $CondaEnvPath ) {
74- $candidates = @ (
75- " $env: USERPROFILE \miniconda3\envs\picasso-workflow" ,
76- " $env: USERPROFILE \anaconda3\envs\picasso-workflow" ,
77- " $env: USERPROFILE \AppData\Local\miniconda3\envs\picasso-workflow" ,
78- " $env: USERPROFILE \AppData\Local\anaconda3\envs\picasso-workflow" ,
79- " C:\ProgramData\Miniconda3\envs\picasso-workflow" ,
80- " C:\ProgramData\Anaconda3\envs\picasso-workflow"
81- )
82- foreach ($c in $candidates ) {
83- if (Test-Path " $c \Scripts\picasso-workflow-gui.exe" ) {
84- $CondaEnvPath = $c
85- Write-Host " Auto-detected conda environment: $CondaEnvPath "
86- break
87- }
98+ $CondaEnvPath = " "
99+ foreach ($c in $candidates ) {
100+ if (Test-Path " $c \Scripts\picasso-workflow-gui.exe" ) {
101+ $CondaEnvPath = $c
102+ Write-Host " Found conda environment: $CondaEnvPath "
103+ break
88104 }
89105}
90106
91107if (-not $CondaEnvPath ) {
92108 Write-Error @"
93- Could not find the picasso-workflow conda environment .
94- Pass the path explicitly:
109+ Could not find picasso-workflow-gui.exe in any known location .
110+ Make sure the package is installed, then pass the env path explicitly:
95111 .\deploy_gui_shortcut.ps1 -CondaEnvPath "C:\...\envs\picasso-workflow"
96112"@
97113 exit 1
98114}
99115
100- if (-not (Test-Path $CondaEnvPath )) {
101- Write-Error " Conda environment path not found: $CondaEnvPath "
102- exit 1
103- }
104-
105116# ---------------------------------------------------------------------------
106- # 2. Find the GUI executable created by the gui-scripts entry point
117+ # 2. Build the exe path (already verified to exist by the search above)
107118# ---------------------------------------------------------------------------
108119$ExePath = Join-Path $CondaEnvPath " Scripts\picasso-workflow-gui.exe"
109120
110- if (-not (Test-Path $ExePath )) {
111- Write-Error @"
112- Executable not found: $ExePath
113-
114- Make sure the package is installed in this environment:
115- conda activate picasso-workflow
116- pip install -e C:\path\to\picasso-workflow
117- "@
118- exit 1
119- }
120-
121121# ---------------------------------------------------------------------------
122122# 3. Locate the icon installed with the package
123123# ---------------------------------------------------------------------------
0 commit comments