Skip to content

Commit 417c9cc

Browse files
author
Martin Krulis
committed
Fixing Python compilation to achieve having multiple versions at the hosts.
1 parent 6e33cfc commit 417c9cc

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

app/helpers/ExerciseConfig/Pipeline/Box/BoxService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public function __construct() {
4343
FetchFileBox::$FETCH_TYPE => FetchFileBox::class,
4444
JavaRunBox::$JAVA_RUNNER_TYPE => JavaRunBox::class,
4545
JavacCompilationBox::$JAVAC_TYPE => JavacCompilationBox::class,
46-
Python3RunBox::$PYTHON3_TYPE => Python3RunBox::class,
47-
Python3CompilationBox::$PYTHON3_COMPILATION_TYPE => Python3CompilationBox::class,
46+
Python3RunBox::$BOX_TYPE => Python3RunBox::class,
47+
Python3CompilationBox::$BOX_TYPE => Python3CompilationBox::class,
4848
PhpRunBox::$PHP_RUN_TYPE => PhpRunBox::class,
4949
NodeRunBox::$NODE_RUN_TYPE => NodeRunBox::class,
5050
MergeFilesBox::$BOX_TYPE => MergeFilesBox::class,

app/helpers/ExerciseConfig/Pipeline/Box/Boxes/Python3CompilationBox.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
class Python3CompilationBox extends CompilationBox
1717
{
1818
/** Type key */
19-
public static $PYTHON3_COMPILATION_TYPE = "python3c";
20-
public static $PYTHON3_BINARY = "/usr/bin/python3";
19+
public static $BOX_TYPE = "python3c";
20+
public static $PYTHON3_BINARY = "/usr/bin/env";
21+
public static $PYTHON3_VERSION = "python3";
2122
public static $PYC_FILES_PORT_KEY = "pyc-files";
2223
public static $PYC_EXT = ".pyc";
2324
public static $DEFAULT_NAME = "Python3 Compilation";
@@ -57,7 +58,7 @@ public function __construct(BoxMeta $meta) {
5758
* @return string
5859
*/
5960
public function getType(): string {
60-
return self::$PYTHON3_COMPILATION_TYPE;
61+
return self::$BOX_TYPE;
6162
}
6263

6364
/**
@@ -97,7 +98,7 @@ public function getDefaultName(): string {
9798
public function compile(CompilationParams $params): array {
9899
$task = $this->compileBaseTask($params);
99100
$task->setCommandBinary(self::$PYTHON3_BINARY);
100-
$task->setCommandArguments(["-m", "compileall", "-b", "."]);
101+
$task->setCommandArguments([self::$PYTHON3_VERSION, "-m", "compileall", "-b", "."]);
101102

102103
// determine name of pyc file and set it to variable
103104
$pycFilenames = [];

app/helpers/ExerciseConfig/Pipeline/Box/Boxes/Python3RunBox.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
class Python3RunBox extends ExecutionBox
1717
{
1818
/** Type key */
19-
public static $PYTHON3_TYPE = "python3";
20-
public static $PYTHON3_BINARY = "/usr/bin/python3";
19+
public static $BOX_TYPE = "python3";
20+
public static $PYTHON3_BINARY = "/usr/bin/env";
21+
public static $PYTHON3_VERSION = "python3";
2122
public static $PYC_FILES_PORT_KEY = "pyc-files";
2223
public static $DEFAULT_NAME = "Python3 Execution";
2324

@@ -61,7 +62,7 @@ public function __construct(BoxMeta $meta) {
6162
* @return string
6263
*/
6364
public function getType(): string {
64-
return self::$PYTHON3_TYPE;
65+
return self::$BOX_TYPE;
6566
}
6667

6768
/**
@@ -104,7 +105,7 @@ public function compile(CompilationParams $params): array {
104105

105106
$runner = $this->getInputPortValue(self::$RUNNER_FILE_PORT_KEY)->getValue();
106107
$entry = $this->getInputPortValue(self::$ENTRY_POINT_KEY)->getValue();
107-
$args = [$runner, $entry];
108+
$args = [self::$PYTHON3_VERSION, $runner, $entry];
108109
if ($this->hasInputPortValue(self::$EXECUTION_ARGS_PORT_KEY)) {
109110
$args = array_merge($args, $this->getInputPortValue(self::$EXECUTION_ARGS_PORT_KEY)->getValue());
110111
}

0 commit comments

Comments
 (0)