Adding windows check for virtualenv Scripts on Windows
@@ -37,8 +37,8 @@ public class PipPackager extends Packager {
boolean createVirtualEnv;
- public PipPackager(final InputStreamConverter inputStreamConverter, final ExecutableFinder executableFinder, final String sourceDirectory,
- final String outputDirectory, final boolean createVirtualEnv) {
+ public PipPackager(final InputStreamConverter inputStreamConverter, final ExecutableFinder executableFinder,
+ final String sourceDirectory, final String outputDirectory, final boolean createVirtualEnv) {
this.inputStreamConverter = inputStreamConverter;
this.executableFinder = executableFinder;
this.sourceDirectory = new File(sourceDirectory);
@@ -53,18 +53,28 @@ public class PipPackager extends Packager {
}
private void createVirtualEnvironment() {
+ String executionFolder = "bin";
+ String pipExecutable = "pip";
+ String pythonExecutable = "python";
if (createVirtualEnv) {
final File virtualEnvironmentPath = new File(outputDirectory, "blackduck_virtualenv");
- final File virtualEnvironmentBinPath = new File(virtualEnvironmentPath, "bin");
+
+ if (System.getProperty("os.name").toLowerCase().contains("windows")) {
+ executionFolder = "Scripts";
+ pipExecutable += ".exe";
+ pythonExecutable += ".exe";
+ }
+ final File virtualEnvironmentBinPath = new File(virtualEnvironmentPath, executionFolder);
final Command command = new Command(logger, executableFinder, sourceDirectory);
command.execute("pip", "install", "virtualenv");
command.execute("virtualenv", virtualEnvironmentPath.getAbsolutePath());
- // command.execute("bash", "-c", ". env.sh; " + executableFinder.findExecutable("activate",
- // virtualEnvironmentBinPath.getAbsolutePath()));
- command.execute(virtualEnvironmentBinPath, "pip", "install", "hub-pip");
- command.execute(virtualEnvironmentBinPath, "python", "setup.py", "install");
- command.execute(virtualEnvironmentBinPath, "python", "setup.py", "hub_pip", "--CreateTreeDependencyList=True", "--CreateHubBdio=False",
+
+ // TODO: We needed to append the .exe, otherwise executables are picked up from global Windows path. No bueno.
+ command.execute(virtualEnvironmentBinPath, pipExecutable, "install", "hub-pip");
+ command.execute(virtualEnvironmentBinPath, pythonExecutable, "setup.py", "install");
+ command.execute(virtualEnvironmentBinPath, pythonExecutable, "setup.py", "hub_pip",
+ "--CreateTreeDependencyList=True", "--CreateHubBdio=False",
"--OutputDirectory=" + outputDirectory.getAbsolutePath());
}
