|
| 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 | + |
0 commit comments