Skip to content

Commit 8c7a137

Browse files
committed
Add the ability to build Python 3.11 and 3.12
Signed-off-by: Stephen Brennan <[email protected]>
1 parent b498ef1 commit 8c7a137

File tree

1 file changed

+82
-8
lines changed

1 file changed

+82
-8
lines changed

buildrpm/python-drgn-tools.spec

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Copyright (c) 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
%if 0%{?rhel} == 8 || 0%{?rhel} == 9
4+
%global with_python311 1
5+
%global with_python312 1
6+
%else
7+
%global with_python311 0
8+
%global with_python312 0
9+
%endif
10+
11+
%if %{with_python311}
12+
%global __python311 /usr/bin/python3.11
13+
%global python311_sitelib /usr/lib/python3.11/site-packages
14+
%endif
15+
16+
%if %{with_python312}
17+
%global __python312 /usr/bin/python3.12
18+
%global python312_sitelib /usr/lib/python3.12/site-packages
19+
%endif
20+
21+
322
Name: python-drgn-tools
423
Version: 1.1.0
524
Release: 1%{?dist}
@@ -15,8 +34,20 @@ BuildRequires: python%{python3_pkgversion}-devel
1534
BuildRequires: python%{python3_pkgversion}-setuptools
1635
BuildRequires: python%{python3_pkgversion}-pip
1736
BuildRequires: python%{python3_pkgversion}-wheel
18-
19-
%global python_wheelname drgn_tools-%{version}-py3-none-any.whl
37+
%if %{with_python311}
38+
BuildRequires: python3.11-devel
39+
BuildRequires: python3.11-setuptools
40+
BuildRequires: python3.11-pip
41+
BuildRequires: python3.11-wheel
42+
%endif
43+
%if %{with_python312}
44+
BuildRequires: python3.12-devel
45+
BuildRequires: python3.12-setuptools
46+
BuildRequires: python3.12-pip
47+
BuildRequires: python3.12-wheel
48+
%endif
49+
50+
%global platform_python %{__python3}
2051

2152
%global _description %{expand:
2253
drgn-tools extends the drgn debugger with scripts & helpers developed by the
@@ -25,23 +56,52 @@ allows users to extract diagnostic information from a kernel core dump, or from
2556
a running kernel image (via /proc/kcore).}
2657
%description %{_description}
2758

28-
%package -n drgn-tools
29-
Summary: %{summary}
3059
# The drgn dependency can be fulfilled by drgn with, or without, CTF support.
3160
# However, drgn-tools is tied to specific drgn releases.
32-
Requires: drgn >= 0.0.25, drgn < 0.0.30
61+
%global drgn_min 0.0.25
62+
%global drgn_max 0.0.30
63+
64+
%package -n drgn-tools
65+
Summary: %{summary}
66+
Requires: drgn >= %{drgn_min}, drgn < %{drgn_max}
3367
%description -n drgn-tools %{_description}
3468

69+
%if %{with_python311}
70+
%package -n python3.11-drgn-tools
71+
Summary: %{summary}
72+
Requires: python3.11-drgn >= %{drgn_min}, python3.11-drgn < %{drgn_max}
73+
%description -n python3.11-drgn-tools %{_description}
74+
%endif
75+
76+
%if %{with_python312}
77+
%package -n python3.12-drgn-tools
78+
Summary: %{summary}
79+
Requires: python3.12-drgn >= %{drgn_min}, python3.12-drgn < %{drgn_max}
80+
%description -n python3.12-drgn-tools %{_description}
81+
%endif
82+
3583
%prep
3684
%autosetup -n drgn-tools-%{version}
3785
echo '__version__ = "%{version}"' > drgn_tools/_version.py
3886

3987
%build
40-
%py3_build_wheel
88+
%py3_build
4189

4290

4391
%install
44-
%py3_install_wheel %{python_wheelname}
92+
# Install alternative Python versions first, so that the corelens script points
93+
# to the last one which is installed: the platform python.
94+
%if %{with_python311}
95+
%global __python3 %{__python311}
96+
%py3_install
97+
%endif
98+
%if %{with_python312}
99+
%global __python3 %{__python312}
100+
%py3_install
101+
%endif
102+
%global __python3 %{platform_python}
103+
104+
%py3_install
45105
gzip man/corelens.1
46106
install -m644 -D man/corelens.1.gz %{buildroot}%{_mandir}/man1/corelens.1.gz
47107

@@ -52,11 +112,25 @@ rm %{buildroot}/usr/bin/DRGN
52112

53113
%files -n drgn-tools
54114
%license LICENSE.txt
55-
%{python3_sitelib}/drgn_tools-*.dist-info/
115+
%{python3_sitelib}/drgn_tools-*.egg-info/
56116
%{python3_sitelib}/drgn_tools/*
57117
/usr/bin/corelens
58118
%{_mandir}/man1/corelens.1.gz
59119

120+
%if %{with_python311}
121+
%files -n python3.11-drgn-tools
122+
%license LICENSE.txt
123+
%{python311_sitelib}/drgn_tools-*.egg-info/
124+
%{python311_sitelib}/drgn_tools/*
125+
%endif
126+
127+
%if %{with_python312}
128+
%files -n python3.12-drgn-tools
129+
%license LICENSE.txt
130+
%{python312_sitelib}/drgn_tools-*.egg-info/
131+
%{python312_sitelib}/drgn_tools/*
132+
%endif
133+
60134
%changelog
61135
* Tue Aug 27 2024 Stephen Brennan <[email protected]> - 1.1.0-1
62136
- Update to 1.1.0

0 commit comments

Comments
 (0)