Python.hx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package runci.targets;
  2. import sys.FileSystem;
  3. import runci.System.*;
  4. import runci.Config.*;
  5. class Python {
  6. static public function getPythonDependencies():Array<String> {
  7. switch (systemName) {
  8. case "Linux":
  9. if (commandSucceed("python3", ["-V"]))
  10. infoMsg('python3 has already been installed.');
  11. else
  12. Linux.requireAptPackages(["python3"]);
  13. runCommand("python3", ["-V"]);
  14. var pypy = "pypy3";
  15. if (commandSucceed(pypy, ["-V"])) {
  16. infoMsg('pypy3 has already been installed.');
  17. } else {
  18. var pypyVersion = "pypy3-2.4.0-linux64";
  19. var file = '${pypyVersion}.tar.bz2';
  20. if(!FileSystem.exists(file)) {
  21. runCommand("wget", ["-nv", 'https://bitbucket.org/pypy/pypy/downloads/$file'], true);
  22. }
  23. runCommand("tar", ["-xf", file]);
  24. pypy = FileSystem.fullPath('${pypyVersion}/bin/pypy3');
  25. }
  26. runCommand(pypy, ["-V"]);
  27. return ["python3", pypy];
  28. case "Mac":
  29. if (commandSucceed("python3", ["-V"]))
  30. infoMsg('python3 has already been installed.');
  31. else
  32. runCommand("brew", ["install", "python3"], true);
  33. runCommand("python3", ["-V"]);
  34. if (commandSucceed("pypy3", ["-V"]))
  35. infoMsg('pypy3 has already been installed.');
  36. else
  37. runCommand("brew", ["install", "pypy3"], true);
  38. runCommand("pypy3", ["-V"]);
  39. return ["python3", "pypy3"];
  40. case "Windows":
  41. if (commandSucceed("python3", ["-V"]))
  42. infoMsg('python3 has already been installed.');
  43. else
  44. throw "please install python 3.x and make it available as python3 in PATH";
  45. runCommand("python3", ["-V"]);
  46. return ["python3"];
  47. }
  48. return [];
  49. }
  50. static public function run(args:Array<String>) {
  51. var pys = getPythonDependencies();
  52. runCommand("haxe", ["compile-python.hxml"].concat(args));
  53. for (py in pys) {
  54. runCommand(py, ["bin/unit.py"]);
  55. }
  56. changeDirectory(sysDir);
  57. runCommand("haxe", ["compile-python.hxml"]);
  58. for (py in pys) {
  59. runCommand(py, ["bin/python/sys.py"]);
  60. }
  61. changeDirectory(miscDir + "pythonImport");
  62. runCommand("haxe", ["compile.hxml"]);
  63. for (py in pys) {
  64. runCommand(py, ["test.py"]);
  65. }
  66. }
  67. }