Skip to content

Commit f8f04c9

Browse files
committed
fix: setuptools_scm version detection for EL10/fc42+
- Add pyproject.toml with [tool.setuptools_scm] configuration - Update .git_archival.txt to modern format (node, node-date, describe-name) - Set SETUPTOOLS_SCM_PRETEND_VERSION in spec %build/%install sections - Fix __about__.py version to be a string instead of integer - Use spec version for non-tagged builds instead of resetting to 0 Fixes RPM build failures on EL10/fc42+ where setuptools_scm 6.0+ requires proper configuration to parse version from git archives.
1 parent cd4b69a commit f8f04c9

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

.git_archival.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
ref-names: $Format:%D$
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
4+
ref-names: $Format:%D$

fds.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ sed -i '/ipaddress;/d' setup.py
141141

142142

143143
%build
144+
# Set version for setuptools_scm in case .git_archival.txt parsing fails
145+
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
144146
%if %{with python2}
145147
%py2_build
146148
%endif
@@ -154,6 +156,8 @@ pandoc -s -t man README.md -o %{name}.1
154156

155157

156158
%install
159+
# Set version for setuptools_scm in case .git_archival.txt parsing fails
160+
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
157161
%if %{with python2}
158162
%py2_install
159163
%endif

fds/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = 0
1+
__version__ = "0.0.0"

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]
6+
fallback_version = "0.0.0"

utils/version-from-tag.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,34 @@
33
# Print what is being run:
44
set -x
55

6+
PKG=$(basename *.spec .spec)
7+
68
if TAG=$(git describe --exact-match --tags "$(git log -n1 --pretty='%h')" 2>/dev/null); then
79
VER=$(echo "${TAG}" | grep --perl-regexp --only-matching '\d+\.\d+\.\d+')
10+
sed -i "s@Version:.*@Version: ${VER}@" "${PKG}.spec"
811
else
9-
TAG="v0"
10-
VER=0
12+
# For non-tagged builds, use the version from spec file (don't reset to 0)
13+
VER=$(awk '/^Version:/ {print $2}' "${PKG}.spec")
14+
TAG="v${VER}"
1115
fi
1216

13-
PKG=$(basename *.spec .spec)
14-
15-
sed -i "s@Version:.*@Version: ${VER}@" "${PKG}.spec"
16-
1717
echo "Creating github-like archive from current checkout, for rpmbuild"
18-
# by our convention, the spec file in git has Version: 0, so it will extract to <name>-0
18+
# The spec file in git has a version number, tagged builds update it from the tag
1919
# first create subst like ref-names: HEAD -> master, tag: v0.0.9 in .git_archival.txt
2020
# because we are creating archive ourselves
2121
# Build name is extracted dir name (without v!)
2222
BUILD_NAME="${PKG}-${VER}"
2323
mkdir "/tmp/${BUILD_NAME}"
2424
cp -aRp ./* "/tmp/${BUILD_NAME}/"
25-
echo "ref-names: HEAD -> master, tag: ${TAG}" > "/tmp/${BUILD_NAME}/.git_archival.txt"
25+
# Create .git_archival.txt with format expected by setuptools_scm 6.0+
26+
NODE=$(git rev-parse HEAD)
27+
NODE_DATE=$(git log -1 --format=%cI)
28+
cat > "/tmp/${BUILD_NAME}/.git_archival.txt" << EOF
29+
node: ${NODE}
30+
node-date: ${NODE_DATE}
31+
describe-name: ${TAG}
32+
ref-names: HEAD -> master, tag: ${TAG}
33+
EOF
2634
pushd /tmp || exit
2735
tar -czvf ./${TAG}.tar.gz "./${BUILD_NAME}"
2836
popd || exit

0 commit comments

Comments
 (0)