From d55e58e4165fb3b4461ef2a8d90713ed5828f51b Mon Sep 17 00:00:00 2001 From: Jonas L Date: Mon, 28 Feb 2022 19:02:01 +0100 Subject: [PATCH] chore: auto generate requirements.txt (#1651) - force LC_ALL for the sort command --- .pre-commit-config.yaml | 10 ++++++++ analyzer/requirements.txt | 6 +++++ api/requirements.txt | 10 ++++++++ api_client/requirements.txt | 4 +++ playout/requirements.txt | 11 ++++++++ shared/requirements.txt | 6 +++++ tools/extract-requirements.sh | 48 +++++++++++++++++++++++++++++++++++ worker/requirements.txt | 6 +++++ 8 files changed, 101 insertions(+) create mode 100644 analyzer/requirements.txt create mode 100644 api/requirements.txt create mode 100644 api_client/requirements.txt create mode 100644 playout/requirements.txt create mode 100644 shared/requirements.txt create mode 100755 tools/extract-requirements.sh create mode 100644 worker/requirements.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 15a22a671..a5a341e75 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -60,3 +60,13 @@ repos: - --ignore-words=.codespellignore - --builtin=clear,rare,informal exclude: (^legacy.*|yarn\.lock)$ + + - repo: local + hooks: + - id: requirements.txt + name: requirements.txt + description: Generate requirements.txt + entry: tools/extract-requirements.sh dev + pass_filenames: false + language: script + files: setup.py$ diff --git a/analyzer/requirements.txt b/analyzer/requirements.txt new file mode 100644 index 000000000..5f304d1fb --- /dev/null +++ b/analyzer/requirements.txt @@ -0,0 +1,6 @@ +# This file is auto-generated by tools/extract-requirements.sh. +# Please do not edit this file, edit the setup.py file! +mutagen>=1.45.1 +pika>=1.0.0 +requests>=2.7.0 +typing_extensions diff --git a/api/requirements.txt b/api/requirements.txt new file mode 100644 index 000000000..9b5370835 --- /dev/null +++ b/api/requirements.txt @@ -0,0 +1,10 @@ +# This file is auto-generated by tools/extract-requirements.sh. +# Please do not edit this file, edit the setup.py file! +coreapi +django~=3.0 +django-filter +djangorestframework +drf-spectacular +markdown +model_bakery +psycopg2 diff --git a/api_client/requirements.txt b/api_client/requirements.txt new file mode 100644 index 000000000..5781df598 --- /dev/null +++ b/api_client/requirements.txt @@ -0,0 +1,4 @@ +# This file is auto-generated by tools/extract-requirements.sh. +# Please do not edit this file, edit the setup.py file! +python-dateutil>=2.7.0 +requests diff --git a/playout/requirements.txt b/playout/requirements.txt new file mode 100644 index 000000000..dbfa1229c --- /dev/null +++ b/playout/requirements.txt @@ -0,0 +1,11 @@ +# This file is auto-generated by tools/extract-requirements.sh. +# Please do not edit this file, edit the setup.py file! +amqplib +configobj +defusedxml +kombu +mutagen +packaging +pytz +requests +typing-extensions diff --git a/shared/requirements.txt b/shared/requirements.txt new file mode 100644 index 000000000..d11dc556a --- /dev/null +++ b/shared/requirements.txt @@ -0,0 +1,6 @@ +# This file is auto-generated by tools/extract-requirements.sh. +# Please do not edit this file, edit the setup.py file! +click>=8.0.3 +loguru==0.6.0 +pydantic +pyyaml diff --git a/tools/extract-requirements.sh b/tools/extract-requirements.sh new file mode 100755 index 000000000..6818c3115 --- /dev/null +++ b/tools/extract-requirements.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +# Extract the dependencies from the setup.py files +# and save the result to requirements.txt. +# +# You can filter any extra require by adding the name as argument. +# +# Examples: +# tools/extract-requirements.sh +# tools/extract-requirements.sh dev + +set -u + +error() { + echo >&2 "error: $*" + exit 1 +} + +command -v python3 > /dev/null || error "python3 command not found!" +command -v sed > /dev/null || error "sed command not found!" + +for setup_path in */setup.py; do + path="$(dirname "$setup_path")" + egg_path="$(echo "$path"/*.egg-info)" + + # Only build egg if absent + if [[ ! -d "$egg_path" ]]; then + python3 "$setup_path" egg_info > /dev/null 2>&1 || true + fi + + # Refresh egg_path with bash expansion + egg_path="$(echo "$path"/*.egg-info)" + + # Remove entire extra section from require file + for arg in "$@"; do + sed --in-place "/^\[$arg\]/,/^\[/d" -- "$egg_path/requires.txt" + done + + # Generate requirements.txt + cat << EOF > "$path/requirements.txt" +# This file is auto-generated by tools/extract-requirements.sh. +# Please do not edit this file, edit the setup.py file! +EOF + + cat -- "$egg_path/requires.txt" | + sed '/^$/d' | + LC_ALL=en_US.UTF-8 sort >> "$path/requirements.txt" +done diff --git a/worker/requirements.txt b/worker/requirements.txt new file mode 100644 index 000000000..e83e0ab91 --- /dev/null +++ b/worker/requirements.txt @@ -0,0 +1,6 @@ +# This file is auto-generated by tools/extract-requirements.sh. +# Please do not edit this file, edit the setup.py file! +celery==4.4.7 +kombu==4.6.10 +mutagen>=1.31.0 +requests>=2.7.0