Skip to content

Commit bf847bc

Browse files
authored
Merge pull request #124 from duncanmmacleod/rpm-python3-devel
Add BuildRequires: python3-devel to ensure proper Python metadata is provided in RPM
2 parents b5f80a2 + 9bf809c commit bf847bc

File tree

2 files changed

+65
-46
lines changed

2 files changed

+65
-46
lines changed

.github/workflows/build.yml

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,45 @@ concurrency:
2020
cancel-in-progress: true
2121

2222
jobs:
23+
tarball:
24+
name: Tarball
25+
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Get source code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: '3.x'
36+
37+
- name: Install build requirements
38+
run: python -m pip install build
39+
40+
- name: Create distributions
41+
run: python -m build . --sdist --wheel --outdir .
42+
43+
- uses: actions/upload-artifact@v4
44+
with:
45+
name: tarball
46+
path: htgettoken-*.tar.*
47+
if-no-files-found: error
48+
49+
- uses: actions/upload-artifact@v4
50+
with:
51+
name: wheel
52+
path: htgettoken*.whl
53+
if-no-files-found: error
54+
2355
# -- RPM builds --
2456

2557
# Build the Source RPM
2658
rhel-srpm:
2759
name: EL ${{ matrix.version }} (${{ matrix.distro }}) source package
60+
needs:
61+
- tarball
2862
strategy:
2963
fail-fast: false
3064
matrix:
@@ -36,29 +70,23 @@ jobs:
3670
version: 9
3771
runs-on: ubuntu-latest
3872
container: ${{ matrix.distro }}:${{ matrix.version }}
73+
env:
74+
TARBALL: "htgettoken-*.tar.*"
3975
steps:
40-
- name: Get source code
41-
uses: actions/checkout@v3
76+
- name: Download tarball
77+
uses: actions/download-artifact@v4
78+
with:
79+
name: tarball
4280

4381
- name: Configure SRPM build tools
4482
run: |
45-
yum -y install \
46-
make \
47-
python-srpm-macros \
83+
dnf -y install \
84+
"*-srpm-macros" \
4885
rpm-build \
49-
yum-utils \
5086
;
5187
52-
- name: Create distributions
53-
run: make sources
54-
5588
- name: Create source package
56-
run: |
57-
rpmbuild \
58-
--define "_sourcedir $(pwd)" \
59-
--define "_srcrpmdir $(pwd)" \
60-
-bs \
61-
htgettoken.spec
89+
run: rpmbuild -ts --define "_srcrpmdir $(pwd)" ${TARBALL}
6290

6391
- uses: actions/upload-artifact@v4
6492
with:
@@ -96,24 +124,20 @@ jobs:
96124
dnf config-manager --set-enabled crb
97125
98126
- name: Configure EPEL
99-
run: yum -y install epel-release
127+
run: dnf -y install epel-release
100128

101129
- name: Install build tools
102130
run: |
103-
yum -y -q install \
131+
dnf -y -q install \
104132
rpm-build \
105-
yum-utils \
133+
"dnf-command(builddep)" \
106134
;
107135
108-
- name: Install epel-rpm-macros
109-
if: matrix.version < 9
110-
run: yum -y -q install epel-rpm-macros
111-
112136
- name: Install build dependencies
113-
run: yum-builddep -y htgettoken-*.src.rpm
137+
run: dnf builddep -y htgettoken-*.src.rpm
114138

115139
- name: List installed packages
116-
run: yum list installed
140+
run: dnf list installed
117141

118142
- name: Build binary packages
119143
run: |
@@ -164,10 +188,10 @@ jobs:
164188
name: rpm-${{ matrix.distro }}-${{ matrix.version }}
165189

166190
- name: Configure EPEL
167-
run: yum -y install epel-release
191+
run: dnf -y install epel-release
168192

169193
- name: Install RPMs
170-
run: yum -y install *.rpm
194+
run: dnf -y install *.rpm
171195

172196
- name: Test htgettoken
173197
run: /usr/bin/htgettoken --help

htgettoken.spec

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@ Prefix: %{_prefix}
1414
# https://codeload.github.com/fermitools/htgettoken/tar.gz/%%{version}
1515
Source0: %{name}-%{version}.tar.gz
1616

17-
# rpmbuild dependencies
18-
BuildRequires: python-rpm-macros
19-
BuildRequires: python3-rpm-macros
20-
2117
# build dependencies
22-
BuildRequires: python3
23-
BuildRequires: python%{python3_pkgversion}-pip
24-
BuildRequires: python%{python3_pkgversion}-setuptools
25-
BuildRequires: python%{python3_pkgversion}-wheel
18+
BuildRequires: python3-devel
19+
BuildRequires: python3dist(pip)
20+
BuildRequires: python3dist(setuptools)
21+
BuildRequires: python3dist(wheel)
2622

2723
# -- Package: htgettoken
2824

2925
# /usr/bin/htgettoken:
30-
Requires: python%{python3_pkgversion}-gssapi
31-
Requires: python%{python3_pkgversion}-paramiko
32-
Requires: python%{python3_pkgversion}-urllib3
26+
# For RHEL>=9 all requirements automatically provided by Python metadata
27+
%if 0%{?rhel} && 0%{?rhel} < 9
28+
Requires: python3dist(gssapi)
29+
Requires: python3dist(paramiko)
30+
Requires: python3dist(urllib3)
31+
%endif
3332
# /usr/bin/httokendecode:
3433
Requires: jq
3534
Recommends: scitokens-cpp
@@ -50,19 +49,11 @@ htgettoken gets OIDC bearer tokens by interacting with Hashicorp vault
5049
%autosetup -n %{name}-%{version}
5150

5251
%build
53-
%if 0%{?rhel} >= 9
5452
%py3_build_wheel
55-
%else
56-
%py3_build
57-
%endif
5853

5954
%install
6055
# install the Python project
61-
%if 0%{?rhel} >= 9
6256
%py3_install_wheel %{name}-%{version}-*.whl
63-
%else
64-
%py3_install
65-
%endif
6657
# link httokendecode to htdecodetoken
6758
(cd %{buildroot}%{_bindir}/; ln -s htdecodetoken httokendecode)
6859
# install man pages
@@ -71,7 +62,7 @@ gzip -c %{name}.1 >%{buildroot}%{_datadir}/man/man1/%{name}.1.gz
7162
for f in %{name} htdestroytoken htdecodetoken httokensh; do
7263
gzip -c $f.1 >%{buildroot}%{_datadir}/man/man1/$f.1.gz
7364
done
74-
ln -s htdecodetoken.1 %{buildroot}%{_datadir}/man/man1/httokendecode.1.gz
65+
ln -s htdecodetoken.1 %{buildroot}%{_datadir}/man/man1/httokendecode.1.gz
7566

7667
%clean
7768
rm -rf $RPM_BUILD_ROOT
@@ -80,6 +71,10 @@ rm -rf $RPM_BUILD_ROOT
8071

8172

8273
%changelog
74+
# - Add BuildRequires python3-devel to generate correct Python metadata.
75+
# - Remove explicit Requires for python dependencies, rely on Python metadata.
76+
# - Always build with wheels.
77+
8378
* Tue Feb 25 2025 Dave Dykstra <[email protected]> 2.1-1
8479
- Fix htdecodetoken to work with token files that do not end in a newline.
8580
- Support args in htgettoken.main() Python entry point.

0 commit comments

Comments
 (0)