File size: 958 Bytes
c357c11
 
 
 
 
 
ab78607
c357c11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash

SCRIPT=$(realpath "$0")
SCRIPT_FOLDER=$(dirname "$SCRIPT")
ROOT_FOLDER=${SCRIPT_FOLDER}/../

mkdir -p tmp
rm ./tmp/requirements_tmp.txt || echo "./tmp/requirements_tmp.txt not found!"

echo "start requirements.txt preparation: pip freeze..."
pip freeze > ./tmp/freeze.txt
echo "grep python dependencies into freeze.txt..."
for x in $(cat ./requirements_no_versions.txt); do
  echo "# $x #"
  grep $x ./tmp/freeze.txt >> ./tmp/requirements_tmp.txt
  echo "######"
done

echo "cat ${ROOT_FOLDER}/tmp/requirements_tmp.txt"
cat ${ROOT_FOLDER}/tmp/requirements_tmp.txt
echo -e "\n"

[[ "$(echo -n 'Promote "${ROOT_FOLDER}/tmp/requirements_tmp.txt" as new requirements.txt? [y/N]> ' >&2; read; echo $REPLY)" == [Yy]* ]] \
  && echo "copy requirements_tmp.txt to root project..." \
  || exit 0

cp ${ROOT_FOLDER}/tmp/requirements_tmp.txt ${ROOT_FOLDER}/requirements.txt

echo "Fix any discrepancy within the new requirements.txt, bye!"

exit 0