summaryrefslogtreecommitdiff
path: root/dev-python/sip/files/sip-6.5.0-pep517-args.patch
blob: c4d39dcf615630b151e620427ed27ece4a269f00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
Backport from https://www.riverbankcomputing.com/hg/sip/

changeset:   2771:8543f04b374f
branch:      6.6-maint
tag:         tip
user:        Phil Thompson <phil@riverbankcomputing.com>
date:        Tue May 10 13:58:28 2022 +0100
summary:     Fixed the PEP571 backend to handle multiple instances of the same config

changeset:   2769:c02af095a016
branch:      6.6-maint
user:        Phil Thompson <phil@riverbankcomputing.com>
date:        Sat May 07 15:18:14 2022 +0100
summary:     Fix an API backward incompatibility.

changeset:   2768:98dbce3e62f1
branch:      6.6-maint
user:        Phil Thompson <phil@riverbankcomputing.com>
date:        Sat May 07 15:03:49 2022 +0100
summary:     Any config settings passed by a PEP 571 frontend are now used.

diff -r 8583e2bb1b32 sipbuild/abstract_project.py
--- a/sipbuild/abstract_project.py	Thu Nov 25 18:15:32 2021 +0000
+++ b/sipbuild/abstract_project.py	Tue May 10 16:15:30 2022 +0200
@@ -1,4 +1,4 @@
-# Copyright (c) 2020, Riverbank Computing Limited
+# Copyright (c) 2022, Riverbank Computing Limited
 # All rights reserved.
 #
 # This copy of SIP is licensed for use under the terms of the SIP License
@@ -34,7 +34,7 @@
     """ This specifies the API of a project. """
 
     @classmethod
-    def bootstrap(cls, tool, tool_description=''):
+    def bootstrap(cls, tool, tool_description='', arguments=None):
         """ Return an AbstractProject instance fully configured for a
         particular command line tool.
         """
@@ -79,6 +79,10 @@
                     "The project factory did not return an AbstractProject "
                     "object")
 
+        # We set this as an attribute rather than change the API of the ctor or
+        # setup().
+        project.arguments = arguments
+
         # Complete the configuration of the project.
         project.setup(pyproject, tool, tool_description)
 
diff -r 8583e2bb1b32 sipbuild/api.py
--- a/sipbuild/api.py	Thu Nov 25 18:15:32 2021 +0000
+++ b/sipbuild/api.py	Tue May 10 16:15:30 2022 +0200
@@ -1,4 +1,4 @@
-# Copyright (c) 2019, Riverbank Computing Limited
+# Copyright (c) 2022, Riverbank Computing Limited
 # All rights reserved.
 #
 # This copy of SIP is licensed for use under the terms of the SIP License
@@ -28,10 +28,8 @@
 def build_sdist(sdist_directory, config_settings=None):
     """ The PEP 517 hook for building an sdist from pyproject.toml. """
 
-    # Note that we ignore config_settings until we have a frontend that we can
-    # fully test with.  (pip seems lacking at the moment.)
-
-    project = AbstractProject.bootstrap('pep517')
+    project = AbstractProject.bootstrap('sdist',
+            arguments=_convert_config_settings(config_settings))
 
     # pip executes this in a separate process and doesn't handle exceptions
     # very well.  However it does capture stdout and (eventually) show it to
@@ -45,10 +43,8 @@
 def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
     """ The PEP 517 hook for building a wheel from pyproject.toml. """
 
-    # Note that we ignore config_settings until we have a frontend that we can
-    # fully test with.  (pip seems lacking at the moment.)
-
-    project = AbstractProject.bootstrap('pep517')
+    project = AbstractProject.bootstrap('wheel',
+            arguments=_convert_config_settings(config_settings))
 
     # pip executes this in a separate process and doesn't handle exceptions
     # very well.  However it does capture stdout and (eventually) show it to
@@ -57,3 +53,26 @@
         return project.build_wheel(wheel_directory)
     except Exception as e:
         handle_exception(e)
+
+
+def _convert_config_settings(config_settings):
+    """ Return any configuration settings from the frontend to a pseudo-command
+    line.
+    """
+
+    if config_settings is None:
+        config_settings = {}
+
+    args = []
+
+    for name, value in config_settings.items():
+        if value:
+            if not isinstance(value, list):
+                value = [value]
+
+            for m_value in value:
+                args.append(name + '=' + m_value)
+        else:
+            args.append(name)
+
+    return args
diff -r 8583e2bb1b32 sipbuild/configurable.py
--- a/sipbuild/configurable.py	Thu Nov 25 18:15:32 2021 +0000
+++ b/sipbuild/configurable.py	Tue May 10 16:15:30 2022 +0200
@@ -1,4 +1,4 @@
-# Copyright (c) 2021, Riverbank Computing Limited
+# Copyright (c) 2022, Riverbank Computing Limited
 # All rights reserved.
 #
 # This copy of SIP is licensed for use under the terms of the SIP License
@@ -244,7 +244,7 @@
     """
 
     # The tools that will build a set of bindings.
-    BUILD_TOOLS = ('build', 'install', 'pep517', 'wheel')
+    BUILD_TOOLS = ('build', 'install', 'wheel')
 
     # All the valid tools.
     _ALL_TOOLS = BUILD_TOOLS + ('sdist', )
diff -r 8583e2bb1b32 sipbuild/project.py
--- a/sipbuild/project.py	Thu Nov 25 18:15:32 2021 +0000
+++ b/sipbuild/project.py	Tue May 10 16:15:30 2022 +0200
@@ -155,6 +155,7 @@
 
         # The current directory should contain the .toml file.
         self.root_dir = os.getcwd()
+        self.arguments = None
         self.bindings = collections.OrderedDict()
         self.bindings_factories = []
         self.builder = None
@@ -204,11 +205,6 @@
     def apply_user_defaults(self, tool):
         """ Set default values for user options that haven't been set yet. """
 
-        # If we are the backend to a 3rd-party frontend (most probably pip)
-        # then let it handle the verbosity of messages.
-        if self.verbose is None and tool == '':
-            self.verbose = True
-
         # This is only used when creating sdist and wheel files.
         if self.name is None:
             self.name = self.metadata['name']
@@ -569,14 +565,9 @@
         # Set the initial configuration from the pyproject.toml file.
         self._set_initial_configuration(pyproject, tool)
 
-        # Add any tool-specific command line options for (so far unspecified)
+        # Add any tool-specific command line arguments for (so far unspecified)
         # parts of the configuration.
-        if tool != 'pep517':
-            self._configure_from_command_line(tool, tool_description)
-        else:
-            # Until pip improves it's error reporting we give the user all the
-            # help we can.
-            self.verbose = True
+        self._configure_from_arguments(tool, tool_description)
 
         # Now that any help has been given we can report a problematic
         # pyproject.toml file.
@@ -712,8 +703,8 @@
         for bindings in self.bindings.values():
             bindings.verify_configuration(tool)
 
-    def _configure_from_command_line(self, tool, tool_description):
-        """ Update the configuration from the user supplied command line. """
+    def _configure_from_arguments(self, tool, tool_description):
+        """ Update the configuration from any user supplied arguments. """
 
         from argparse import SUPPRESS
         from .argument_parser import ArgumentParser
@@ -739,7 +730,7 @@
             bindings.add_command_line_options(parser, tool, all_options)
 
         # Parse the arguments and update the corresponding configurables.
-        args = parser.parse_args()
+        args = parser.parse_args(self.arguments)
 
         for option, configurables in all_options.items():
             for configurable in configurables: