-
Notifications
You must be signed in to change notification settings - Fork 58
/
gcc-python-plugin.spec
402 lines (321 loc) · 9.5 KB
/
gcc-python-plugin.spec
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
Name: gcc-python-plugin
Version: 0.17
Release: 1%{?dist}
Summary: GCC plugin that embeds Python
Group: Development/Languages
License: GPLv3+
URL: https://fedorahosted.org/gcc-python-plugin/
Source0: https://fedorahosted.org/releases/g/c/gcc-python-plugin/gcc-python-plugin-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: gcc-plugin-devel
# gcc 4.6.1's plugin/include/double-int.h includes "gmp.h", but on Fedora,
# gmp-devel isn't yet listed in the requirements of gcc-plugin-devel
# For now, explicitly require it:
BuildRequires: gmp-devel
# Filed as https://bugzilla.redhat.com/show_bug.cgi?id=725569
# Various python runtimes to build the plugin against:
BuildRequires: python-devel
BuildRequires: python-debug
BuildRequires: python3-devel
BuildRequires: python3-debug
# "six" is used at buildtime:
BuildRequires: python-six
BuildRequires: python3-six
# sphinx is used for building documentation:
BuildRequires: python-sphinx
# pygments is used when running the selftests:
BuildRequires: python-pygments
BuildRequires: python3-pygments
# lxml is used when running the selftests:
BuildRequires: python-lxml
BuildRequires: python3-lxml
%global gcc_plugins_dir %(gcc --print-file-name=plugin)
%description
Plugins for embedding various versions of Python within GCC
%package -n gcc-python-plugin-c-api
Summary: Shared library to make it easier to write GCC plugins
Group: Development/Languages
%description -n gcc-python-plugin-c-api
Shared library to make it easier to write GCC plugins
%package -n gcc-python2-plugin
Summary: GCC plugin embedding Python 2
Group: Development/Languages
Requires: python-six
Requires: python-pygments
Requires: python-lxml
Requires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}
%description -n gcc-python2-plugin
GCC plugin embedding Python 2
%package -n gcc-python3-plugin
Summary: GCC plugin embedding Python 3
Group: Development/Languages
Requires: python3-six
Requires: python3-pygments
Requires: python3-lxml
Requires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}
%description -n gcc-python3-plugin
GCC plugin embedding Python 3
%package -n gcc-python2-debug-plugin
Summary: GCC plugin embedding Python 2 debug build
Group: Development/Languages
Requires: python-six
Requires: python-pygments
Requires: python-lxml
Requires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}
%description -n gcc-python2-debug-plugin
GCC plugin embedding debug build of Python 2
%package -n gcc-python3-debug-plugin
Summary: GCC plugin embedding Python 3 debug build
Group: Development/Languages
Requires: python3-six
Requires: python3-pygments
Requires: python3-lxml
Requires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}
%description -n gcc-python3-debug-plugin
GCC plugin embedding debug build of Python 3
%package docs
Summary: API documentation for the GCC Python plugin
Group: Development/Languages
%description docs
This package contains API documentation for the GCC Python plugin
%prep
%setup -q
# We will be building the plugin 4 times, each time against a different
# Python runtime
#
# The plugin doesn't yet cleanly support srcdir != builddir, so for now
# make 4 separate copies of the source, once for each build
PrepPlugin() {
PluginName=$1
BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName
rm -rf $BuildDir
cp -a . $BuildDir
}
PrepPlugin \
python2
PrepPlugin \
python2_debug
PrepPlugin \
python3
PrepPlugin \
python3_debug
%build
BuildPlugin() {
PythonExe=$1
PythonConfig=$2
PluginDso=$3
PluginName=$4
BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName
pushd $BuildDir
make \
%{?_smp_mflags} \
PLUGIN_NAME=$PluginName \
PLUGIN_DSO=$PluginDso \
PYTHON=$PythonExe \
PYTHON_CONFIG=$PythonConfig \
PLUGIN_PYTHONPATH=%{gcc_plugins_dir}/$PluginName \
plugin print-gcc-version
popd
}
BuildPlugin \
python \
python-config \
python2.so \
python2
BuildPlugin \
python-debug \
python-debug-config \
python2_debug.so \
python2_debug
BuildPlugin \
python3 \
python3-config \
python3.so \
python3
BuildPlugin \
python3-debug \
/usr/bin/python3.?dm-config \
python3_debug.so \
python3_debug
# Documentation:
cd docs
make html
# Avoid having a hidden file in the payload:
rm _build/html/.buildinfo
make man
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{gcc_plugins_dir}
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1
InstallPlugin() {
PythonExe=$1
PythonConfig=$2
PluginDso=$3
PluginName=$4
BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName
pushd $BuildDir
make install \
DESTDIR=$RPM_BUILD_ROOT \
PLUGIN_NAME=$PluginName \
PLUGIN_DSO=$PluginDso
popd
# (doing the above actually installs each build's copy of libgccapi.so,
# all to the same location, but they should all be identical, so that's
# OK)
}
InstallPlugin \
python \
python-config \
python2.so \
python2
InstallPlugin \
python-debug \
python-debug-config \
python2_debug.so \
python2_debug
InstallPlugin \
python3 \
python3-config \
python3.so \
python3
InstallPlugin \
python3-debug \
python3.4dm-config \
python3_debug.so \
python3_debug
%clean
rm -rf $RPM_BUILD_ROOT
%check
CheckPlugin() {
PythonExe=$1
PythonConfig=$2
PluginDso=$3
PluginName=$4
SelftestArgs=$5
BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName
pushd $BuildDir
# Run the selftests:
LD_LIBRARY_PATH=gcc-c-api \
PLUGIN_NAME=$PluginName \
$PythonExe run-test-suite.py $SelftestArgs
LD_LIBRARY_PATH=gcc-c-api \
PLUGIN_NAME=$PluginName \
$PythonExe testcpychecker.py -v
popd
}
# Selftest for python2 (optimized) build
# All tests ought to pass:
CheckPlugin \
python \
python-config \
python2.so \
python2 \
%{nil}
# Selftest for python2-debug build:
# Disable the cpychecker tests for now: somewhat ironically, the extra
# instrumentation in the debug build breaks the selftests for the refcount
# tracker. (specifically, handling of _Py_RefTotal):
#
# Failed tests:
# tests/cpychecker/refcounts/correct_py_none
# tests/cpychecker/refcounts/correct_decref
# tests/cpychecker/refcounts/use_after_dealloc
# tests/cpychecker/refcounts/returning_dead_object
# tests/cpychecker/refcounts/too_many_increfs
# tests/cpychecker/refcounts/loop_n_times
#
CheckPlugin \
python-debug \
python-debug-config \
python2_debug.so \
python2_debug \
"-x tests/cpychecker"
# Selftest for python3 (optimized) build:
# Disable the cpychecker tests for now:
# Failed tests:
# tests/cpychecker/PyArg_ParseTuple/incorrect_codes_S_and_U
# tests/cpychecker/PyArg_ParseTuple/correct_codes_S_and_U
# tests/cpychecker/refcounts/correct_decref
# tests/cpychecker/refcounts/fold_conditional
# tests/cpychecker/refcounts/use_after_dealloc
# tests/cpychecker/refcounts/missing_decref
# tests/cpychecker/refcounts/returning_dead_object
# tests/cpychecker/refcounts/too_many_increfs
# tests/cpychecker/refcounts/loop_n_times
#
CheckPlugin \
python3 \
python3-config \
python3.so \
python3 \
"-x tests/cpychecker"
# Selftest for python3-debug build:
# (shares the issues of the above)
CheckPlugin \
python3-debug \
python3.4dm-config \
python3_debug.so \
python3_debug \
"-x tests/cpychecker"
%files -n gcc-python-plugin-c-api
%{gcc_plugins_dir}/libgcc-c-api.so
%files -n gcc-python2-plugin
%defattr(-,root,root,-)
%doc COPYING README.rst
%{_bindir}/gcc-with-python2
%{gcc_plugins_dir}/python2.so
%{gcc_plugins_dir}/python2
%doc %{_mandir}/man1/gcc-with-python2.1.gz
%files -n gcc-python3-plugin
%defattr(-,root,root,-)
%doc COPYING README.rst
%{_bindir}/gcc-with-python3
%{gcc_plugins_dir}/python3.so
%{gcc_plugins_dir}/python3
%doc %{_mandir}/man1/gcc-with-python3.1.gz
%files -n gcc-python2-debug-plugin
%defattr(-,root,root,-)
%doc COPYING README.rst
%{_bindir}/gcc-with-python2_debug
%{gcc_plugins_dir}/python2_debug.so
%{gcc_plugins_dir}/python2_debug
%doc %{_mandir}/man1/gcc-with-python2_debug.1.gz
%files -n gcc-python3-debug-plugin
%defattr(-,root,root,-)
%doc COPYING README.rst
%{_bindir}/gcc-with-python3_debug
%{gcc_plugins_dir}/python3_debug.so
%{gcc_plugins_dir}/python3_debug
%doc %{_mandir}/man1/gcc-with-python3_debug.1.gz
%files docs
%defattr(-,root,root,-)
%doc COPYING
%doc docs/_build/html
# Example scripts:
%doc examples
%changelog
* Mon Feb 6 2012 David Malcolm <dmalcolm@redhat.com> - 0.9-1
- 0.9
* Tue Jan 10 2012 David Malcolm <dmalcolm@redhat.com> - 0.8-1
- 0.8
* Tue Aug 2 2011 David Malcolm <dmalcolm@redhat.com> - 0.6-1
- 0.6
* Wed Jul 27 2011 David Malcolm <dmalcolm@redhat.com> - 0.5-1
- 0.5
- examples are now in an "examples" subdirectory
* Tue Jul 26 2011 David Malcolm <dmalcolm@redhat.com> - 0.4-1
- 0.4
- add requirement on pygments
- run the upstream test suites during %%check
* Mon Jul 25 2011 David Malcolm <dmalcolm@redhat.com> - 0.3-1
- add requirements on python-six and python3-six
- add %%check section (empty for now)
- set PYTHON and PLUGIN_PYTHONPATH during each build; install support files
into build-specific directories below the gcc plugin dir
- add helper gcc-with-python scripts, with man pages
- package the license
- add example scripts
- add explicit BR on gmp-devel (rhbz#725569)
* Tue May 24 2011 David Malcolm <dmalcolm@redhat.com> - 0.1-1
- initial packaging