2
0

Python.hx 2.5 KB

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