From 1cafc9c4b940b4a40c7c3a9196ccd0d9a3114efe Mon Sep 17 00:00:00 2001 From: notplants Date: Tue, 16 Mar 2021 13:04:55 +0100 Subject: [PATCH 1/2] Add functionality to automatically parse version number from setup.py for peach-config build --- peach_package_builder/build_peach_config.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/peach_package_builder/build_peach_config.py b/peach_package_builder/build_peach_config.py index 9afb0f9..b1fb971 100644 --- a/peach_package_builder/build_peach_config.py +++ b/peach_package_builder/build_peach_config.py @@ -4,12 +4,26 @@ script to build the peach-config debian module and add it to the freight reposit import argparse import subprocess import sys +import re import os from peach_package_builder.constants import * from peach_package_builder.utils import add_deb_to_freight, update_freight_cache +def get_version_from_setup_file(file_path): + with open(file_path, 'r') as f: + lines = f.read().splitlines() + for line in lines: + print(line) + match = re.match('.*version = "(\S+)",', line) + if match: + version = match.group(1) + return version + # if a version wasn't found then raise an exception + raise Exception("version not found") + + def build_peach_config(default_branch=True): service_path = os.path.join(MICROSERVICES_SRC_DIR, "peach-config") if default_branch: @@ -34,7 +48,10 @@ def build_peach_config(default_branch=True): "bdist_deb" ], cwd=service_path) - version = "0.2.7" # TODO: get this version number from the repo + # get version number of peach-config from setup.py file + setup_file = os.path.join(service_path, 'setup.py') + version = get_version_from_setup_file(setup_file) + # build the deb deb_name = "python3-peach-config_{version}-1_all.deb".format(version=version) debian_package_path = os.path.join( service_path, From 9544954ab7333a39901ff54fd3d9b0ea23b3f34a Mon Sep 17 00:00:00 2001 From: notplants Date: Tue, 16 Mar 2021 14:37:31 +0100 Subject: [PATCH 2/2] Remove print statement --- peach_package_builder/build_peach_config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/peach_package_builder/build_peach_config.py b/peach_package_builder/build_peach_config.py index b1fb971..36570e6 100644 --- a/peach_package_builder/build_peach_config.py +++ b/peach_package_builder/build_peach_config.py @@ -15,7 +15,6 @@ def get_version_from_setup_file(file_path): with open(file_path, 'r') as f: lines = f.read().splitlines() for line in lines: - print(line) match = re.match('.*version = "(\S+)",', line) if match: version = match.group(1)