Skip to content

Commit b893dee

Browse files
authored
Merge pull request #29 from jordimassaguerpla/add_release_tools
build(all): add pydeps release script
2 parents 6f1deb1 + 6dcdb19 commit b893dee

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

release/check_pyproject_toml.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
echo "Checking for deps in pyproject.toml"
3+
echo "Running uv sync.."
4+
uv sync
5+
RED='\033[0;31m'
6+
NC='\033[0m' # No Color
7+
OBS_PROJECTS="home:jordimassaguerpla:branch:systemsmanagement:Uyuni:AI science:machinelearning:mcp devel:languages:python"
8+
changes=0
9+
for i in $(uv pip list | tail -n 41 | cut -d" " -f1);do
10+
grep $i pyproject.toml > /dev/null
11+
if [ $? -ne 0 ];then # package not in pyproject
12+
found="FALSE"
13+
echo
14+
echo "$i not found in pyproject.toml"
15+
version_i=$(uv pip show $i | grep Version: | cut -d ":" -f2 | tr -s " " | cut -d" " -f2)
16+
echo "We need $i-$version_i (installed with uv/pip)"
17+
for p in $OBS_PROJECTS;do
18+
echo "Looking for python-$i in $p..."
19+
osc ls $p python-$i > /dev/null 2> /dev/null
20+
if [ $? -ne 0 ];then # package was not found
21+
echo "python-$i not found in obs://$p"
22+
else # package was found
23+
echo "python-$i found in obs://$p"
24+
version_p=$(osc cat $p python-$i python-$i.spec | grep Version: | cut -d":" -f2 | tr -s " " | cut -d" " -f2)
25+
echo "python-$i-$version_p in obs://$p"
26+
if [ "$version_i" == "$version_p" ];then
27+
echo "You can use the package from obs://$p"
28+
uv add $i==$version_i
29+
else # versions do not match
30+
echo "Installed version $version_i differ from packaged version $version_p in obs://$p. Trying to change installed version..."
31+
uv add $i==$version_p
32+
if [ $? -ne 0 ];then
33+
printf "${RED}I could not install $version_p. You need to change the package version in $p to $version_i ${NC}\n"
34+
fi # install error?
35+
fi # do versions not match?
36+
found="TRUE"
37+
break # package was found, no need to check more projects
38+
fi # was package found?
39+
done # loop projects
40+
if [ "$found" == "FALSE" ];then
41+
changes=$((changes+1))
42+
printf "${RED}Package $i was not found in $OBS_PROJECTS. You need to create a new package ${NC}\n"
43+
fi # package not found
44+
fi # package in pyproject
45+
done # loop installed packages
46+
if [ $changes -eq 0 ];then
47+
echo "Nothing to do"
48+
fi
49+

release/copy_deps.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
projects="devel:languages:python science:machinelearning:mcp"
2+
deps="systemsmanagement:Uyuni:AI:Deps"
3+
for p in *;do
4+
echo "# deps for $p"
5+
cd $p
6+
for project in $projects;do
7+
for i in $(osc buildinfo 2>/dev/null | grep project=\"${project}\" | cut -d\" -f2 | grep python311 | tr -s "311-" "-");do
8+
echo "osc copypac -e ${project} ${i} ${deps}:${project}"
9+
done
10+
done
11+
cd ..
12+
done

release/pydeps.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/python3.11
2+
3+
import os
4+
import tomllib
5+
6+
print(f"# List of python dependencies from pyprojec.toml generated by {os.path.basename(__file__)}")
7+
pyproject_toml = os.path.dirname(os.path.realpath(__file__)) + "/../pyproject.toml"
8+
pyprefix = "python311"
9+
with open(pyproject_toml, "rb") as f:
10+
data = tomllib.load(f)
11+
for i in data['project']['dependencies']:
12+
dep = i.replace("==", " = ")
13+
# the package is python-Authlib while the module is authlib
14+
dep = dep.replace("authlib", "Authlib")
15+
dep = dep.replace("markupsafe", "MarkupSafe")
16+
dep = dep.replace("pyyaml", "PyYAML")
17+
dep = dep.replace("werkzeug", "Werkzeug")
18+
print(f"Requires: {pyprefix}-{dep}")
19+
print("# End")

0 commit comments

Comments
 (0)