Tools for developing ICPC-style programming contest problems.
Project description
BAPCtools
BAPCtools is a tool for creating and developing problems following the CLICS (DOMjudge/Kattis) problem format specified here.
The aim of this tool is to run all necessary compilation, validation, and testing commands while working on an ICPC-style problem. Ideally one should never have to manually run any compilation or testing command themselves.
I'm interested to know who's using this, so feel free to inform me (e.g. via an issue) if so ;) The current state is relatively stable, but things do change from time to time since I'm not aware of usage outside of BAPC yet.
Installation
[!IMPORTANT] The latest version of BAPCtools is only compatible with problem format version
2025-09. Thebt upgradecommand is a best-effort automated way to upgradelegacyproblems to2025-09. To use BAPCtools withlegacyproblems, you can use thelegacybranch of this repository, which is no longer maintained.
There are multiple ways to install BAPCtools:
- From PyPI:
pip install bapctools. This should be a complete installation (including all dependencies and abtexecutable) and should work on any Linux-ish system. - The bapctools-git AUR package, mirrored here.
- Run from a Docker image.
- (Deprecated) Run from cloning the source and installing dependencies manually.
- If you're interested in developing BAPCtools itself, see the installation instructions at the end of this file.
(If you know how to make a Debian package, feel free to help out.)
Windows
For Windows, the preferred way to use BAPCtools is inside the Windows Subsystem for Linux (WSL).
Note that BAPCtools makes use of symlinks for building programs.
By default, users are not allowed to create symlinks on Windows.
This can be fixed by enabling Developer Mode on Windows (only since Windows 10 version 1703, or newer).
In case you're still having problems with symlinks in combination with Git after enabling this setting,
please try the suggestions at https://stackoverflow.com/a/59761201.
Specifically, git config -g core.symlinks true should do the trick,
after which you can restore broken symlinks using git checkout -- path/to/symlink.
Native Windows
If you cannot or do not want to use WSL, you'll need the following in your %PATH%:
pythonfor Python 3g++to compile C++javacandjavato compile and run Java.
Resource limits (memory limit/hard cpu time limit) are not supported.
Docker
A docker image containing this git repo and dependencies, together with commonly
used languages, is provided at
ragnargrootkoerkamp/bapctools.
This version may be somewhat outdated, but we intend to update it whenever dependencies change.
Ping me if you'd like it to be updated.
Alternatively, inside the Docker container, you can run git -C /opt/BAPCtools pull to update to the latest version of BAPCtools,
and use pacman -Sy <package> to install potential missing dependencies.
TODO: update the Docker image to use installation via Pip.
This image can be used for e.g.:
- running CI on your repo. Also see
bt gitlabciwhich generates a.gitlab-ci.yamlfile. Make sure to clear the entrypoint, e.g.entrypoint: [""]. - running
bton your local problems. Use this command to mount your local directory into the docker image and run a command on it:docker run -v $PWD:/data --rm -it ragnargrootkoerkamp/bapctools <bt subcommands>
For maintainers, these are the steps to build and push an updated image:
$ sudo systemctl start docker
$ docker pull archlinux:latest
$ docker login
$ docker build . -t ragnargrootkoerkamp/bapctools
$ docker push ragnargrootkoerkamp/bapctools
$ ssh <server> sudo docker pull ragnargrootkoerkamp/bapctools
The last step is needed when your CI server is not automatically pulling the latest version.
Manual installation
This installation method is deprecated, and the list of dependencies may be out-of-date.
Clone this repository and install the required dependencies manually.
-
Python 3 (>= 3.10).
-
The ruamel.yaml library via
pip install ruamel.yamlor thepython-ruamel-yamlArch Linux package (python3-ruamel.yamlon Debian derivatives). -
The colorama library via
pip install coloramaor thepython[3]-coloramaArch Linux package. -
The
argcompletelibrary for command line argument completion. Install viapython[3]-argcomplete.-
Note that actually using
argcompleteis optional, but recommended. Detailed instructions are here.TL;DR: Put
eval "$(register-python-argcomplete[3] bt)"in your.bashrcor.zshrc.
-
Optional dependencies, required for some subcommands:
- The
latexmkandpdflatexcommands, provided bytexlive-binon Arch Linux and potentially some specific LaTeX packages (like tikz) provided bytexlive-extra. These are only needed for buildingpdffiles, not forrunandvalidateand such. - The matplotlib library via
pip install matplotlibor thepython[3]-matplotlibLinux package.- This is optional and only used by the
solve_statscommand.
- This is optional and only used by the
- The requests library via
pip install requestsor thepython[3]-requestsLinux package.- This is optional and only used by the commands that call the DOMjudge API (
export,solutions --order-from-css, andsolve_stats) or the Slack API (create_slack_channelscommand).
- This is optional and only used by the commands that call the DOMjudge API (
- The questionary library via
pip install questionary.- This is optional and only used by the
new_contestandnew_problemcommands.
- This is optional and only used by the
After cloning the repository, symlink bin/tools.py to somewhere in your $PATH. E.g., if ~/bin/ is in your $PATH, you can do:
$ ln -s ~/git/BAPCtools/bin/tools.py ~/bin/bt
Usage
BAPCtools can be run either from a problem directory or a contest directory. This
is automatically detected by searching for the problem.yaml file.
The most common commands and options to use on an existing repository are:
bt run [-v] [submissions [submissions ...]] [testcases [testcases ...]]bt test <submission> [--interactive | --samples | [testcases [testcases ...]]]bt generate [-v] [--jobs JOBS]bt validate [-v] [--input | --answer] [--remove | --move-to DIR] [testcases [testcases ...]]bt pdf [-v]
The list of all available commands and options is at doc/commands.md#synopsis, and more information regarding the implementation is at doc/implementation_notes.md.
Run
bt run [-v] [submissions [submissions ...]] [testcases [testcases ...]]
Without arguments, the run command runs all submissions against all testcases.
Specify one or more submissions and one or more testcases to only run the given submissions against the given testcases.
Before running the given submissions, this command first makes sure that all
generated testcases are up to date (in case generators/generators.yaml was
found). To disable automatically regenerating testcases, pass -G
(--no-generate), or add no_generate: true to a .bapctools.yaml file in the
problem or contest directory.
By default, bt run only prints one summary line per submission, and one additional line for each testcase with an unexpected result. Use -v to print one line per testcase instead.
Test
bt test <submission> [--samples | [testcases [testcases ...]]]
Use the test command to run a single submission on some testcases. The submission stdout and stderr are printed to the terminal instead of verified as an answer file.
Use --samples to run on the samples, or pass a list of testcases or directories containing testcases. Use --interactive/-i to run in interactive mode, where console input is forwarded to the submission.
This rebuilds and reruns the program until either control-C or control-D is pressed. It's also possible to supply the test case on the command line directly using e.g. < /path/to/file.in or <<< "10 20".
Generate
bt generate [-v] [--jobs JOBS]
Use the generate command to generate the testcases specified in generators/generators.yaml. See doc/generators.md for the specification of generators.yaml and see doc/commands.md#generate for the full list of arguents.
Use -j 0 to disable running multiple jobs in parallel (the default is 4).
Validate
bt validate [-v] [--input | --answer] [--remove | --move-to DIR] [testcases [testcases ...]]
Validate all the .in and .ans for all (given) testcases. It runs all validators from input_validators, answer_validators, and output_validators.
Validators can be one of
- a single-file program.
- a multi-file program with all files in a common directory.
- a .ctd CheckTestData file (this needs the
checktestdataexecutable in your$PATH). - a .viva file.
You can use --remove to delete all failing testcases or --move <dir> to move
them to a separate directory.
bt pdf [-v]
Use this command to compile the problem.en.pdf from the statement/problem.en.tex LaTeX statement.
problem.en.pdf is written to the problem directory itself.
This can also be used to create the contest pdf by running it from the contest directory.
Personal configuration file
For some command-line flags, it is convenient if they are always set to the same value, which differs per user
(e.g., --username or --password for commands that access a CCS like DOMjudge,
or --jobs to limit parallel execution) or per contest (e.g., which statement languages are used).
For this, you can create a configuration YAML file containing key-value pairs
in one of the following locations, from low to high priority:
$XDG_CONFIG_HOME/bapctools/config.yaml(Unix-ish systems, where$XDG_CONFIG_HOMEusually is~/.config)%AppData%/bapctools/config.yaml(Windows systems)<contest directory>/.bapctools.yaml
The keys in this config file can be any option that can be passed on the command-line.
Note that the keys should be written out in full (e.g., username: jury rather than u: jury)
and any hyphens should be replaced with an underscore (e.g., no_bar: True rather than no-bar: True).
These personal config files also allow to set the key local_time_multiplier to adjust hardcoded time limits intended for different hardware.
This might be useful for the CI or if your hadware is much faster or slower than the contest hardware.
Developing / Contributing to BAPCtools
The recommended way to install all development dependencies is in a virtual environment,
created with python3 -m venv venv and activated with . venv/bin/activate.
Install the development dependencies with pip install --editable . --group dev.
If you want to use your local development version of BAPCtools anywhere,
you can create a symlink from any bin directory on your $PATH to the virtual environment,
for example: ln -s /path/to/BAPCtools/venv/bin/bt ~/bin/bt.
The Python code in the repository is formatted using Ruff
and type-checked using mypy.
To enable the pre-commit hook,
run pre-commit install from the repository root.
All Python code will now automatically be formatted and type-checked on each commit.
If you want to run the hooks before creating a commit,
use pre-commit run (only staged files) or pre-commit run -a (all files).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bapctools-2026.3.1.tar.gz.
File metadata
- Download URL: bapctools-2026.3.1.tar.gz
- Upload date:
- Size: 9.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ef08ebb02d343a4547a16a95942128077ffb8cdba09973a0b1a2bb5cbfd3f4c
|
|
| MD5 |
a655f7ba8d0d14a9ecc69b88e727a9c5
|
|
| BLAKE2b-256 |
61ac4eaff5bff93a3118c2f6bad118b6aebf7300a2b47267d717ce84a1f0608c
|
Provenance
The following attestation bundles were made for bapctools-2026.3.1.tar.gz:
Publisher:
release.yml on RagnarGrootKoerkamp/BAPCtools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bapctools-2026.3.1.tar.gz -
Subject digest:
3ef08ebb02d343a4547a16a95942128077ffb8cdba09973a0b1a2bb5cbfd3f4c - Sigstore transparency entry: 1006537323
- Sigstore integration time:
-
Permalink:
RagnarGrootKoerkamp/BAPCtools@0853b9c0e2f239c6fdd194d37ba88dd6497aa659 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RagnarGrootKoerkamp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0853b9c0e2f239c6fdd194d37ba88dd6497aa659 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file bapctools-2026.3.1-py3-none-any.whl.
File metadata
- Download URL: bapctools-2026.3.1-py3-none-any.whl
- Upload date:
- Size: 3.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04bbc2e5df579fcac2ea39509b5d5dbdae2eeee74b8836f5f84fb858d96b4527
|
|
| MD5 |
918257e4cacb56f5d374e88d7e53bc83
|
|
| BLAKE2b-256 |
1a7976678eb75d1841b184c4aeccee309dc2eafff2b9d614a42d5f52389a1df9
|
Provenance
The following attestation bundles were made for bapctools-2026.3.1-py3-none-any.whl:
Publisher:
release.yml on RagnarGrootKoerkamp/BAPCtools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bapctools-2026.3.1-py3-none-any.whl -
Subject digest:
04bbc2e5df579fcac2ea39509b5d5dbdae2eeee74b8836f5f84fb858d96b4527 - Sigstore transparency entry: 1006537326
- Sigstore integration time:
-
Permalink:
RagnarGrootKoerkamp/BAPCtools@0853b9c0e2f239c6fdd194d37ba88dd6497aa659 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RagnarGrootKoerkamp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0853b9c0e2f239c6fdd194d37ba88dd6497aa659 -
Trigger Event:
workflow_dispatch
-
Statement type: