import org.apache.tools.ant.taskdefs.condition.Os

plugins {
  id "com.jetbrains.python.envs" version "0.0.2"
}

envs {
  bootstrapDirectory = new File(buildDir, '.miniconda')
  envsDirectory = new File(buildDir, 'MinicondaEnvs')
  minicondaVersion = 'latest'
  packages = ["cython", "numpy", "nose", "ipython", "pip"]

  conda "py27_64", "2.7", ["django>=1.7,<1.8", ["-U", "setuptools>=0.9"], ["-U", "wheel>=0.21", "twine"]]
  conda "py34_64", "3.4", ["django>=1.9", ["-U", "setuptools>=0.9"], ["-U", "wheel>=0.21", "twine"]]
  conda "py35_64", "3.5", ["django>=1.9", ["-U", "setuptools>=0.9"], ["-U", "wheel>=0.21", "twine"]]
  conda "py27_32", "2.7", ["django>=1.7,<1.8", ["-U", "setuptools>=0.9"], ["-U", "wheel>=0.21", "twine"]]
  conda "py34_32", "3.4", ["django>=1.9", ["-U", "setuptools>=0.9"], ["-U", "wheel>=0.21", "twine"]]
  conda "py35_32", "3.5", ["django>=1.9", ["-U", "setuptools>=0.9"], ["-U", "wheel>=0.21", "twine"]]
}

task buildBinariesOnWindows(dependsOn: 'build_envs') << {
  exec {
    workingDir projectDir

    environment PYTHONPATH: projectDir,
                MINICONDA32_ENVS: envs.envsDirectory,
                MINICONDA64_ENVS: envs.envsDirectory

    commandLine "${envs.envsDirectory}/py27_32/python.exe", "build_tools/build_binaries_windows.py"
  }
}



task buildBinaries() {
  if (Os.isFamily(Os.FAMILY_WINDOWS)) {
    dependsOn buildBinariesOnWindows
  }
  else if (Os.isFamily(Os.FAMILY_MAC)) {
    dependsOn buildOnMac
  }
}
