From 4717b6b8892a327a6fe7f4b37985acf1dfd7dc30 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Mon, 1 Apr 2019 18:54:11 +0300 Subject: [PATCH] set path to fix tox test --- .../testSrc/com/jetbrains/env/PyToxTest.java | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/python/testSrc/com/jetbrains/env/PyToxTest.java b/python/testSrc/com/jetbrains/env/PyToxTest.java index 08a5f106a719..19eb2bd493d5 100644 --- a/python/testSrc/com/jetbrains/env/PyToxTest.java +++ b/python/testSrc/com/jetbrains/env/PyToxTest.java @@ -445,32 +445,35 @@ public final class PyToxTest extends PyEnvTestCase { @Override protected void configurationCreatedAndWillLaunch(@NotNull PyToxConfiguration configuration) throws IOException { super.configurationCreatedAndWillLaunch(configuration); + fixPathForTox(configuration); + } + } - // To help tox with all interpreters, we add all our environments to path - // Envs should have binaries like "python2.7" (with version included), - // and tox will find em: see tox_get_python_executable @ interpreters.py + private static void fixPathForTox(final @NotNull PyToxConfiguration configuration) { + // To help tox with all interpreters, we add all our environments to path + // Envs should have binaries like "python2.7" (with version included), + // and tox will find em: see tox_get_python_executable @ interpreters.py - //On linux we also need shared libs from Anaconda, so we add it to LD_LIBRARY_PATH - final List roots = new ArrayList<>(); - final List libs = new ArrayList<>(); - for (final String root : getPythonRoots()) { - File bin = new File(root, "/bin/"); - roots.add(bin.exists() ? bin.getAbsolutePath() : root); - File lib = new File(root, "/lib/"); - if (lib.exists()) { - libs.add(lib.getAbsolutePath()); - } + //On linux we also need shared libs from Anaconda, so we add it to LD_LIBRARY_PATH + final List roots = new ArrayList<>(); + final List libs = new ArrayList<>(); + for (final String root : getPythonRoots()) { + File bin = new File(root, "/bin/"); + roots.add(bin.exists() ? bin.getAbsolutePath() : root); + File lib = new File(root, "/lib/"); + if (lib.exists()) { + libs.add(lib.getAbsolutePath()); } + } - final String pathes = StringUtil.join(roots, File.pathSeparator); - final String libraryPathes = StringUtil.join(libs, File.pathSeparator); - final Logger logger = Logger.getInstance(PyToxTest.class); - Map envs = configuration.getEnvs(); - envs.put("PATH", pathes); - envs.put("LD_LIBRARY_PATH", libraryPathes); - for (final String key : envs.keySet()) { - logger.warn(String.format("%s: %s", key, envs.get(key))); - } + final String pathes = StringUtil.join(roots, File.pathSeparator); + final String libraryPathes = StringUtil.join(libs, File.pathSeparator); + final Logger logger = Logger.getInstance(PyToxTest.class); + Map envs = configuration.getEnvs(); + envs.put("PATH", pathes); + envs.put("LD_LIBRARY_PATH", libraryPathes); + for (final String key : envs.keySet()) { + logger.warn(String.format("%s: %s", key, envs.get(key))); } } @@ -514,6 +517,7 @@ public final class PyToxTest extends PyEnvTestCase { super.configurationCreatedAndWillLaunch(configuration); PyToxTestTools.setArguments(configuration, myArgs); PyToxTestTools.setRunOnlyEnvs(configuration, myEnvsToRun); + fixPathForTox(configuration); } } }