kattis-cli 1.2.6__tar.gz → 1.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/PKG-INFO +1 -1
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/pyproject.toml +1 -1
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/.kattis-cli.toml +2 -2
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/main.py +15 -1
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/solution_tester.py +19 -1
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/utils/run_program.py +18 -3
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/LICENSE +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/README.md +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/__init__.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/client.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/download.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/fireworks.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_setup.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/__init__.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/main/c.txt +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/main/cpp.txt +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/main/java.txt +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/main/python.txt +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/main/python3.txt +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/c/Makefile +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/c/src/problemid/problemid.c +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/c/tests/test_problemid.c +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/cpp/Makefile +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/cpp/src/problemid.cpp +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/cpp/tests/test_problemid.cpp +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/java/src/problemid.java +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/java/tests/tests_problemid.java +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python/Makefile +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python/src/problemid.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python/tests/__init__.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python/tests/test_problemid.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python3/Makefile +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python3/src/problemid.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python3/tests/__init__.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python3/tests/test_problemid.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/settings.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/template.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/ui.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/utils/__init__.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/utils/config.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/utils/languages.py +0 -0
- {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/utils/utility.py +0 -0
|
@@ -15,12 +15,12 @@ execute = "python3 {mainfile}"
|
|
|
15
15
|
mainfile = "{problemid}.py"
|
|
16
16
|
|
|
17
17
|
[cpp]
|
|
18
|
-
compile = "g++ -g -O2 -std=
|
|
18
|
+
compile = "g++ -g -O2 -std=gnu++23 -static -lrt -Wl,--whole-archive -lpthread -Wl,--no-whole-archive"
|
|
19
19
|
execute = "./a.out"
|
|
20
20
|
mainfile = "{problemid}.cpp"
|
|
21
21
|
|
|
22
22
|
[c]
|
|
23
|
-
compile = "gcc -g -O2 -std=
|
|
23
|
+
compile = "gcc -g -O2 -std=gnu23 -static -lm"
|
|
24
24
|
execute = "./a.out"
|
|
25
25
|
mainfile = "{problemid}.c"
|
|
26
26
|
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Change the __version__ to match in pyproject.toml
|
|
4
4
|
"""
|
|
5
|
-
__version__ = '1.2.
|
|
5
|
+
__version__ = '1.2.7'
|
|
6
6
|
|
|
7
7
|
from math import inf
|
|
8
8
|
import os
|
|
9
|
+
from urllib.parse import urlparse
|
|
9
10
|
from typing import Tuple
|
|
10
11
|
from rich.console import Console
|
|
11
12
|
import click
|
|
@@ -30,11 +31,24 @@ def main() -> None:
|
|
|
30
31
|
pass
|
|
31
32
|
|
|
32
33
|
|
|
34
|
+
def _normalize_problemid(problemid: str) -> str:
|
|
35
|
+
"""Return a raw Kattis problem id from an id or full problem URL."""
|
|
36
|
+
parsed = urlparse(problemid)
|
|
37
|
+
if not parsed.scheme or not parsed.netloc:
|
|
38
|
+
return problemid
|
|
39
|
+
|
|
40
|
+
path_parts = [part for part in parsed.path.split('/') if part]
|
|
41
|
+
if not path_parts:
|
|
42
|
+
return problemid
|
|
43
|
+
return path_parts[-1]
|
|
44
|
+
|
|
45
|
+
|
|
33
46
|
@main.command(help='Download sample data & metadata.')
|
|
34
47
|
@click.argument('problemid')
|
|
35
48
|
def get(problemid: str) -> None:
|
|
36
49
|
"""Command Line Interface for Kattis.
|
|
37
50
|
"""
|
|
51
|
+
problemid = _normalize_problemid(problemid)
|
|
38
52
|
console = Console()
|
|
39
53
|
console.print(
|
|
40
54
|
f"Downloading metadata: [bold blue]{problemid}[/bold blue]")
|
|
@@ -7,6 +7,7 @@ delegator for backward compatibility with the previous procedural API.
|
|
|
7
7
|
from typing import Any, List, Dict, Optional
|
|
8
8
|
from math import inf
|
|
9
9
|
import glob
|
|
10
|
+
import shlex
|
|
10
11
|
import time
|
|
11
12
|
import os
|
|
12
13
|
from pathlib import Path
|
|
@@ -77,15 +78,22 @@ class SolutionTester:
|
|
|
77
78
|
console.print("No sample input files found!", style="bold red")
|
|
78
79
|
exit(1)
|
|
79
80
|
in_files.sort()
|
|
81
|
+
compile_command = None
|
|
80
82
|
if lang_config['compile']:
|
|
83
|
+
compile_command = run_program.build_compile_command(
|
|
84
|
+
lang_config,
|
|
85
|
+
files,
|
|
86
|
+
)
|
|
81
87
|
ex_code, ans, error = run_program.compile_program(
|
|
82
88
|
lang_config,
|
|
83
89
|
files,
|
|
84
90
|
)
|
|
85
91
|
if ex_code != 0: # compilation error; exit code
|
|
92
|
+
console.print(
|
|
93
|
+
f"Compile command: {shlex.join(compile_command)}",
|
|
94
|
+
style='bold blue')
|
|
86
95
|
console.print(escape(error), style='bold red')
|
|
87
96
|
exit(1)
|
|
88
|
-
console.print('Compiled successfully!', style='bold green')
|
|
89
97
|
|
|
90
98
|
count = 0
|
|
91
99
|
total = len(in_files)
|
|
@@ -94,6 +102,16 @@ class SolutionTester:
|
|
|
94
102
|
main_src_file = next((f for f in files if f.endswith(mainclass)), None)
|
|
95
103
|
if not main_src_file:
|
|
96
104
|
main_src_file = mainclass
|
|
105
|
+
run_command = run_program.build_run_command(lang_config, main_src_file)
|
|
106
|
+
|
|
107
|
+
if compile_command:
|
|
108
|
+
console.print(
|
|
109
|
+
f"Compile command: {shlex.join(compile_command)}",
|
|
110
|
+
style='bold blue')
|
|
111
|
+
console.print('Compiled successfully!', style='bold green')
|
|
112
|
+
console.print(
|
|
113
|
+
f"Run command: {shlex.join(run_command)}",
|
|
114
|
+
style='bold blue')
|
|
97
115
|
|
|
98
116
|
title += f" using {loc_language} 👷[/]"
|
|
99
117
|
table.title = title
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
"""Run the program with the given input file and return the output.
|
|
2
2
|
"""
|
|
3
3
|
|
|
4
|
+
import shlex
|
|
4
5
|
import subprocess
|
|
5
6
|
from typing import Tuple, List, Dict, Any
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
def build_compile_command(
|
|
10
|
+
lang_config: Dict[Any, Any], files: List[str]) -> List[str]:
|
|
11
|
+
"""Build the compile command for the configured language."""
|
|
12
|
+
command = shlex.split(lang_config['compile'])
|
|
13
|
+
command.extend(files)
|
|
14
|
+
return command
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def build_run_command(
|
|
18
|
+
lang_config: Dict[Any, Any], mainclass: str) -> List[str]:
|
|
19
|
+
"""Build the run command for the configured language."""
|
|
20
|
+
return shlex.split(
|
|
21
|
+
lang_config['execute'].replace("{mainfile}", mainclass))
|
|
22
|
+
|
|
23
|
+
|
|
8
24
|
def compile_program(
|
|
9
25
|
lang_config: Dict[Any, Any], files: List[str]) -> Tuple[int, str, str]:
|
|
10
26
|
"""Compile Program.
|
|
@@ -13,8 +29,7 @@ def compile_program(
|
|
|
13
29
|
lang_config (Dict[Any, Any]): language config
|
|
14
30
|
files (List[str]): List of files
|
|
15
31
|
"""
|
|
16
|
-
command = lang_config
|
|
17
|
-
command.extend(files)
|
|
32
|
+
command = build_compile_command(lang_config, files)
|
|
18
33
|
# print(f'{command=}')
|
|
19
34
|
# print(f'{files}')
|
|
20
35
|
# Set the g++ command and its arguments in a list
|
|
@@ -48,7 +63,7 @@ def run(lang_config: Dict[Any, Any],
|
|
|
48
63
|
Tuple[str, str]: program output and error
|
|
49
64
|
"""
|
|
50
65
|
|
|
51
|
-
program = lang_config
|
|
66
|
+
program = build_run_command(lang_config, mainclass)
|
|
52
67
|
# print(f'{program=}')
|
|
53
68
|
code, ans, error = execute(program, input_file)
|
|
54
69
|
return code, ans, error
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/c/Makefile
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/cpp/Makefile
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|