Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/sip/files/, dev-python/sip/
Date: Wed, 11 May 2022 16:43:57
Message-Id: 1652287422.58ee906da23e6e5e7d51289e45b33af9ca6f45e6.mgorny@gentoo
1 commit: 58ee906da23e6e5e7d51289e45b33af9ca6f45e6
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun May 8 12:50:12 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed May 11 16:43:42 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=58ee906d
7
8 dev-python/sip: Backport PEP517 argument passing support
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 dev-python/sip/files/sip-6.5.0-pep517-args.patch | 190 +++++++++++++++++++++++
13 dev-python/sip/sip-6.5.0-r1.ebuild | 36 +++++
14 2 files changed, 226 insertions(+)
15
16 diff --git a/dev-python/sip/files/sip-6.5.0-pep517-args.patch b/dev-python/sip/files/sip-6.5.0-pep517-args.patch
17 new file mode 100644
18 index 000000000000..c4d39dcf6156
19 --- /dev/null
20 +++ b/dev-python/sip/files/sip-6.5.0-pep517-args.patch
21 @@ -0,0 +1,190 @@
22 +Backport from https://www.riverbankcomputing.com/hg/sip/
23 +
24 +changeset: 2771:8543f04b374f
25 +branch: 6.6-maint
26 +tag: tip
27 +user: Phil Thompson <phil@××××××××××××××××××.com>
28 +date: Tue May 10 13:58:28 2022 +0100
29 +summary: Fixed the PEP571 backend to handle multiple instances of the same config
30 +
31 +changeset: 2769:c02af095a016
32 +branch: 6.6-maint
33 +user: Phil Thompson <phil@××××××××××××××××××.com>
34 +date: Sat May 07 15:18:14 2022 +0100
35 +summary: Fix an API backward incompatibility.
36 +
37 +changeset: 2768:98dbce3e62f1
38 +branch: 6.6-maint
39 +user: Phil Thompson <phil@××××××××××××××××××.com>
40 +date: Sat May 07 15:03:49 2022 +0100
41 +summary: Any config settings passed by a PEP 571 frontend are now used.
42 +
43 +diff -r 8583e2bb1b32 sipbuild/abstract_project.py
44 +--- a/sipbuild/abstract_project.py Thu Nov 25 18:15:32 2021 +0000
45 ++++ b/sipbuild/abstract_project.py Tue May 10 16:15:30 2022 +0200
46 +@@ -1,4 +1,4 @@
47 +-# Copyright (c) 2020, Riverbank Computing Limited
48 ++# Copyright (c) 2022, Riverbank Computing Limited
49 + # All rights reserved.
50 + #
51 + # This copy of SIP is licensed for use under the terms of the SIP License
52 +@@ -34,7 +34,7 @@
53 + """ This specifies the API of a project. """
54 +
55 + @classmethod
56 +- def bootstrap(cls, tool, tool_description=''):
57 ++ def bootstrap(cls, tool, tool_description='', arguments=None):
58 + """ Return an AbstractProject instance fully configured for a
59 + particular command line tool.
60 + """
61 +@@ -79,6 +79,10 @@
62 + "The project factory did not return an AbstractProject "
63 + "object")
64 +
65 ++ # We set this as an attribute rather than change the API of the ctor or
66 ++ # setup().
67 ++ project.arguments = arguments
68 ++
69 + # Complete the configuration of the project.
70 + project.setup(pyproject, tool, tool_description)
71 +
72 +diff -r 8583e2bb1b32 sipbuild/api.py
73 +--- a/sipbuild/api.py Thu Nov 25 18:15:32 2021 +0000
74 ++++ b/sipbuild/api.py Tue May 10 16:15:30 2022 +0200
75 +@@ -1,4 +1,4 @@
76 +-# Copyright (c) 2019, Riverbank Computing Limited
77 ++# Copyright (c) 2022, Riverbank Computing Limited
78 + # All rights reserved.
79 + #
80 + # This copy of SIP is licensed for use under the terms of the SIP License
81 +@@ -28,10 +28,8 @@
82 + def build_sdist(sdist_directory, config_settings=None):
83 + """ The PEP 517 hook for building an sdist from pyproject.toml. """
84 +
85 +- # Note that we ignore config_settings until we have a frontend that we can
86 +- # fully test with. (pip seems lacking at the moment.)
87 +-
88 +- project = AbstractProject.bootstrap('pep517')
89 ++ project = AbstractProject.bootstrap('sdist',
90 ++ arguments=_convert_config_settings(config_settings))
91 +
92 + # pip executes this in a separate process and doesn't handle exceptions
93 + # very well. However it does capture stdout and (eventually) show it to
94 +@@ -45,10 +43,8 @@
95 + def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
96 + """ The PEP 517 hook for building a wheel from pyproject.toml. """
97 +
98 +- # Note that we ignore config_settings until we have a frontend that we can
99 +- # fully test with. (pip seems lacking at the moment.)
100 +-
101 +- project = AbstractProject.bootstrap('pep517')
102 ++ project = AbstractProject.bootstrap('wheel',
103 ++ arguments=_convert_config_settings(config_settings))
104 +
105 + # pip executes this in a separate process and doesn't handle exceptions
106 + # very well. However it does capture stdout and (eventually) show it to
107 +@@ -57,3 +53,26 @@
108 + return project.build_wheel(wheel_directory)
109 + except Exception as e:
110 + handle_exception(e)
111 ++
112 ++
113 ++def _convert_config_settings(config_settings):
114 ++ """ Return any configuration settings from the frontend to a pseudo-command
115 ++ line.
116 ++ """
117 ++
118 ++ if config_settings is None:
119 ++ config_settings = {}
120 ++
121 ++ args = []
122 ++
123 ++ for name, value in config_settings.items():
124 ++ if value:
125 ++ if not isinstance(value, list):
126 ++ value = [value]
127 ++
128 ++ for m_value in value:
129 ++ args.append(name + '=' + m_value)
130 ++ else:
131 ++ args.append(name)
132 ++
133 ++ return args
134 +diff -r 8583e2bb1b32 sipbuild/configurable.py
135 +--- a/sipbuild/configurable.py Thu Nov 25 18:15:32 2021 +0000
136 ++++ b/sipbuild/configurable.py Tue May 10 16:15:30 2022 +0200
137 +@@ -1,4 +1,4 @@
138 +-# Copyright (c) 2021, Riverbank Computing Limited
139 ++# Copyright (c) 2022, Riverbank Computing Limited
140 + # All rights reserved.
141 + #
142 + # This copy of SIP is licensed for use under the terms of the SIP License
143 +@@ -244,7 +244,7 @@
144 + """
145 +
146 + # The tools that will build a set of bindings.
147 +- BUILD_TOOLS = ('build', 'install', 'pep517', 'wheel')
148 ++ BUILD_TOOLS = ('build', 'install', 'wheel')
149 +
150 + # All the valid tools.
151 + _ALL_TOOLS = BUILD_TOOLS + ('sdist', )
152 +diff -r 8583e2bb1b32 sipbuild/project.py
153 +--- a/sipbuild/project.py Thu Nov 25 18:15:32 2021 +0000
154 ++++ b/sipbuild/project.py Tue May 10 16:15:30 2022 +0200
155 +@@ -155,6 +155,7 @@
156 +
157 + # The current directory should contain the .toml file.
158 + self.root_dir = os.getcwd()
159 ++ self.arguments = None
160 + self.bindings = collections.OrderedDict()
161 + self.bindings_factories = []
162 + self.builder = None
163 +@@ -204,11 +205,6 @@
164 + def apply_user_defaults(self, tool):
165 + """ Set default values for user options that haven't been set yet. """
166 +
167 +- # If we are the backend to a 3rd-party frontend (most probably pip)
168 +- # then let it handle the verbosity of messages.
169 +- if self.verbose is None and tool == '':
170 +- self.verbose = True
171 +-
172 + # This is only used when creating sdist and wheel files.
173 + if self.name is None:
174 + self.name = self.metadata['name']
175 +@@ -569,14 +565,9 @@
176 + # Set the initial configuration from the pyproject.toml file.
177 + self._set_initial_configuration(pyproject, tool)
178 +
179 +- # Add any tool-specific command line options for (so far unspecified)
180 ++ # Add any tool-specific command line arguments for (so far unspecified)
181 + # parts of the configuration.
182 +- if tool != 'pep517':
183 +- self._configure_from_command_line(tool, tool_description)
184 +- else:
185 +- # Until pip improves it's error reporting we give the user all the
186 +- # help we can.
187 +- self.verbose = True
188 ++ self._configure_from_arguments(tool, tool_description)
189 +
190 + # Now that any help has been given we can report a problematic
191 + # pyproject.toml file.
192 +@@ -712,8 +703,8 @@
193 + for bindings in self.bindings.values():
194 + bindings.verify_configuration(tool)
195 +
196 +- def _configure_from_command_line(self, tool, tool_description):
197 +- """ Update the configuration from the user supplied command line. """
198 ++ def _configure_from_arguments(self, tool, tool_description):
199 ++ """ Update the configuration from any user supplied arguments. """
200 +
201 + from argparse import SUPPRESS
202 + from .argument_parser import ArgumentParser
203 +@@ -739,7 +730,7 @@
204 + bindings.add_command_line_options(parser, tool, all_options)
205 +
206 + # Parse the arguments and update the corresponding configurables.
207 +- args = parser.parse_args()
208 ++ args = parser.parse_args(self.arguments)
209 +
210 + for option, configurables in all_options.items():
211 + for configurable in configurables:
212
213 diff --git a/dev-python/sip/sip-6.5.0-r1.ebuild b/dev-python/sip/sip-6.5.0-r1.ebuild
214 new file mode 100644
215 index 000000000000..3f31cadaf6d1
216 --- /dev/null
217 +++ b/dev-python/sip/sip-6.5.0-r1.ebuild
218 @@ -0,0 +1,36 @@
219 +# Copyright 1999-2022 Gentoo Authors
220 +# Distributed under the terms of the GNU General Public License v2
221 +
222 +EAPI=8
223 +
224 +PYTHON_COMPAT=( python3_{8..10} )
225 +DISTUTILS_USE_SETUPTOOLS=rdepend
226 +inherit distutils-r1
227 +
228 +DESCRIPTION="Python bindings generator for C/C++ libraries"
229 +HOMEPAGE="https://www.riverbankcomputing.com/software/sip/ https://pypi.org/project/sip/"
230 +
231 +MY_P=${PN}-${PV/_pre/.dev}
232 +if [[ ${PV} == *_pre* ]]; then
233 + SRC_URI="https://dev.gentoo.org/~pesa/distfiles/${MY_P}.tar.gz"
234 +else
235 + SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${MY_P}.tar.gz"
236 +fi
237 +S=${WORKDIR}/${MY_P}
238 +
239 +LICENSE="|| ( GPL-2 GPL-3 SIP )"
240 +SLOT="5"
241 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~sparc ~x86"
242 +
243 +RDEPEND="
244 + !<dev-python/sip-4.19.25-r1[${PYTHON_USEDEP}]
245 + !=dev-python/sip-5.5.0-r0[${PYTHON_USEDEP}]
246 + dev-python/packaging[${PYTHON_USEDEP}]
247 + dev-python/toml[${PYTHON_USEDEP}]
248 +"
249 +
250 +distutils_enable_sphinx doc --no-autodoc
251 +
252 +PATCHES=(
253 + "${FILESDIR}"/${P}-pep517-args.patch
254 +)