Update logic to determine and set PyGObject version in pyproject.toml based on libgirepository apt package version

This commit is contained in:
Adnan Hodzic 2025-04-10 19:02:00 +02:00
parent 8870b62b17
commit 6789cb6ce4
2 changed files with 26 additions and 8 deletions

View File

@ -80,19 +80,35 @@ function tool_install {
detected_distro "Debian based"
VERSION=$(cat /etc/debian_version)
# https://github.com/AdnanHodzic/auto-cpufreq/pull/826
# install necessary debian dependencies
sudo apt update
# install necessary libgirepository debian package dependencies
# https://github.com/AdnanHodzic/auto-cpufreq/pull/826#issuecomment-2794549837
apt update
if apt-cache show libgirepository-2.0-dev > /dev/null 2>&1; then
echo "Installing libgirepository-2.0-dev ..."
sudo apt install -y libgirepository-2.0-dev
LIB_GI_REPO="libgirepository-2.0-dev"
PYGOBJECT_VER="^3.50.0"
else
echo "Installing libgirepository1.0-dev..."
sudo apt install -y libgirepository1.0-dev
LIB_GI_REPO="libgirepository1.0-dev"
# pin PYGOBJECT_VER to libgirepository1.0-dev
# https://github.com/AdnanHodzic/auto-cpufreq/issues/813#issuecomment-2712543486
PYGOBJECT_VER="3.50.0"
fi
echo $LIB_GI_REPO needs to be installed for version $VERSION
# Update PyGObject in pyproject.toml
# https://github.com/AdnanHodzic/auto-cpufreq/pull/826#issuecomment-2794549837
if [ -f ./pyproject.toml ]; then
if grep -q 'PyGObject *= *{[^}]*version *= *"' pyproject.toml; then
sed -i "s/\(PyGObject *= *{[^}]*version *= *\"\)[^\"]*\(.*\)/\1$PYGOBJECT_VER\2/" pyproject.toml
echo "PyGObject version updated to $PYGOBJECT_VER in pyproject.toml"
else
echo "Warning: Could not find PyGObject version entry in pyproject.toml!"
fi
else
echo "Error: pyproject.toml not found and PyGObject version not updated!"
fi
echo "$LIB_GI_REPO needs to be installed for version $VERSION"
echo '---- '
apt install -y python3-dev python3-pip python3-venv python3-setuptools dmidecode \
"$LIB_GI_REPO" libcairo2-dev libgtk-3-dev gcc

View File

@ -26,6 +26,8 @@ psutil = ">=6.0.0,<8.0.0"
click = "^8.1.0"
distro = "^1.8.0"
requests = "^2.32.3"
# PyObject version will be updated automatically for Debian based distro based on libgirepository
# apt package version: https://github.com/AdnanHodzic/auto-cpufreq/pull/826#issuecomment-2794549837
PyGObject = {version="3.50.0", optional=true}
urwid = "^2.6.16"
pyinotify = {git = "https://github.com/shadeyg56/pyinotify-3.12"}