From bdd44e9bba78bb50121dc64a2a5a8cd8f3e98b25 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Tue, 15 Aug 2023 20:50:48 +0200 Subject: [PATCH] BLD: Fix version script (#54525) * BLD: Fix the version generation script * Update config.yml * Update config.yml --- .circleci/config.yml | 1 + generate_version.py | 28 ++++++++++++++++++++++----- scripts/validate_unwanted_patterns.py | 1 + 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ac9db5f451bf3..50f6a116a6630 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -46,6 +46,7 @@ jobs: fi - run: name: Build aarch64 wheels + no_output_timeout: 30m # Sometimes the tests won't generate any output, make sure the job doesn't get killed by that command: | pip3 install cibuildwheel==2.14.1 cibuildwheel --prerelease-pythons --output-dir wheelhouse diff --git a/generate_version.py b/generate_version.py index 5534f49c0ea58..46e9f52bfc5de 100644 --- a/generate_version.py +++ b/generate_version.py @@ -1,18 +1,30 @@ # Note: This file has to live next to setup.py or versioneer will not work import argparse import os +import sys import versioneer +sys.path.insert(0, "") + def write_version_info(path): + version = None + git_version = None + + try: + import _version_meson + + version = _version_meson.__version__ + git_version = _version_meson.__git_version__ + except ImportError: + version = versioneer.get_version() + git_version = versioneer.get_versions()["full-revisionid"] if os.environ.get("MESON_DIST_ROOT"): path = os.path.join(os.environ.get("MESON_DIST_ROOT"), path) with open(path, "w", encoding="utf-8") as file: - file.write(f'__version__="{versioneer.get_version()}"\n') - file.write( - f'__git_version__="{versioneer.get_versions()["full-revisionid"]}"\n' - ) + file.write(f'__version__="{version}"\n') + file.write(f'__git_version__="{git_version}"\n') def main(): @@ -43,7 +55,13 @@ def main(): write_version_info(args.outfile) if args.print: - print(versioneer.get_version()) + try: + import _version_meson + + version = _version_meson.__version__ + except ImportError: + version = versioneer.get_version() + print(version) main() diff --git a/scripts/validate_unwanted_patterns.py b/scripts/validate_unwanted_patterns.py index f8b49923cf466..47534226f972f 100755 --- a/scripts/validate_unwanted_patterns.py +++ b/scripts/validate_unwanted_patterns.py @@ -49,6 +49,7 @@ "_global_config", "_chained_assignment_msg", "_chained_assignment_method_msg", + "_version_meson", }