Skip to content

Commit 6485923

Browse files
committed
setools 4.5.1-2 update: fix setuptools compatibility
Setuptools now reports: /usr/lib/python3.12/site-packages/setuptools/__init__.py:94: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. !! ******************************************************************************** Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`. ******************************************************************************** !! dist.fetch_build_eggs(dist.setup_requires) /usr/lib/python3.12/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'test_suite' warnings.warn(msg) SETools upstream actually reworked `setup.py` in SELinuxProject/setools#131 ("setup.py: Move static definitions to pyproject.toml."), which is not part of a release yet. Backport the commits from this Pull Request to enable using recent setuptools when building and testing setools. Moreover, the testsuite requires module `pytestqt` provided by package `python-pytest-qt`, and `PySide6` or another PyQt Python package. Add the required dependencies to `checkdepends`. Finally, `python setup.py test` no longer works. Upstream README, https://github.com/SELinuxProject/setools/blob/4.5.1/README.md#unit-tests , documents: python setup.py build_ext -i pytest tests Use this instead. Fixes: #125
1 parent ef397de commit 6485923

File tree

3 files changed

+243
-7
lines changed

3 files changed

+243
-7
lines changed

.SRCINFO

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pkgbase = setools
22
pkgdesc = Policy analysis tools for SELinux
33
pkgver = 4.5.1
4-
pkgrel = 1
4+
pkgrel = 2
55
url = https://github.com/SELinuxProject/setools/wiki
66
arch = i686
77
arch = x86_64
@@ -10,7 +10,9 @@ pkgbase = setools
1010
license = GPL
1111
license = LGPL
1212
checkdepends = checkpolicy
13+
checkdepends = pyside6
1314
checkdepends = python-pytest
15+
checkdepends = python-pytest-qt
1416
makedepends = cython
1517
makedepends = python-tox
1618
depends = libsepol>=3.2
@@ -21,9 +23,11 @@ pkgbase = setools
2123
optdepends = python-graphviz: for seinfoflow, sedta, apol
2224
optdepends = python-pyqt6: needed for graphical tools
2325
optdepends = qt6-tools: display apol help with Qt Assistant
24-
provides = selinux-setools=4.5.1-1
26+
provides = selinux-setools=4.5.1-2
2527
conflicts = selinux-setools
2628
source = https://github.com/SELinuxProject/setools/releases/download/4.5.1/setools-4.5.1.tar.bz2
29+
source = 0001-setup.py-Move-static-definitions-to-pyproject.toml.patch
2730
sha256sums = 25e47d00bbffd6046f55409c9ba3b08d9b1d5788cc159ea247d9e0ced8e482e7
31+
sha256sums = 27fd3673709767038fcd5253f13a057dac48b5c6884e07507ff3f1461223cd21
2832

2933
pkgname = setools
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
From 2661b1af6d76a5c3c2fd2035b1f86314a1c10470 Mon Sep 17 00:00:00 2001
2+
From: Chris PeBenito <[email protected]>
3+
Date: Mon, 22 Apr 2024 12:07:48 -0400
4+
Subject: [PATCH] setup.py: Move static definitions to pyproject.toml.
5+
6+
Signed-off-by: Chris PeBenito <[email protected]>
7+
8+
Upstream commits
9+
https://github.com/SELinuxProject/setools/commit/2661b1af6d76a5c3c2fd2035b1f86314a1c10470
10+
and
11+
https://github.com/SELinuxProject/setools/commit/5718140bfe41f22bb2a5010168fa4aaa02e759fe
12+
---
13+
pyproject.toml | 65 +++++++++++++++++++++++++++++++++++++++++++++++++-
14+
setup.py | 37 +++-------------------------
15+
2 files changed, 67 insertions(+), 35 deletions(-)
16+
17+
diff --git a/pyproject.toml b/pyproject.toml
18+
index 08e61a330442..37e8226f4609 100644
19+
--- a/pyproject.toml
20+
+++ b/pyproject.toml
21+
@@ -1,7 +1,70 @@
22+
[build-system]
23+
-requires = ["setuptools", "Cython>=0.27"]
24+
+# setup also requires libsepol and libselinux
25+
+# C libraries and headers to compile.
26+
+requires = ["setuptools", "Cython>=0.29.14"]
27+
build-backend = "setuptools.build_meta"
28+
29+
+[project]
30+
+name = "setools"
31+
+version = "4.6.0.dev"
32+
+description="SELinux policy analysis tools."
33+
+authors = [{name = "Chris PeBenito", email="[email protected]"}]
34+
+readme = {file = "README.md", content-type = "text/markdown"}
35+
+urls.Homepage = "https://github.com/SELinuxProject/setools"
36+
+urls.Repository = "https://github.com/SELinuxProject/setools.git"
37+
+urls."Bug Tracker" = "https://github.com/SELinuxProject/setools/issues"
38+
+
39+
+keywords = ["SELinux",
40+
+ "SETools",
41+
+ "policy",
42+
+ "analysis",
43+
+ "seinfo",
44+
+ "sesearch",
45+
+ "sediff",
46+
+ "sedta",
47+
+ "seinfoflow",
48+
+ "apol"]
49+
+
50+
+# https://pypi.org/classifiers/
51+
+classifiers = ["Development Status :: 5 - Production/Stable",
52+
+ "Environment :: Console",
53+
+ "Environment :: X11 Applications :: Qt",
54+
+ "Intended Audience :: Information Technology",
55+
+ "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
56+
+ "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
57+
+ "Programming Language :: Cython",
58+
+ "Topic :: Security",
59+
+ "Topic :: Utilities",
60+
+ "Typing :: Typed"]
61+
+
62+
+requires-python=">=3.10"
63+
+# also requires libsepol.so and libselinux.so.
64+
+dependencies = ["setuptools"]
65+
+
66+
+optional-dependencies.analysis = ["networkx>=2.6",
67+
+ "pygraphviz"]
68+
+optional-dependencies.gui = ["PyQt6"]
69+
+optional-dependencies.test = ["tox"]
70+
+
71+
+[tool.setuptools]
72+
+include-package-data = false
73+
+script-files = ["apol",
74+
+ "sediff",
75+
+ "seinfo",
76+
+ "seinfoflow",
77+
+ "sesearch",
78+
+ "sedta",
79+
+ "sechecker"]
80+
+
81+
+[tool.setuptools.packages.find]
82+
+include = ["setools*"]
83+
+
84+
+[tool.setuptools.package-data]
85+
+"*" = ["*.css", "*.html", "perm_map", "py.typed"]
86+
+
87+
+[tool.setuptools.exclude-package-data]
88+
+"*" = ["*.c", "*.pyi", "*.pyx"]
89+
+
90+
91+
#
92+
# Coverage config
93+
diff --git a/setup.py b/setup.py
94+
index b2245ac7f33f..0b8e3e96d89e 100644
95+
--- a/setup.py
96+
+++ b/setup.py
97+
@@ -1,37 +1,34 @@
98+
#!/usr/bin/env python3
99+
100+
-import glob
101+
-from setuptools import Extension, setup
102+
import sys
103+
import os
104+
-from os.path import join
105+
-from contextlib import suppress
106+
+import glob
107+
+from pathlib import Path
108+
+
109+
+from setuptools import Extension, setup
110+
from Cython.Build import cythonize
111+
-import os.path
112+
113+
114+
# Library linkage
115+
-lib_dirs = ['.', '/usr/lib64', '/usr/lib', '/usr/local/lib']
116+
-include_dirs = []
117+
+lib_dirs: list[str] = ['.', '/usr/lib64', '/usr/lib', '/usr/local/lib']
118+
+include_dirs: list[str] = []
119+
120+
-with suppress(KeyError):
121+
- userspace_src = os.environ["USERSPACE_SRC"]
122+
- include_dirs.insert(0, userspace_src + "/libsepol/include")
123+
- include_dirs.insert(1, userspace_src + "/libselinux/include")
124+
- lib_dirs.insert(0, userspace_src + "/libsepol/src")
125+
- lib_dirs.insert(1, userspace_src + "/libselinux/src")
126+
+userspace_src = os.getenv("USERSPACE_SRC", "")
127+
+if userspace_src:
128+
+ userspace_path = Path(userspace_src)
129+
+ include_dirs.insert(0, str(userspace_path / "libsepol/include"))
130+
+ include_dirs.insert(1, str(userspace_path / "libselinux/include"))
131+
+ lib_dirs.insert(0, str(userspace_path / "libsepol/src"))
132+
+ lib_dirs.insert(1, str(userspace_path / "libselinux/src"))
133+
134+
-if sys.platform.startswith('darwin'):
135+
- macros=[('DARWIN',1)]
136+
-else:
137+
- macros=[]
138+
+macros: list[tuple[str, str | int]] = [('DARWIN',1)] if sys.platform.startswith('darwin') else []
139+
140+
# Code coverage. Enable this to get coverage in the cython code.
141+
-enable_coverage = bool(os.environ.get("SETOOLS_COVERAGE", False))
142+
+enable_coverage = bool(os.getenv("SETOOLS_COVERAGE", ""))
143+
if enable_coverage:
144+
macros.append(("CYTHON_TRACE", 1))
145+
146+
-cython_annotate = bool(os.environ.get("SETOOLS_ANNOTATE", False))
147+
+cython_annotate = bool(os.getenv("SETOOLS_ANNOTATE", ""))
148+
149+
ext_py_mods = [Extension('setools.policyrep', ['setools/policyrep.pyx'],
150+
include_dirs=include_dirs,
151+
@@ -53,53 +50,26 @@ ext_py_mods = [Extension('setools.policyrep', ['setools/policyrep.pyx'],
152+
'-Wwrite-strings',
153+
'-fno-exceptions'])]
154+
155+
-installed_data = [('share/man/man1', glob.glob("man/*.1"))]
156+
-
157+
-linguas = ["ru"]
158+
-
159+
-with suppress(KeyError):
160+
- linguas = os.environ["LINGUAS"].split(" ")
161+
+linguas: set[Path] = set(Path(p) for p in os.getenv("LINGUAS", "").split(" ") if p)
162+
+if not linguas:
163+
+ linguas.add(Path("ru"))
164+
+linguas.add(Path("."))
165+
166+
+base_source_path = Path("man") # below source root
167+
+base_target_path = Path("share/man") # below prefixdir, usually /usr or /usr/local
168+
+installed_data = list[tuple]()
169+
for lang in linguas:
170+
- if lang and os.path.exists(join("man", lang)):
171+
- installed_data.append((join('share/man', lang, 'man1'), glob.glob(join("man", lang, "*.1"))))
172+
+ source_path = base_source_path / lang
173+
+ if source_path.exists():
174+
+ for i in range(1, 9):
175+
+ installed_data.append((base_target_path / lang / f"man{i}",
176+
+ glob.glob(str(source_path / f"*.{i}"))))
177+
178+
-setup(name='setools',
179+
- version='4.5.1',
180+
- description='SELinux policy analysis tools.',
181+
- author='Chris PeBenito',
182+
- author_email='[email protected]',
183+
- url='https://github.com/SELinuxProject/setools',
184+
- packages=['setools', 'setools.checker', 'setools.diff', 'setoolsgui', 'setoolsgui.widgets',
185+
- 'setoolsgui.widgets.criteria', 'setoolsgui.widgets.details',
186+
- 'setoolsgui.widgets.models', 'setoolsgui.widgets.views'],
187+
- scripts=['apol', 'sediff', 'seinfo', 'seinfoflow', 'sesearch', 'sedta', 'sechecker'],
188+
- data_files=installed_data,
189+
- package_data={'': ['*.css', '*.html'],
190+
- 'setools': ['perm_map', 'policyrep.pyi', 'py.typed']},
191+
+# see pyproject.toml for most package options.
192+
+setup(data_files=installed_data,
193+
ext_modules=cythonize(ext_py_mods, include_path=['setools/policyrep'],
194+
annotate=cython_annotate,
195+
compiler_directives={"language_level": 3,
196+
"c_string_type": "str",
197+
"c_string_encoding": "ascii",
198+
- "linetrace": enable_coverage}),
199+
- test_suite='tests',
200+
- license='GPLv2+, LGPLv2.1+',
201+
- classifiers=[
202+
- 'Environment :: Console',
203+
- 'Environment :: X11 Applications :: Qt',
204+
- 'Intended Audience :: Information Technology',
205+
- 'Topic :: Security',
206+
- 'Topic :: Utilities',
207+
- ],
208+
- keywords='SELinux SETools policy analysis tools seinfo sesearch sediff sedta seinfoflow apol',
209+
- python_requires='>=3.10',
210+
- # setup also requires libsepol and libselinux
211+
- # C libraries and headers to compile.
212+
- setup_requires=['setuptools', 'Cython>=0.29.14'],
213+
- install_requires=['setuptools'],
214+
- extras_require={
215+
- "analysis": ["networkx>=2.6", "pygraphviz"],
216+
- "test": "tox"
217+
- }
218+
- )
219+
+ "linetrace": enable_coverage}))
220+
--
221+
2.46.0
222+

PKGBUILD

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
pkgname=setools
2121
pkgver=4.5.1
22-
pkgrel=1
22+
pkgrel=2
2323
pkgdesc="Policy analysis tools for SELinux"
2424
groups=('selinux')
2525
arch=('i686' 'x86_64' 'aarch64')
@@ -30,11 +30,19 @@ optdepends=('python-graphviz: for seinfoflow, sedta, apol'
3030
'python-pyqt6: needed for graphical tools'
3131
'qt6-tools: display apol help with Qt Assistant')
3232
makedepends=('cython' 'python-tox')
33-
checkdepends=('checkpolicy' 'python-pytest')
33+
checkdepends=('checkpolicy' 'pyside6' 'python-pytest' 'python-pytest-qt')
3434
conflicts=("selinux-${pkgname}")
3535
provides=("selinux-${pkgname}=${pkgver}-${pkgrel}")
36-
source=("https://github.com/SELinuxProject/setools/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.bz2")
37-
sha256sums=('25e47d00bbffd6046f55409c9ba3b08d9b1d5788cc159ea247d9e0ced8e482e7')
36+
source=("https://github.com/SELinuxProject/setools/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.bz2"
37+
0001-setup.py-Move-static-definitions-to-pyproject.toml.patch
38+
)
39+
sha256sums=('25e47d00bbffd6046f55409c9ba3b08d9b1d5788cc159ea247d9e0ced8e482e7'
40+
'27fd3673709767038fcd5253f13a057dac48b5c6884e07507ff3f1461223cd21')
41+
42+
prepare() {
43+
cd "${pkgname}"
44+
patch -Np1 -i "../0001-setup.py-Move-static-definitions-to-pyproject.toml.patch"
45+
}
3846

3947
build() {
4048
cd "${pkgname}"
@@ -44,7 +52,9 @@ build() {
4452

4553
check() {
4654
cd "${pkgname}"
47-
python setup.py test
55+
# Instructions from https://github.com/SELinuxProject/setools/blob/4.5.1/README.md#unit-tests
56+
python setup.py build_ext -i
57+
pytest tests
4858
}
4959

5060
package() {

0 commit comments

Comments
 (0)