diff --git a/accsoft-nxcals-data-access-python3/build.gradle b/accsoft-nxcals-data-access-python3/build.gradle index 8045725cee7433adedc747bb3ff0721e9fccd18e..dac2823132b8f4039eb7f87de8011be69cab2348 100644 --- a/accsoft-nxcals-data-access-python3/build.gradle +++ b/accsoft-nxcals-data-access-python3/build.gradle @@ -1,6 +1,8 @@ apply plugin: 'org.sonarqube' -def pathToPythonInterpreter = '/user/bdisoft/operational/bin/Python/anaconda_py35/bin/python' +def defaultPythonInterpreter = '/user/bdisoft/operational/bin/Python/anaconda_py35/bin/python' + +def pathToPythonInterpreter = null def pythonProjectName = name.replace('-', '_') def pythonProjectVersion = version.replace('-', '_') @@ -17,22 +19,27 @@ def finaArtifactPathZip = distDirectoryPath + finaArtifactNameZip def pythonPathVariableName = 'pythonPath' +//Beside appropriate version following packages have to be present in python env: +//"setuptools" and "wheel" task testPythonVersion() { def stdout = new ByteArrayOutputStream() exec { commandLine 'python', '--version' errorOutput = stdout } + if (project.hasProperty(pythonPathVariableName)) { pathToPythonInterpreter = pythonPath + } else if (file(defaultPythonInterpreter).exists()) { + pathToPythonInterpreter = defaultPythonInterpreter } else if (stdout.toString().startsWith('Python 3')) { pathToPythonInterpreter = 'python' } else if (exec { commandLine 'which', 'python3'; ignoreExitValue = true }.getExitValue() == 0) { pathToPythonInterpreter = 'python3' } else { - if (!file(pathToPythonInterpreter).exists()) { - throw new GradleException("To proceed python3 interpreter has to be provided, either as default intepreter (ran by \"python\" or \"python3\" command) or by specifying -P$pythonPathVariableName=/path/to/python3 gradle option") - } + throw new GradleException('To proceed python3 interpreter has to be provided, either as default intepreter (ran by \"python\" or \"python3\" command) ' + + 'or by specifying -P$pythonPathVariableName=/path/to/python3 gradle option.' + + 'Also following packages have to be present in python env: setooptools and wheel') } } @@ -41,7 +48,7 @@ task cleanWheel(type: Delete) { exec { commandLine pathToPythonInterpreter, 'setup.py', 'clean', '--all', "--nxcals-version=$currentVersion" } - delete distDirectoryPath, pythonProjectName + '.egg-info', fileTree('.') { include '**/*.pyc'} + delete distDirectoryPath, pythonProjectName + '.egg-info', fileTree('.') { include '**/*.pyc' } }