Skip to content

Commit 5177ede

Browse files
Merge pull request #99 from fledge-iot/FOGL-9331
FOGL-9331 pip install package handling added to support for python 3.11 or higher
2 parents cc9172f + bd2d10c commit 5177ede

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/Debian/common/DEBIAN/postinst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,22 @@ copy_new_data () {
113113
}
114114

115115
install_pip3_packages () {
116-
python3 -m pip install --upgrade pip
117-
python3 -m pip install -r /usr/local/fledge/python/requirements.txt
116+
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
117+
PYTHON_MAJOR=$(echo "$PYTHON_VERSION" | cut -d. -f1)
118+
PYTHON_MINOR=$(echo "$PYTHON_VERSION" | cut -d. -f2)
119+
120+
FLAG=""
121+
# Set the FLAG only for Python versions 3.11 or higher
122+
if [ "$PYTHON_MAJOR" -gt 3 ] || { [ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -ge 11 ]; }; then
123+
FLAG="--break-system-packages"
124+
fi
125+
126+
# Install pip and packages with or without the flag
127+
python3 -m pip install --upgrade pip $FLAG
128+
python3 -m pip install -r /usr/local/fledge/python/requirements.txt $FLAG
118129
}
119130

131+
120132
# Call Fledge package update script
121133
# Any message will be written by called update script
122134
call_package_update_script () {

0 commit comments

Comments
 (0)