rbx.cp 0.5.20__py3-none-any.whl → 0.5.22__py3-none-any.whl

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.
rbx/box/code.py CHANGED
@@ -1,5 +1,7 @@
1
1
  import pathlib
2
+ import re
2
3
  import shlex
4
+ import tempfile
3
5
  from enum import Enum
4
6
  from pathlib import PosixPath
5
7
  from typing import List, Optional
@@ -82,12 +84,14 @@ def add_sanitizer_flags(commands: List[str]) -> List[str]:
82
84
  return [add_sanitizer_flags_to_command(command) for command in commands]
83
85
 
84
86
 
87
+ CXX_WARNING_FLAGS = (
88
+ '-Wall -Wshadow -Wno-unused-result -Wno-sign-compare -Wno-char-subscripts'
89
+ )
90
+
91
+
85
92
  def add_warning_flags_to_command(command: str) -> str:
86
93
  if is_cxx_command(command):
87
- return (
88
- command
89
- + ' -Wall -Wshadow -Wno-unused-result -Wno-sign-compare -Wno-char-subscripts'
90
- )
94
+ return command + ' ' + CXX_WARNING_FLAGS
91
95
  return command
92
96
 
93
97
 
@@ -98,6 +102,35 @@ def add_warning_flags(commands: List[str], force_warnings: bool) -> List[str]:
98
102
  return commands
99
103
 
100
104
 
105
+ def _add_warning_pragmas(code: str) -> str:
106
+ flags = CXX_WARNING_FLAGS.split()
107
+ pragma_lines = '\n'.join(
108
+ [
109
+ f'#pragma GCC diagnostic ignored "{flag}"'
110
+ for flag in flags
111
+ if not flag.startswith('-Wno-')
112
+ ]
113
+ )
114
+
115
+ return re.sub(
116
+ r'^(#include[^\n]*)',
117
+ '#pragma GCC diagnostic push\n'
118
+ + pragma_lines
119
+ + '\n\\1'
120
+ + '\n#pragma GCC diagnostic pop\n',
121
+ code,
122
+ flags=re.MULTILINE,
123
+ )
124
+
125
+
126
+ def _ignore_warning_in_cxx_input(input: GradingFileInput):
127
+ if input.src is None or input.src.suffix not in ('.cpp', '.c', '.cc', '.cxx'):
128
+ return
129
+ tmp_path = PosixPath(tempfile.mkstemp()[1])
130
+ tmp_path.write_text(_add_warning_pragmas(input.src.read_text()))
131
+ input.src = tmp_path
132
+
133
+
101
134
  # Compile code item and return its digest in the storage.
