Skip to content

Commit 061450c

Browse files
authored
Fixed an issue where the Debian build process failed with a "Sphinx module not found" error when using a Python virtual environment. #9240
1 parent b62212b commit 061450c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/linux/build-functions.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ _setup_env() {
2222
# Setting up the correct Python version for Ubuntu 18 and EL-8, which have
2323
# new Python versions installed parallel to the old ones.
2424
OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F "=" '{ print $2 }' | sed 's/"//g' | awk -F "." '{ print $1 }')
25-
SYSTEM_PYTHON_PATH='/usr/bin/python3'
25+
if [ -n "$VIRTUAL_ENV" ]; then
26+
SYSTEM_PYTHON_PATH="$VIRTUAL_ENV/bin/python3"
27+
echo "Detected virtual environment: $VIRTUAL_ENV"
28+
else
29+
SYSTEM_PYTHON_PATH='/usr/bin/python3'
30+
echo "Not in a virtual environment, using system Python path."
31+
fi
2632
PYTHON_BINARY=$("${SYSTEM_PYTHON_PATH}" -c "import sys; print('python%d.%.d' % (sys.version_info.major, sys.version_info.minor))")
2733
PYTHON_BINARY_WITHOUT_DOTS='python3'
2834
if [ "$2" == 'redhat' ] && [ "${OS_VERSION}" == "8" ]; then
@@ -203,9 +209,7 @@ _build_docs() {
203209
cd "${SERVERROOT}" && mkdir -p "usr/${APP_NAME}/share/docs/en_US/html"
204210
cd "${SOURCEDIR}/docs/en_US" || exit
205211
python3 build_code_snippet.py
206-
SYS_PYTHONPATH=$("${SYSTEM_PYTHON_PATH}" -c "import sys; print(':'.join([p for p in sys.path if p]))")
207-
# shellcheck disable=SC2153
208-
PYTHONPATH=$PYTHONPATH:${SYS_PYTHONPATH} python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
212+
"${SYSTEM_PYTHON_PATH}" -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
209213
}
210214

211215
_copy_code() {

0 commit comments

Comments
 (0)