From fe1b37afaf09c2c885be4401a1fcd80b344b2b7b Mon Sep 17 00:00:00 2001 From: John Westcott IV Date: Wed, 9 Nov 2022 10:15:36 -0500 Subject: [PATCH] Updating README and update.sh usage --- requirements/README.md | 11 ++++------- requirements/updater.sh | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/requirements/README.md b/requirements/README.md index d98557aa58..9714398c37 100644 --- a/requirements/README.md +++ b/requirements/README.md @@ -1,25 +1,22 @@ # Dependency Management -The `requirements.txt` file is generated from `requirements.in`, using `pip-tools` `pip-compile`. +The `requirements.txt` file is generated from `requirements.in` and `requirements_git.txt`, using `pip-tools` and `pip-compile`. ## How To Use -Commands should be run from inside the `./requirements` directory of the awx repository. +Commands should be run in the awx container from inside the `./requirements` directory of the awx repository. ### Upgrading or Adding Select Libraries If you need to add or upgrade one targeted library, then modify `requirements.in`, then run the script: -`./updater.sh` - -NOTE: `./updater.sh` uses /usr/bin/python3.6, to match the current python version -(3.6) used to build releases. +`./updater.sh run` #### Upgrading Unpinned Dependency If you require a new version of a dependency that does not have a pinned version -for a fix or feature, pin a minimum version and run `./updater.sh`. For example, +for a fix or feature, pin a minimum version in `requirements.in` and run `./updater.sh run`. For example, replace the line `asgi-amqp` with `asgi-amqp>=1.1.4`, and consider leaving a note. diff --git a/requirements/updater.sh b/requirements/updater.sh index 9f61376214..6f96a840e5 100755 --- a/requirements/updater.sh +++ b/requirements/updater.sh @@ -33,11 +33,47 @@ generate_requirements() { main() { base_dir=$(pwd) - _tmp="$(mktemp -d --suffix .awx-requirements XXXX -p /tmp)" + + _tmp=$(python -c "import tempfile; print(tempfile.mkdtemp(suffix='.awx-requirements', dir='/tmp'))") + trap _cleanup INT TERM EXIT - if [ "$1" = "upgrade" ]; then + case $1 in + "run") + NEEDS_HELP=0 + ;; + "upgrade") + NEEDS_HELP=0 pip_compile="${pip_compile} --upgrade" + ;; + "help") + NEEDS_HELP=1 + ;; + *) + echo "" + echo "ERROR: Parameter $1 not valid" + echo "" + NEEDS_HELP=1 + ;; + esac + + if [[ "$NEEDS_HELP" == "1" ]] ; then + echo "This script generates requirements.txt from requirements.in and requirements_git.in" + echo "It should be run from within the awx container" + echo "" + echo "Usage: $0 [run|upgrade]" + echo "" + echo "Commands:" + echo "help Print this message" + echo "run Run the process only upgrading pinned libraries from requirements.in" + echo "upgrade Upgrade all libraries to latest while respecting pinnings" + echo "" + exit + fi + + if [[ ! -d /awx_devel ]] ; then + echo "This script should be run inside the awx container" + exit fi cp -vf requirements.txt "${_tmp}"