rbx.cp 0.5.0__py3-none-any.whl → 0.5.2__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/contest/main.py CHANGED
@@ -37,7 +37,6 @@ app.add_typer(
37
37
 
38
38
 
39
39
  @app.command('create, c', help='Create a new contest package.')
40
- @within_contest
41
40
  def create(
42
41
  name: str,
43
42
  preset: Annotated[
rbx/box/main.py CHANGED
@@ -233,7 +233,6 @@ def irun(
233
233
 
234
234
 
235
235
  @app.command('create, c', help='Create a new problem package.')
236
- @package.within_problem
237
236
  def create(
238
237
  name: str,
239
238
  preset: Annotated[
@@ -350,7 +349,6 @@ def stress(
350
349
 
351
350
 
352
351
  @app.command('environment, env', help='Set or show the current box environment.')
353
- @package.within_problem
354
352
  def environment_command(
355
353
  env: Annotated[Optional[str], typer.Argument()] = None,
356
354
  install_from: Annotated[
@@ -365,6 +363,9 @@ def environment_command(
365
363
  if env is None:
366
364
  cfg = config.get_config()
367
365
  console.console.print(f'Current environment: [item]{cfg.boxEnvironment}[/item]')
366
+ console.console.print(
367
+ f'Location: {environment.get_environment_path(cfg.boxEnvironment)}'
368
+ )
368
369
  return
369
370
  if install_from is not None:
370
371
  environment.install_environment(env, pathlib.Path(install_from))
@@ -420,7 +421,6 @@ def activate():
420
421
 
421
422
 
422
423
  @app.command('languages', help='List the languages available in this environment')
423
- @package.within_problem
424
424
  def languages():
425
425
  env = environment.get_environment()
426
426
 
@@ -437,7 +437,7 @@ def languages():
437
437
 
438
438
 
439
439
  @app.command('clear, clean', help='Clears cache and build directories.')
440
- @package.within_problem
440
+ @cd.within_closest_package
441
441
  def clear():
442
442
  console.console.print('Cleaning cache and build directories...')
443
443
  shutil.rmtree('.box', ignore_errors=True)
@@ -14,9 +14,9 @@ class BocaExtension(BaseModel):
14
14
 
15
15
  def flags_with_defaults(self) -> typing.Dict[BocaLanguage, str]:
16
16
  res: typing.Dict[BocaLanguage, str] = {
17
- 'c': '-std=gnu11 -O2 -static -lm',
18
- 'cpp': '-O2 -static -lm',
19
- 'cc': '-std=c++20 -O2 -static -lm',
17
+ 'c': '-std=gnu11 -O2 -lm -static',
18
+ 'cpp': '-O2 -lm -static',
19
+ 'cc': '-std=c++20 -O2 -lm -static',
20
20
  }
21
21
  res.update(self.flags)
22
22
  return res
@@ -48,13 +48,13 @@ class BocaPackager(BasePackager):
48
48
 
49
49
  def _get_problem_name(self) -> str:
50
50
  pkg = package.find_problem_package_or_die()
51
- return pkg.name
51
+ # BOCA forces Java class names to be the name of the problem.
52
+ return pkg.name.replace('-', '_')
52
53
 
53
54
  def _get_problem_info(self) -> str:
54
- pkg = package.find_problem_package_or_die()
55
55
  statement = self._get_main_statement()
56
56
  return (
57
- f'basename={pkg.name}\n'
57
+ f'basename={self._get_problem_name()}\n'
58
58
  f'fullname={statement.title}\n'
59
59
  f'descfile={self._get_problem_name()}.pdf\n'
60
60
  )
@@ -128,6 +128,8 @@ class BocaPackager(BasePackager):
128
128
  return compare_path.read_text()
129
129
 
130
130
  def _get_checker(self) -> str:
131
+ extension = get_extension_or_default('boca', BocaExtension)
132
+
131
133
  checker_path = get_default_app_path() / 'packagers' / 'boca' / 'checker.sh'
132
134
  if not checker_path.exists():
133
135
  console.console.print(
@@ -137,8 +139,10 @@ class BocaPackager(BasePackager):
137
139
  checker_text = checker_path.read_text()
138
140
  testlib = get_testlib().read_text()
139
141
  checker = package.get_checker().path.read_text()
140
- return checker_text.replace('{{testlib_content}}', testlib).replace(
141
- '{{checker_content}}', checker
142
+ return (
143
+ checker_text.replace('{{rbxFlags}}', extension.flags_with_defaults()['cc'])
144
+ .replace('{{testlib_content}}', testlib)
145
+ .replace('{{checker_content}}', checker)
142
146
  )
143
147
 
144
148
  def _get_compile(self, language: BocaLanguage) -> str:
@@ -165,6 +169,33 @@ class BocaPackager(BasePackager):
165
169
  compile_text = compile_text.replace('{{rbxFlags}}', flags[language])
166
170
  return compile_text
167
171
 
172
+ def _copy_solutions(self, into_path: pathlib.Path):
173
+ for solution in package.get_solutions():
174
+ dest_path = (
175
+ into_path
176
+ / solution.path.stem
177
+ / pathlib.Path(self._get_problem_name()).with_suffix(
178
+ solution.path.suffix
179
+ )
180
+ )
181
+ dest_path.parent.mkdir(parents=True, exist_ok=True)
182
+ shutil.copy(str(solution.path), dest_path)
183
+
184
+ if solution.path.suffix == '.java':
185
+ java_content = dest_path.read_text()
186
+ if (
187
+ 'class Main ' not in java_content
188
+ and f'class {self._get_problem_name()} ' not in java_content
189
+ ):
190
+ console.console.print(
191
+ '[error]For BOCA packaging, Java solutions must be named `class Main` or `class <ProblemName>`.[/error]'
192
+ )
193
+ dest_path.write_text(
194
+ java_content.replace(
195
+ 'class Main ', f'class {self._get_problem_name()} '
196
+ )
197
+ )
198
+
168
199
  def name(self) -> str:
169
200
  return 'boca'
170
201
 
@@ -223,6 +254,11 @@ class BocaPackager(BasePackager):
223
254
  (description_path / self._get_problem_name()).with_suffix('.pdf'),
224
255
  )
225
256
 
257
+ # Copy solutions
258
+ solutions_path = into_path / 'solutions'
259
+ solutions_path.mkdir(parents=True, exist_ok=True)
260
+ self._copy_solutions(solutions_path)
261
+
226
262
  # Prepare IO
227
263
  inputs_path = into_path / 'input'
228
264
  inputs_path.mkdir(parents=True, exist_ok=True)
@@ -29,7 +29,7 @@ if [ -f "$checker_cache" ]; then
29
29
  cp "$checker_cache" $CHECKER_OUT -f
30
30
  else
31
31
  echo "Compiling polygon checker: $CHECKER_PATH"
32
- $cc {{stdcpp}} -static -O2 -lm $CHECKER_PATH -o $CHECKER_OUT
32
+ $cc {{rbxFlags}} $CHECKER_PATH -o $CHECKER_OUT
33
33
 
34
34
  if [ $? -ne 0 ]; then
35
35
  echo "Checker could not be compiled"
@@ -40,4 +40,4 @@ else
40
40
  fi
41
41
 
42
42
  chmod 0755 $CHECKER_OUT
43
- ### END OF CHECKER COMPILATION
43
+ ### END OF CHECKER COMPILATION
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rbx.cp
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary:
5
5
  Author: Roberto Sales
6
6
  Requires-Python: >=3.9,<4.0
@@ -12,7 +12,7 @@ rbx/box/contest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  rbx/box/contest/build_contest_statements.py,sha256=qar6h5u1xAlOKHl3P7-A1d0aYtaqu4PspGw_DYUGOLY,11260
13
13
  rbx/box/contest/contest_package.py,sha256=-eHk6CfJ083jZptWCjR0F4x_r9qsmKeSOUvK0QnDyA4,2393
14
14
  rbx/box/contest/contest_utils.py,sha256=vWv4iNWdJT5motAznfdNzl8o-tEoCU4xmdyaPTPJZuY,490
15
- rbx/box/contest/main.py,sha256=NS59Pg5TB4dArZ51HQwg_hK3Y9Rg00oq3sDpNnRxKZw,5706
15
+ rbx/box/contest/main.py,sha256=bYPB16-CtMFgJgz2tYZZz9RLVWiz2nPN62kjQGvDuKs,5690
16
16
  rbx/box/contest/schema.py,sha256=rxzjJasMWPKKhvSJs4eW4A2oCiA4gXgfF-MzqsbPslQ,4914
17
17
  rbx/box/contest/statements.py,sha256=iG_E4bqhc7hof4LlAliw4m9VO8HcDzvnhsWmxzVRQM4,2690
18
18
  rbx/box/creation.py,sha256=mZ7kEt1F-0scwDBc6oWsJxFRW69AccZlKuJfN1QyDd4,2203
@@ -21,10 +21,10 @@ rbx/box/environment.py,sha256=HiufDkaXJeZk9gWvt27UMmyzaknnODu8flGerrwnNhE,10851
21
21
  rbx/box/extensions.py,sha256=p0iLaU28KswOBDX2HGVO_dR2gk-JSAWb6sXC6GZ1d0w,738
22
22
  rbx/box/generators.py,sha256=UJNyvwbY4JBVpmdMoVsYi16O3oodMgguH_dmZAoOFm4,16104
23
23
  rbx/box/generators_test.py,sha256=mQqHepAMYa6zV_PseQALI0nIX6AdQktt6lh94muFhNw,1758
24
- rbx/box/main.py,sha256=zVCyj1I61hY73cNiRYqLhj1XiZcSd4XMuass38IR7eM,13461
24
+ rbx/box/main.py,sha256=pGw9D3iBD9CgaDbJXxMAwWOHf27SH7nE3jPzYSWpnnY,13513
25
25
  rbx/box/package.py,sha256=8JqavlW6cF_TtflrNLdd39P6iecFVTxTDNRP_mQ8jP8,10067
26
- rbx/box/packaging/boca/extension.py,sha256=7xaLzccFtHeoLwlr0cyfJtsBsWvVyMixzrmWohyCS7Y,852
27
- rbx/box/packaging/boca/packager.py,sha256=quuTg5WQFjL7p4U_7rzKk1OeA-wJYhw4rjSpDwKEm4o,9159
26
+ rbx/box/packaging/boca/extension.py,sha256=hQhcbocNfW2ESv5RalS1wf6uvOoOfOnR_gHvbXUbSzY,852
27
+ rbx/box/packaging/boca/packager.py,sha256=FOhSRg5K5Y4qNB0WyTR3DKgrpObf9I0JbyGpJHOtxpo,10673
28
28
  rbx/box/packaging/contest_main.py,sha256=ypiBS8dd0yCqoFJIqiK1Fo02dQmUB_G-Z7G926jomrk,2746
29
29
  rbx/box/packaging/main.py,sha256=CyjfuvwmRsJGk4lKVp2LT_WCQ5jZ5L_7NfZQEC40nuY,2228
30
30
  rbx/box/packaging/packager.py,sha256=suCT_SLnWa915rV2j8VFqzH43HGKRTr9mGGlrvj45aw,3267
@@ -92,7 +92,7 @@ rbx/resources/checkers/boilerplate.cpp,sha256=vj1Qjy59JKEzb4ZpaX_MkL1FaZn_tTLZXj
92
92
  rbx/resources/default_config.json,sha256=8GZVHns4nci0-e5ALk9C1lfO6TO9W2ZlmZtxHkL6ibA,949
93
93
  rbx/resources/envs/default.rbx.yml,sha256=8gl4DXc5mVISx__1libPQfmuHYdW32xjysfqpNESIAo,853
94
94
  rbx/resources/envs/isolate.rbx.yml,sha256=VZAJ-Mu-A5Rt4m0VtMygOXA7eLLvCCmoorv_0acDmXQ,870
95
- rbx/resources/packagers/boca/checker.sh,sha256=wFMYnvvB2Hjq2sGDFNxIcChpbtaZmdVmV9jzpQPFSjo,1046
95
+ rbx/resources/packagers/boca/checker.sh,sha256=c7EBnKZXJKNDv_HxBv62Jt2bLV-GIOJ8FgxJisMJ1Ys,1033
96
96
  rbx/resources/packagers/boca/compare,sha256=2c7PR_loHNgRm-kszK7NQWvRb5hutXoqdj4HMmq7mbw,1849
97
97
  rbx/resources/packagers/boca/compile/c,sha256=lHLvxzkG_he5jmxWrix0WT80ipMWWUZdOgOQMSpj8oo,4507
98
98
  rbx/resources/packagers/boca/compile/cc,sha256=B_18QkUGcjUg6yrTFlTQuMWnHpTWUKPZmFuk7Y0l1VA,4561
@@ -157,8 +157,8 @@ rbx/testdata/caching/executable.py,sha256=WKRHNf_fprFJd1Fq1ubmQtR3mZzTYVNwKPLWuZ
157
157
  rbx/testdata/compatible,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
158
158
  rbx/testing_utils.py,sha256=ZZLKMUHlZ4HwsuNY50jqSBJ9HhpnFdba7opjDsvXE1U,2084
159
159
  rbx/utils.py,sha256=OkOLjNG8Pq7y2ylqhXQyAOVDfUsva_4Mfjd8OmII55E,4145
160
- rbx_cp-0.5.0.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
161
- rbx_cp-0.5.0.dist-info/METADATA,sha256=DIjf86z6PlLOOEnlrFLMr5w7-w5k9RigzwSzL7_l3bQ,3253
162
- rbx_cp-0.5.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
163
- rbx_cp-0.5.0.dist-info/entry_points.txt,sha256=qBTLBOeifT1F00LWaEewRRE_jQPgvH7BUdJfZ-dYsFU,57
164
- rbx_cp-0.5.0.dist-info/RECORD,,
160
+ rbx_cp-0.5.2.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
161
+ rbx_cp-0.5.2.dist-info/METADATA,sha256=fiqGkYBfzJBTozxW_9jKubvmcVyVioblqa4iREtVUVI,3253
162
+ rbx_cp-0.5.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
163
+ rbx_cp-0.5.2.dist-info/entry_points.txt,sha256=qBTLBOeifT1F00LWaEewRRE_jQPgvH7BUdJfZ-dYsFU,57
164
+ rbx_cp-0.5.2.dist-info/RECORD,,
File without changes