online-judge-tools: init at 11.5.1

This commit is contained in:
Seong Yong-ju 2021-11-15 04:34:05 +09:00 committed by Jonathan Ringer
parent abe84c21a9
commit 555014c67d
5 changed files with 136 additions and 0 deletions

View file

@ -0,0 +1,60 @@
{ lib
, appdirs
, beautifulsoup4
, buildPythonPackage
, colorlog
, fetchFromGitHub
, git
, jsonschema
, lxml
, markdown
, python
, requests
, substituteAll
, toml
}:
let
# NOTE This is needed to download & run another Python program internally in
# order to generate test cases for library-checker problems.
pythonEnv = python.withPackages (ps: with ps; [ colorlog jinja2 markdown toml ]);
in buildPythonPackage rec {
pname = "online-judge-api-client";
version = "10.10.0";
src = fetchFromGitHub {
owner = "online-judge-tools";
repo = "api-client";
rev = "v${version}";
sha256 = "0lmryqi0bv82v9k9kf1rzzq9zr83smpmy8ivzw4fk31hvpczp4fn";
};
patches = [ ./fix-paths.patch ];
postPatch = ''
substituteInPlace onlinejudge/service/library_checker.py \
--subst-var-by git ${git} \
--subst-var-by pythonInterpreter ${pythonEnv.interpreter}
'';
propagatedBuildInputs = [
appdirs
beautifulsoup4
colorlog
jsonschema
lxml
requests
toml
];
# Requires internet access
doCheck = false;
pythonImportsCheck = [ "onlinejudge" "onlinejudge_api" ];
meta = with lib; {
description = "API client to develop tools for competitive programming";
homepage = "https://github.com/online-judge-tools/api-client";
license = licenses.mit;
maintainers = with maintainers; [ sei40kr ];
};
}

View file

@ -0,0 +1,39 @@
diff --git a/onlinejudge/service/library_checker.py b/onlinejudge/service/library_checker.py
index b63c7b7..e062490 100644
--- a/onlinejudge/service/library_checker.py
+++ b/onlinejudge/service/library_checker.py
@@ -51,7 +51,7 @@ class LibraryCheckerService(onlinejudge.type.Service):
return
try:
- subprocess.check_call(['git', '--version'], stdout=sys.stderr, stderr=sys.stderr)
+ subprocess.check_call(['@git@/bin/git', '--version'], stdout=sys.stderr, stderr=sys.stderr)
except FileNotFoundError:
logger.error('git command not found')
raise
@@ -60,12 +60,12 @@ class LibraryCheckerService(onlinejudge.type.Service):
if not path.exists():
# init the problem repository
url = 'https://github.com/yosupo06/library-checker-problems'
- logger.info('$ git clone %s %s', url, path)
- subprocess.check_call(['git', 'clone', url, str(path)], stdout=sys.stderr, stderr=sys.stderr)
+ logger.info('$ @git@/bin/git clone %s %s', url, path)
+ subprocess.check_call(['@git@/bin/git', 'clone', url, str(path)], stdout=sys.stderr, stderr=sys.stderr)
else:
# sync the problem repository
- logger.info('$ git -C %s pull', str(path))
- subprocess.check_call(['git', '-C', str(path), 'pull'], stdout=sys.stderr, stderr=sys.stderr)
+ logger.info('$ @git@/bin/git -C %s pull', str(path))
+ subprocess.check_call(['@git@/bin/git', '-C', str(path), 'pull'], stdout=sys.stderr, stderr=sys.stderr)
cls.is_repository_updated = True
@@ -100,7 +100,7 @@ class LibraryCheckerProblem(onlinejudge.type.Problem):
logger.warning("generate.py may not work on Windows")
problem_spec = str(self._get_problem_directory_path() / 'info.toml')
- command = [sys.executable, str(path / 'generate.py'), problem_spec]
+ command = ['@pythonInterpreter@', str(path / 'generate.py'), problem_spec]
if compile_checker:
command.append('--compile-checker')
logger.info('$ %s', ' '.join(command))

View file

@ -0,0 +1,31 @@
{ lib
, buildPythonPackage
, colorama
, fetchFromGitHub
, online-judge-api-client
, requests
}:
buildPythonPackage rec {
pname = "online-judge-tools";
version = "11.5.1";
src = fetchFromGitHub {
owner = "online-judge-tools";
repo = "oj";
rev = "v${version}";
sha256 = "0zkzmmjgjb6lyrzq1ip54cpnp7al9a7mcyjyi5vx58bvnx3q0c6m";
};
propagatedBuildInputs = [ colorama online-judge-api-client requests ];
# Requires internet access
doCheck = false;
meta = with lib; {
description = "Tools for various online judges. Download sample cases, generate additional test cases, test your code, and submit it.";
homepage = "https://github.com/online-judge-tools/oj";
license = licenses.mit;
maintainers = with maintainers; [ sei40kr ];
};
}

View file

@ -3510,6 +3510,8 @@ with pkgs;
oneshot = callPackage ../tools/networking/oneshot { };
online-judge-tools = with python3.pkgs; toPythonApplication online-judge-tools;
xkbd = callPackage ../applications/misc/xkbd { };
libpsm2 = callPackage ../os-specific/linux/libpsm2 { };

View file

@ -5572,6 +5572,10 @@ in {
onkyo-eiscp = callPackage ../development/python-modules/onkyo-eiscp { };
online-judge-api-client = callPackage ../development/python-modules/online-judge-api-client { };
online-judge-tools = callPackage ../development/python-modules/online-judge-tools { };
onlykey-solo-python = callPackage ../development/python-modules/onlykey-solo-python { };
onnx = callPackage ../development/python-modules/onnx { };