Skip to content

Commit 1b5afa0

Browse files
committed
Adapt to possibly using micromamba.
1 parent d31db2d commit 1b5afa0

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

src/main/java/fiji/plugin/trackmate/cellpose/CellposeDetector.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
* it under the terms of the GNU General Public License as
99
* published by the Free Software Foundation, either version 3 of the
1010
* License, or (at your option) any later version.
11-
*
11+
*
1212
* This program is distributed in the hope that it will be useful,
1313
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1414
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515
* GNU General Public License for more details.
16-
*
16+
*
1717
* You should have received a copy of the GNU General Public
1818
* License along with this program. If not, see
1919
* <http://www.gnu.org/licenses/gpl-3.0.html>.
@@ -34,6 +34,7 @@
3434
import java.nio.file.Paths;
3535
import java.time.Duration;
3636
import java.util.ArrayList;
37+
import java.util.HashMap;
3738
import java.util.Iterator;
3839
import java.util.List;
3940
import java.util.Map;
@@ -540,6 +541,13 @@ public String call() throws Exception
540541
{
541542
final ProcessBuilder pbOmni = new ProcessBuilder( cmd );
542543
pbOmni.redirectErrorStream( true );
544+
// Env variables.
545+
final Map< String, String > env = new HashMap<>();
546+
final String condaRootPrefix = CLIUtils.getCondaRootPrefix();
547+
env.put( "MAMBA_ROOT_PREFIX", condaRootPrefix );
548+
env.put( "CONDA_ROOT_PREFIX", condaRootPrefix );
549+
pbOmni.environment().putAll( env );
550+
543551
process = pbOmni.start();
544552

545553
final BufferedReader reader = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
@@ -575,6 +583,7 @@ public String call() throws Exception
575583
final ProcessBuilder updatedPbOmni = new ProcessBuilder( cmd2 );
576584
updatedPbOmni.redirectOutput( ProcessBuilder.Redirect.INHERIT );
577585
updatedPbOmni.redirectError( ProcessBuilder.Redirect.INHERIT );
586+
updatedPbOmni.environment().putAll( env );
578587

579588
process = updatedPbOmni.start();
580589
process.waitFor();
@@ -589,6 +598,12 @@ else if ( pythonErrorOutput.contains( "pretrained model has incorrect path" ) )
589598
final ProcessBuilder pb = new ProcessBuilder( cmd );
590599
pb.redirectOutput( ProcessBuilder.Redirect.INHERIT );
591600
pb.redirectError( ProcessBuilder.Redirect.INHERIT );
601+
// Env variables.
602+
final Map< String, String > env = new HashMap<>();
603+
final String condaRootPrefix = CLIUtils.getCondaRootPrefix();
604+
env.put( "MAMBA_ROOT_PREFIX", condaRootPrefix );
605+
env.put( "CONDA_ROOT_PREFIX", condaRootPrefix );
606+
pb.environment().putAll( env );
592607

593608
process = pb.start();
594609
process.waitFor();

src/main/java/fiji/plugin/trackmate/cellpose/sam/CellposeSAMDetector.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
* it under the terms of the GNU General Public License as
99
* published by the Free Software Foundation, either version 3 of the
1010
* License, or (at your option) any later version.
11-
*
11+
*
1212
* This program is distributed in the hope that it will be useful,
1313
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1414
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515
* GNU General Public License for more details.
16-
*
16+
*
1717
* You should have received a copy of the GNU General Public
1818
* License along with this program. If not, see
1919
* <http://www.gnu.org/licenses/gpl-3.0.html>.
@@ -32,6 +32,7 @@
3232
import java.nio.file.Paths;
3333
import java.time.Duration;
3434
import java.util.ArrayList;
35+
import java.util.HashMap;
3536
import java.util.Iterator;
3637
import java.util.List;
3738
import java.util.Map;
@@ -510,6 +511,12 @@ public String call() throws Exception
510511
final ProcessBuilder pb = new ProcessBuilder( cmd );
511512
pb.redirectOutput( ProcessBuilder.Redirect.INHERIT );
512513
pb.redirectError( ProcessBuilder.Redirect.INHERIT );
514+
// Env variables.
515+
final Map< String, String > env = new HashMap<>();
516+
final String condaRootPrefix = CLIUtils.getCondaRootPrefix();
517+
env.put( "MAMBA_ROOT_PREFIX", condaRootPrefix );
518+
env.put( "CONDA_ROOT_PREFIX", condaRootPrefix );
519+
pb.environment().putAll( env );
513520

514521
process = pb.start();
515522
process.waitFor();

0 commit comments

Comments
 (0)