From b827250e5dad24489546c46bac916553a20a5739 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sat, 2 May 2020 00:30:55 -0500 Subject: [PATCH] Install python requirements during daily (#11486) * install python requirements during daily * Only check python 3 * ignore failures --- composer.json | 6 +++++- scripts/check_requirements.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 scripts/check_requirements.py diff --git a/composer.json b/composer.json index b38af4a711..8890c48fa7 100644 --- a/composer.json +++ b/composer.json @@ -114,10 +114,14 @@ "post-install-cmd": [ "LibreNMS\\ComposerHelper::postInstall", "Illuminate\\Foundation\\ComposerScripts::postInstall", - "@php artisan vue-i18n:generate --multi-locales --format=umd" + "@php artisan vue-i18n:generate --multi-locales --format=umd", + "@python-requirements" ], "post-update-cmd": [ "Illuminate\\Foundation\\ComposerScripts::postUpdate" + ], + "python-requirements": [ + "scripts/check_requirements.py || pip3 install -r requirements.txt || :" ] } } diff --git a/scripts/check_requirements.py b/scripts/check_requirements.py new file mode 100755 index 0000000000..fce327bb5c --- /dev/null +++ b/scripts/check_requirements.py @@ -0,0 +1,18 @@ +#! /usr/bin/env python3 +import os +import pkg_resources +from pkg_resources import DistributionNotFound, VersionConflict + +target = os.path.realpath(os.path.dirname(__file__) + '/../requirements.txt') + +with open(target, 'r') as file: + requirements = file.read().rstrip().split("\n") + try: + pkg_resources.require(requirements) + except DistributionNotFound: + exit(1) + except VersionConflict: + exit(2) + exit(0) + +exit(3)