fix(judger): python

This commit is contained in:
Baoshuo Ren 2022-03-16 20:43:41 +08:00
parent 7a7d46e057
commit 8ce32618b6
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
3 changed files with 8 additions and 8 deletions

View File

@ -3,7 +3,7 @@
getAptPackage(){
printf "\n\n==> Getting environment packages\n"
export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get install -y vim ntp zip unzip curl wget build-essential fp-compiler python python3 python3-requests openjdk-8-jdk openjdk-11-jdk
apt-get update && apt-get install -y vim ntp zip unzip curl wget build-essential fp-compiler python2.7 python3.8 python3-requests openjdk-8-jdk openjdk-11-jdk
}
setJudgeConf(){
@ -24,7 +24,7 @@ cd /opt/uoj_judger && chmod +x judge_client
cat >uoj_judger/include/uoj_work_path.h <<UOJEOF
#define UOJ_WORK_PATH "/opt/uoj_judger/uoj_judger"
#define UOJ_JUDGER_BASESYSTEM_UBUNTU1804
#define UOJ_JUDGER_PYTHON3_VERSION "3.6"
#define UOJ_JUDGER_PYTHON3_VERSION "3.8"
#define UOJ_JUDGER_FPC_VERSION "3.0.4"
UOJEOF
cd uoj_judger && make -j$(($(nproc) + 1))

View File

@ -1152,12 +1152,12 @@ RunCompilerResult compile_cpp11(const string &name, const string &path = work_pa
}
RunCompilerResult compile_python2(const string &name, const string &path = work_path) {
return run_compiler(path.c_str(),
"/usr/bin/python2", "-E", "-s", "-B", "-O", "-c",
"/usr/bin/python2.7", "-E", "-s", "-B", "-O", "-c",
("import py_compile\nimport sys\ntry:\n py_compile.compile('" + name + ".code'" + ", '" + name + "', doraise=True)\n sys.exit(0)\nexcept Exception as e:\n print e\n sys.exit(1)").c_str(), NULL);
}
RunCompilerResult compile_python3(const string &name, const string &path = work_path) {
return run_compiler(path.c_str(),
"/usr/bin/python3", "-I", "-B", "-O", "-c", ("import py_compile\nimport sys\ntry:\n py_compile.compile('" + name + ".code'" + ", '" + name + "', doraise=True)\n sys.exit(0)\nexcept Exception as e:\n print(e)\n sys.exit(1)").c_str(), NULL);
"/usr/bin/python3.8", "-I", "-B", "-O", "-c", ("import py_compile\nimport sys\ntry:\n py_compile.compile('" + name + ".code'" + ", '" + name + "', doraise=True)\n sys.exit(0)\nexcept Exception as e:\n print(e)\n sys.exit(1)").c_str(), NULL);
}
RunCompilerResult compile_java8(const string &name, const string &path = work_path) {
RunCompilerResult ret = prepare_java_source(name, path);
@ -1250,12 +1250,12 @@ RunCompilerResult compile_cpp11_with_implementer(const string &name, const strin
/*
RunCompilerResult compile_python2(const string &name, const string &path = work_path) {
return run_compiler(path.c_str(),
"/usr/bin/python2", "-E", "-s", "-B", "-O", "-c",
"/usr/bin/python2.7", "-E", "-s", "-B", "-O", "-c",
("import py_compile\nimport sys\ntry:\n py_compile.compile('" + name + ".code'" + ", '" + name + "', doraise=True)\n sys.exit(0)\nexcept Exception as e:\n print e\n sys.exit(1)").c_str(), NULL);
}
RunCompilerResult compile_python3(const string &name, const string &path = work_path) {
return run_compiler(path.c_str(),
"/usr/bin/python3", "-I", "-B", "-O", "-c", ("import py_compile\nimport sys\ntry:\n py_compile.compile('" + name + ".code'" + ", '" + name + "', doraise=True)\n sys.exit(0)\nexcept Exception as e:\n print(e)\n sys.exit(1)").c_str(), NULL);
"/usr/bin/python3.8", "-I", "-B", "-O", "-c", ("import py_compile\nimport sys\ntry:\n py_compile.compile('" + name + ".code'" + ", '" + name + "', doraise=True)\n sys.exit(0)\nexcept Exception as e:\n print(e)\n sys.exit(1)").c_str(), NULL);
}
*/
RunCompilerResult compile_with_implementer(const char *name) {

View File

@ -237,10 +237,10 @@ void parse_args(int argc, char **argv) {
}
if (run_program_config.type == "python2") {
string pre[4] = {"/usr/bin/python2", "-E", "-s", "-B"};
string pre[4] = {"/usr/bin/python2.7", "-E", "-s", "-B"};
run_program_config.argv.insert(run_program_config.argv.begin(), pre, pre + 4);
} else if (run_program_config.type == "python3") {
string pre[3] = {"/usr/bin/python3", "-I", "-B"};
string pre[3] = {"/usr/bin/python3.8", "-I", "-B"};
run_program_config.argv.insert(run_program_config.argv.begin(), pre, pre + 3);
} else if (run_program_config.type == "java8") {
string pre[3] = {"/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-Xmx1024m", "-Xss1024m"};