research_helpers.arxiv

Assembles and checks an arXiv submission. See arXiv and Zenodo.

research_helpers.arxiv.manifest(*, patterns=DEFAULT_PATTERNS, extra=None, document=PAPER_DOCUMENT)[source]

Return the upload set, keyed by the path each file takes inside the submission.

Names are taken relative to the directory holding the manuscript, so a table installed at ‘tex/tables/scores.tex’ and read as ‘input{tables/scores}’ is uploaded as ‘tables/scores.tex’ and resolves the same way on arXiv. Only the tables and figures that the manuscript reads are uploaded (’input’ and ‘includegraphics’ outside a comment). A name with no file behind it is listed as written, so that ‘check’ reports it missing. A package the manuscript loads from its own directory, such as the ‘rhtextmath.sty’ that ‘research-helpers sty’ copies there, is uploaded beside it.

Parameters:
  • patterns (Iterable[str], default: DEFAULT_PATTERNS) – glob patterns a file in the tables and figures directories must match.

  • extra (Mapping[str, Path] | None, default: None) – anything else the build needs, e.g. a class file or a logo, keyed by its path inside the submission.

  • document (str, default: PAPER_DOCUMENT) – target: ‘paper’, or a name under ‘[tool.research-helpers.documents]’.

Return type:

dict[str, Path]

Returns:

Submission path to source file, in a stable order.

Raises:

KeyError – if no document of that name is configured.

research_helpers.arxiv.unused(files, *, patterns=DEFAULT_PATTERNS, document=PAPER_DOCUMENT)[source]

Return tables and figures omitted from the upload.

Includes any file that the manuscript does not read, or reads in some way the manifest does not recognise, such as through a macro.

Parameters:
  • files (Mapping[str, Path]) – the upload set, from ‘manifest’.

  • patterns (Iterable[str], default: DEFAULT_PATTERNS) – the glob patterns ‘manifest’ was given.

  • document (str, default: PAPER_DOCUMENT) – the target document.

Return type:

list[str]

Returns:

Each omitted file.

research_helpers.arxiv.bbl_format(path)[source]

Return the format version declared in a biblatex .bbl.

Return type:

str | None

Parameters:

path (Path)

research_helpers.arxiv.check(files, *, engine=None, texlive=None, expected_bbl_format=None, markers=None, document=PAPER_DOCUMENT)[source]

Return every reason this submission would be rejected or would build wrongly.

Parameters:
  • files (Mapping[str, Path]) – the upload set, from ‘manifest’.

  • engine (str | None, default: None) – the LaTeX engine selected on arXiv. Defaults to the project’s setting.

  • texlive (int | None, default: None) – the TeX Live year selected on arXiv, used in messages.

  • expected_bbl_format (str | None, default: None) – the biblatex .bbl format that year reads. Defaults to the project’s setting.

  • markers (Iterable[str] | None, default: None) – text that must not reach the submission, checked outside comments in every TeX file. Defaults to the project’s setting (none).

  • document (str, default: PAPER_DOCUMENT) – the target document: ‘paper’, or a name under ‘[tool.research-helpers.documents]’.

Return type:

list[str]

Returns:

One line per problem, empty when there is nothing wrong.

Raises:

KeyError – if no document of that name is configured.

research_helpers.arxiv.build(files, destination)[source]

Copy the upload set into a freshly emptied directory.

Parameters:
  • files (Mapping[str, Path]) – the upload set, from ‘manifest’.

  • destination (Path | str) – the submission directory, emptied first so nothing stale is uploaded.

Return type:

list[str]

Returns:

The submission paths written.

research_helpers.arxiv.pack(source, archive=None)[source]

Pack a built submission as the tarball arXiv accepts.

The archive is byte-reproducible, so re-packing an unchanged submission gives an identical file and a resubmission can be told apart from a rebuild.

Parameters:
  • source (Path | str) – the built submission directory.

  • archive (Path | str | None, default: None) – where to write the tarball. Defaults to the directory’s name plus ‘.tar.gz’.

Return type:

Path

Returns:

The archive written.

research_helpers.arxiv.preview(source, destination, *, engine=None, passes=DEFAULT_PASSES, document=PAPER_DOCUMENT)[source]

Compile a built submission with the engine arXiv will use.

Parameters:
  • source (Path | str) – the built submission directory.

  • destination (Path | str) – where to compile, emptied first.

  • engine (str | None, default: None) – the LaTeX engine. Defaults to the project’s setting.

  • passes (int, default: DEFAULT_PASSES) – how many times to run it, for cross-references to settle.

  • document (str, default: PAPER_DOCUMENT) – the target document.

Return type:

Path

Returns:

The PDF produced.

Raises:

RuntimeError – if the engine produced no PDF.

research_helpers.arxiv.report(files, problems, *, document=PAPER_DOCUMENT, unused_files=())[source]

Return the manifest and anything wrong with it.

Parameters:
  • files (Mapping[str, Path]) – the upload set, from ‘manifest’.

  • problems (list[str]) – what ‘check’ found.

  • document (str, default: PAPER_DOCUMENT) – the target document.

  • unused_files (Iterable[str], default: ()) – output of ‘unused’.

Return type:

str

Returns:

The report, ready to print.