()
| 30 | |
| 31 | |
| 32 | def main() -> None: |
| 33 | parser = argparse.ArgumentParser() |
| 34 | parser.add_argument( |
| 35 | "-o", |
| 36 | "--outfile", |
| 37 | type=str, |
| 38 | help="Path to write version info to", |
| 39 | required=False, |
| 40 | ) |
| 41 | parser.add_argument( |
| 42 | "--print", |
| 43 | default=False, |
| 44 | action="store_true", |
| 45 | help="Whether to print out the version", |
| 46 | required=False, |
| 47 | ) |
| 48 | args = parser.parse_args() |
| 49 | |
| 50 | if args.outfile: |
| 51 | if not args.outfile.endswith(".py"): |
| 52 | raise ValueError( |
| 53 | f"Output file must be a Python file. " |
| 54 | f"Got: {args.outfile} as filename instead" |
| 55 | ) |
| 56 | |
| 57 | write_version_info(args.outfile) |
| 58 | |
| 59 | if args.print: |
| 60 | try: |
| 61 | import _version_meson |
| 62 | |
| 63 | version = _version_meson.__version__ |
| 64 | except ImportError: |
| 65 | version = versioneer.get_version() |
| 66 | print(version) |
| 67 | |
| 68 | |
| 69 | main() |
no test coverage detected