rbx.cp 0.5.22__py3-none-any.whl → 0.5.24__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,7 +1,6 @@
1
1
  import pathlib
2
2
  import re
3
3
  import shlex
4
- import tempfile
5
4
  from enum import Enum
6
5
  from pathlib import PosixPath
7
6
  from typing import List, Optional
@@ -123,12 +122,32 @@ def _add_warning_pragmas(code: str) -> str:
123
122
  )
124
123
 
125
124
 
125
+ def _add_warning_pragmas_around(code: str) -> str:
126
+ flags = CXX_WARNING_FLAGS.split()
127
+ pragma_lines = '\n'.join(
128
+ [
129
+ f'#pragma GCC diagnostic ignored "{flag}"'
130
+ for flag in flags
131
+ if not flag.startswith('-Wno-')
132
+ ]
133
+ )
134
+
135
+ return (
136
+ '#pragma GCC diagnostic push\n'
137
+ + pragma_lines
138
+ + '\n'
139
+ + code
140
+ + '\n'
141
+ + '#pragma GCC diagnostic pop\n'
142
+ )
143
+
144
+
126
145
  def _ignore_warning_in_cxx_input(input: GradingFileInput):
127
- if input.src is None or input.src.suffix not in ('.cpp', '.c', '.cc', '.cxx'):
146
+ if input.src is None or input.src.suffix not in ('.h', '.hpp'):
128
147
  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
148
+ preprocessed_path = package.get_problem_preprocessed_path(input.src)
149
+ preprocessed_path.write_text(_add_warning_pragmas_around(input.src.read_text()))
150
+ input.src = preprocessed_path
132
151
 
133
152
 
134
153
  # Compile code item and return its digest in the storage.
@@ -186,9 +205,6 @@ def compile_item(
186
205
  GradingFileInput(src=generator_path, dest=PosixPath(file_mapping.compilable))
187
206
  )
188
207
 
189
- for input in artifacts.inputs:
190
- _ignore_warning_in_cxx_input(input)
191
-
192
208
  artifacts.outputs.append(
193
209
  GradingFileOutput(
194
210
  src=PosixPath(file_mapping.executable),
@@ -197,6 +213,9 @@ def compile_item(
197
213
  )
198
214
  )
199
215
 
216
+ for input in artifacts.inputs:
217
+ _ignore_warning_in_cxx_input(input)
218
+
200
219
  if not steps_with_caching.compile(
201
220
  commands,
202
221
  params=sandbox_params,
rbx/box/main.py CHANGED
@@ -3,7 +3,6 @@ from gevent import monkey
3
3
 
4
4
  monkey.patch_all()
5
5
 
6
-
7
6
  import asyncio
8
7
  import tempfile
9
8
  import shlex
rbx/box/package.py CHANGED
@@ -158,6 +158,21 @@ def get_problem_iruns_dir(root: pathlib.Path = pathlib.Path()) -> pathlib.Path:
158
158
  return iruns_dir
159
159
 
160
160
 
161
+ def get_problem_preprocessed_path(
162
+ item: pathlib.Path, root: pathlib.Path = pathlib.Path()
163
+ ) -> pathlib.Path:
164
+ root_resolved = root.resolve()
165
+ item_resolved = item.resolve()
166
+
167
+ if not item_resolved.is_relative_to(root_resolved):
168
+ final_path = pathlib.Path('remote') / item_resolved.name
169
+ else:
170
+ final_path = item_resolved.relative_to(root_resolved)
171
+ path = get_problem_cache_dir(root) / '.preprocessed' / final_path
172
+ path.parent.mkdir(parents=True, exist_ok=True)
173
+ return path
174
+
175
+
161
176
  @functools.cache
162
177
  def get_cache_storage(root: pathlib.Path = pathlib.Path()) -> Storage:
163
178
  return FilesystemStorage(get_problem_storage_dir(root))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rbx.cp
3
- Version: 0.5.22
3
+ Version: 0.5.24
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=_g9-BGQdiH0wBIxkzZXj7Hk3O3u7ZqGzPRO88CwOsWo,11064
8
+ rbx/box/code.py,sha256=9VKwvIyQRaoINg1lRzDgJlibDNLdzf5CCPYxsAtYEcU,11528
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
@@ -22,8 +22,8 @@ rbx/box/environment.py,sha256=47NtyuVC6zSQKAtQaXPEXvqcD-KJiuWRpWF8pYvcG4c,11158
22
22
  rbx/box/extensions.py,sha256=gIC73VbF1897er3iIMhaIw6GE8o1t43M7q97Iz7-_lg,503
23
23
  rbx/box/generators.py,sha256=bzURQrNEscCO8_3BYXCyGK9ZneX4-eOJZP5JJV28f3I,16350
24
24
  rbx/box/generators_test.py,sha256=mQqHepAMYa6zV_PseQALI0nIX6AdQktt6lh94muFhNw,1758
25
- rbx/box/main.py,sha256=QFn19JoxnAerg1u-jpUIkgvu2qscMmJdCHRSGsWkafc,22068
26
- rbx/box/package.py,sha256=yk5NvHtDk2SnoYgs0zhA0VybZYSrwe7BjSNb7PwgCKY,11334
25
+ rbx/box/main.py,sha256=pc7DiIaPnq50DUPsPhtzr4kiPu5c2TrK0QaS21wcmwY,22067
26
+ rbx/box/package.py,sha256=SSckCXo7Zh412_qjYhSNwConjhR0Sk8911qGJU34Hac,11851
27
27
  rbx/box/packaging/boca/extension.py,sha256=hQhcbocNfW2ESv5RalS1wf6uvOoOfOnR_gHvbXUbSzY,852
28
28
  rbx/box/packaging/boca/packager.py,sha256=FOhSRg5K5Y4qNB0WyTR3DKgrpObf9I0JbyGpJHOtxpo,10673
29
29
  rbx/box/packaging/contest_main.py,sha256=Hbxh7geNqrePs5tWhPgdg5W2qhaW5yoreK_VP0Sm19k,2727
@@ -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.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,,
165
+ rbx_cp-0.5.24.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
166
+ rbx_cp-0.5.24.dist-info/METADATA,sha256=oIiRQJKg7rlcz6fJfap3_0yZrNT2uWDW1TH8VG33NCY,3290
167
+ rbx_cp-0.5.24.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
168
+ rbx_cp-0.5.24.dist-info/entry_points.txt,sha256=qBTLBOeifT1F00LWaEewRRE_jQPgvH7BUdJfZ-dYsFU,57
169
+ rbx_cp-0.5.24.dist-info/RECORD,,