Files
edx-platform/scripts/post-pip-compile.sh
Carlos Muniz 8e8d8404be Carlos muniz/symmath removal unrevert (#29912)
* Revert "Merge pull request #29909 from openedx/revert-29869-Carlos-Muniz/symmath-removal"

This reverts commit 8c0db8ddff, reversing
changes made to 1156c62014.

* fix: Remove misplaced `-e`

`-e` was wrongfully placed in front of `common/lib/sandbox-packages`,
which may have most likely been causing the edxAPP to break.

* fix: Change regex to apply to right dirs

`py38.txt` does not include `common/lib/xmodule` so it doesn't match the
regex. Therefore, it never got its lines in `common/lib/sandbox-packages`
fixed. If we change the regex to match any `common/lib/<packagename>` it
should work correctly.
2022-02-14 10:26:40 -05:00

49 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
# Remove any cruft from a requirements file generated by pip-compile which we don't want to keep
function show_help {
echo "Usage: post-pip-compile.sh file ..."
echo "Remove any cruft left behind by pip-compile in the given requirements file(s)."
echo ""
echo "Removes \"-e\" prefixes which were added to GitHub URLs only so that"
echo "pip-compile could process them correctly."
}
function clean_file {
FILE_PATH=$1
TEMP_FILE=${FILE_PATH}.tmp
# Workaround for https://github.com/jazzband/pip-tools/issues/204 -
# change absolute paths for local editable packages back to relative ones
FILE_CONTENT=$(<${FILE_PATH})
FILE_URL_REGEX="-e (file:///[^"$'\n'"]*)/common/lib/\w+"
if [[ "${FILE_CONTENT}" =~ ${FILE_URL_REGEX} ]]; then
BASE_FILE_URL=${BASH_REMATCH[1]}
sed "s|$BASE_FILE_URL/||" ${FILE_PATH} > ${TEMP_FILE}
mv ${TEMP_FILE} ${FILE_PATH}
sed "s|$BASE_FILE_URL|.|" ${FILE_PATH} > ${TEMP_FILE}
mv ${TEMP_FILE} ${FILE_PATH}
fi
# Code sandbox local package installs must be non-editable due to file
# permissions issues. edxapp ones must stay editable until assorted
# packaging bugs are fixed.
if [[ "${FILE_PATH}" == "requirements/edx-sandbox/py38.txt" ]]; then
sed "s|-e common/lib/|common/lib/|" ${FILE_PATH} > ${TEMP_FILE}
mv ${TEMP_FILE} ${FILE_PATH}
fi
}
for i in "$@"; do
case ${i} in
-h|--help)
# help or unknown option
show_help
exit 0
;;
*)
clean_file ${i}
;;
esac
done