File: write_release.py

package info (click to toggle)
numpy 1%3A2.4.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 87,160 kB
  • sloc: python: 259,644; asm: 232,483; ansic: 213,962; cpp: 160,235; f90: 1,585; sh: 785; fortran: 567; makefile: 443; sed: 139; xml: 109; java: 97; perl: 82; cs: 62; javascript: 53; objc: 33; lex: 13; yacc: 9
file content (68 lines) | stat: -rw-r--r-- 1,722 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
Standalone script for writing release doc::

    python tools/write_release <version>

Example::

    python tools/write_release.py 1.7.0

Needs to be run from the root of the repository and assumes
that the output is in `release` and wheels and sdist in
`release/installers`.

Translation from rst to md markdown requires Pandoc, you
will need to rely on your distribution to provide that.

"""
import argparse
import os
import subprocess
from pathlib import Path

# Name of the notes directory
NOTES_DIR = "doc/source/release"
# Name of the output directory
OUTPUT_DIR = "release"
# Output base name, `.rst` or `.md` will be appended
OUTPUT_FILE = "README"

def write_release(version):
    """
    Copy the <version>-notes.rst file to the OUTPUT_DIR and use
    pandoc to translate it to markdown. That results in both
    README.rst and README.md files that can be used for on
    github for the release.

    Parameters
    ----------
    version: str
       Release version, e.g., '2.3.2', etc.

    Returns
    -------
    None.

    """
    notes = Path(NOTES_DIR) / f"{version}-notes.rst"
    outdir = Path(OUTPUT_DIR)
    outdir.mkdir(exist_ok=True)
    target_md = outdir / f"{OUTPUT_FILE}.md"
    target_rst = outdir / f"{OUTPUT_FILE}.rst"

    # translate README.rst to md for posting on GitHub
    os.system(f"cp {notes} {target_rst}")
    subprocess.run(
        ["pandoc", "-s", "-o", str(target_md), str(target_rst), "--wrap=preserve"],
        check=True,
    )


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "version",
        help="NumPy version of the release, e.g. 2.3.2, etc.")

    args = parser.parse_args()
    write_release(args.version)