102
135
  def compile_item(
103
136
  code: CodeItem,
@@ -146,11 +179,16 @@ def compile_item(
146
179
  GradingFileInput(src=src, dest=dest)
147
180
  for src, dest in package.get_compilation_files(code)
148
181
  )
182
+
149
183
  download.maybe_add_testlib(code, artifacts)
150
184
  download.maybe_add_jngen(code, artifacts)
151
185
  artifacts.inputs.append(
152
186
  GradingFileInput(src=generator_path, dest=PosixPath(file_mapping.compilable))
153
187
  )
188
+
189
+ for input in artifacts.inputs:
190
+ _ignore_warning_in_cxx_input(input)
191
+
154
192
  artifacts.outputs.append(
155
193
  GradingFileOutput(
156
194
  src=PosixPath(file_mapping.executable),
rbx/box/solutions.py CHANGED
@@ -955,9 +955,16 @@ def _print_limits(limits: Dict[str, Limits]):
955
955
  )
956
956
  for lang, limit in limits.items():
957
957
  console.console.print(f'[bold][status]{lang}[/status][/bold]')
958
- console.console.print(f'Time: {get_formatted_time(limit.time or int('+inf'))}')
959
- memory = limit.memory * 1024 * 1024 if limit.memory is not None else int('+inf')
960
- console.console.print(f'Memory: {get_formatted_memory(memory)}')
958
+ time = (
959
+ '<No time limit>' if limit.time is None else get_formatted_time(limit.time)
960
+ )
961
+ memory = (
962
+ '<No memory limit>'
963
+ if limit.memory is None
964
+ else get_formatted_memory(limit.memory * 1024 * 1024)
965
+ )
966
+ console.console.print(f'Time: {time}')
967
+ console.console.print(f'Memory: {memory}')
961
968
  if limit.isDoubleTL:
962
969
  console.console.print('[warning]Running with 2*TL[/warning]')
963
970
  console.console.print()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rbx.cp
3
- Version: 0.5.20
3
+ Version: 0.5.22
4
4
  Summary:
5
5
  Author: Roberto Sales
6
6
  Requires-Python: >=3.9,<4.0
@@ -5,7 +5,7 @@ rbx/box/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  rbx/box/builder.py,sha256=0TiRQJoHqLHAI8QwBrscbaJmhdcmialVtP_oEkfHcs0,3260
6
6
  rbx/box/cd.py,sha256=9a_SOnzoJBXxxffp4Wbf3UKXIwKuN3Hvj7K6SocALwE,1194
7
7
  rbx/box/checkers.py,sha256=VpgDzevOK7hrffG2zJGxquNiu-a9Fl3wquLn7xadcK0,6285
8
- rbx/box/code.py,sha256=xQL9YGouwyk5L1MzsENI6TwjEPAfCJ56y0Ih5jmYhSs,10146
8
+ rbx/box/code.py,sha256=_g9-BGQdiH0wBIxkzZXj7Hk3O3u7ZqGzPRO88CwOsWo,11064
9
9
  rbx/box/compile.py,sha256=OJLthDQ921w9vyoE6Gk1Df54i5RwtRJ2YG-8XEfefcs,2489
10
10
  rbx/box/conftest.py,sha256=sEmciXSeDC-wmrZ1JSxbsUenKNP_VWW32mrCun2pY3I,1070
11
11
  rbx/box/contest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -39,7 +39,7 @@ rbx/box/presets/schema.py,sha256=mZmSPkQsw7eQM0lQN6er1MO_LiW1ObwwAZFDK0F5fxE,196
39
39
  rbx/box/sanitizers/warning_stack.py,sha256=RI97_GJgdjTKIXY_r0EKp5h0qQQSDSdNDh5K7zINrqs,2861
40
40
  rbx/box/schema.py,sha256=mPEOchzoGDwk_S9wUw1DKqwJWJ0S5GTxQnZIlm9BFwo,13709
41
41
  rbx/box/setter_config.py,sha256=6nGTPMvnJ7y1sM-EBuI493NSZOIiOZ1DTypSXrL-HRY,3686
42
- rbx/box/solutions.py,sha256=SijWw3bn8EwJq8SPqkLOfWuTN2TKbYZ0IVMiU9Pz4s4,36458
42
+ rbx/box/solutions.py,sha256=0kVFY_RdQQ-wK9hk4XY4VeJv5oPNkkq28x1sk8RNP3o,36584
43
43
  rbx/box/solutions_test.py,sha256=Cx7Goon_0sz_PaUcD8qa8gmjgzOVub6VHss3CB0GaA0,1524
44
44
  rbx/box/statements/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
45
  rbx/box/statements/build_statements.py,sha256=upsMT-cAnSvbmKgtijdFc0OxPcyeBxRG92hY6dN-ZOk,11920
@@ -162,8 +162,8 @@ rbx/testdata/caching/executable.py,sha256=WKRHNf_fprFJd1Fq1ubmQtR3mZzTYVNwKPLWuZ
162
162
  rbx/testdata/compatible,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
163
163
  rbx/testing_utils.py,sha256=ZZLKMUHlZ4HwsuNY50jqSBJ9HhpnFdba7opjDsvXE1U,2084
164
164
  rbx/utils.py,sha256=WlmnF4whc0-6ksVZoOhmom2bR2spT6zETFHjnpJOCsA,4383
165
- rbx_cp-0.5.20.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
166
- rbx_cp-0.5.20.dist-info/METADATA,sha256=JlMBAAS18FWLar6T7L8oxVsnAbIt3RFf-AIwfNZONog,3290
167
- rbx_cp-0.5.20.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
168
- rbx_cp-0.5.20.dist-info/entry_points.txt,sha256=qBTLBOeifT1F00LWaEewRRE_jQPgvH7BUdJfZ-dYsFU,57
169
- rbx_cp-0.5.20.dist-info/RECORD,,
165
+ rbx_cp-0.5.22.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
166
+ rbx_cp-0.5.22.dist-info/METADATA,sha256=uUIasZQ4aNtfxM9AnnRJe2S_I3Z6kzxT_qtTDQmdVlM,3290
167
+ rbx_cp-0.5.22.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
168
+ rbx_cp-0.5.22.dist-info/entry_points.txt,sha256=qBTLBOeifT1F00LWaEewRRE_jQPgvH7BUdJfZ-dYsFU,57
169
+ rbx_cp-0.5.22.dist-info/RECORD,,