issue5063: Fixes for building RPM on CentOS plus misc .spec file enhancements.
[python.git] / Misc / RPM / python-2.7.spec
blobde733239013c725f23d3d38458083d65ad163614
1 ##########################
2 # User-modifiable configs
3 ##########################
5 # Is the resulting package and the installed binary named "python" or
6 # "python2"?
7 #WARNING: Commenting out doesn't work. Last line is what's used.
8 %define config_binsuffix none
9 %define config_binsuffix 2.6
11 # Build tkinter? "auto" enables it if /usr/bin/wish exists.
12 #WARNING: Commenting out doesn't work. Last line is what's used.
13 %define config_tkinter no
14 %define config_tkinter yes
15 %define config_tkinter auto
17 # Use pymalloc? The last line (commented or not) determines wether
18 # pymalloc is used.
19 #WARNING: Commenting out doesn't work. Last line is what's used.
20 %define config_pymalloc no
21 %define config_pymalloc yes
23 # Enable IPV6?
24 #WARNING: Commenting out doesn't work. Last line is what's used.
25 %define config_ipv6 yes
26 %define config_ipv6 no
28 # Build shared libraries or .a library?
29 #WARNING: Commenting out doesn't work. Last line is what's used.
30 %define config_sharedlib no
31 %define config_sharedlib yes
33 # Location of the HTML directory.
34 %define config_htmldir /var/www/html/python
36 #################################
37 # End of user-modifiable configs
38 #################################
40 %define name python
41 #--start constants--
42 %define version 2.7a2
43 %define libvers 2.7
44 #--end constants--
45 %define release 1pydotorg
46 %define __prefix /usr
48 # kludge to get around rpm <percent>define weirdness
49 %define ipv6 %(if [ "%{config_ipv6}" = yes ]; then echo --enable-ipv6; else echo --disable-ipv6; fi)
50 %define pymalloc %(if [ "%{config_pymalloc}" = yes ]; then echo --with-pymalloc; else echo --without-pymalloc; fi)
51 %define binsuffix %(if [ "%{config_binsuffix}" = none ]; then echo ; else echo "%{config_binsuffix}"; fi)
52 %define include_tkinter %(if [ \\( "%{config_tkinter}" = auto -a -f /usr/bin/wish \\) -o "%{config_tkinter}" = yes ]; then echo 1; else echo 0; fi)
53 %define libdirname %(( uname -m | egrep -q '_64$' && [ -d /usr/lib64 ] && echo lib64 ) || echo lib)
54 %define sharedlib %(if [ "%{config_sharedlib}" = yes ]; then echo --enable-shared; else echo ; fi)
55 %define include_sharedlib %(if [ "%{config_sharedlib}" = yes ]; then echo 1; else echo 0; fi)
57 # detect if documentation is available
58 %define include_docs %(if [ -f "%{_sourcedir}/html-%{version}.tar.bz2" ]; then echo 1; else echo 0; fi)
60 Summary: An interpreted, interactive, object-oriented programming language.
61 Name: %{name}%{binsuffix}
62 Version: %{version}
63 Release: %{release}
64 License: Modified CNRI Open Source License
65 Group: Development/Languages
66 Source: Python-%{version}.tar.bz2
67 %if %{include_docs}
68 Source1: html-%{version}.tar.bz2
69 %endif
70 BuildRoot: %{_tmppath}/%{name}-%{version}-root
71 BuildPrereq: expat-devel
72 BuildPrereq: db4-devel
73 BuildPrereq: gdbm-devel
74 BuildPrereq: sqlite-devel
75 Prefix: %{__prefix}
76 Packager: Sean Reifschneider <jafo-rpms@tummy.com>
78 %description
79 Python is an interpreted, interactive, object-oriented programming
80 language. It incorporates modules, exceptions, dynamic typing, very high
81 level dynamic data types, and classes. Python combines remarkable power
82 with very clear syntax. It has interfaces to many system calls and
83 libraries, as well as to various window systems, and is extensible in C or
84 C++. It is also usable as an extension language for applications that need
85 a programmable interface. Finally, Python is portable: it runs on many
86 brands of UNIX, on PCs under Windows, MS-DOS, and OS/2, and on the
87 Mac.
89 %package devel
90 Summary: The libraries and header files needed for Python extension development.
91 Prereq: python%{binsuffix} = %{PACKAGE_VERSION}
92 Group: Development/Libraries
94 %description devel
95 The Python programming language's interpreter can be extended with
96 dynamically loaded extensions and can be embedded in other programs.
97 This package contains the header files and libraries needed to do
98 these types of tasks.
100 Install python-devel if you want to develop Python extensions. The
101 python package will also need to be installed. You'll probably also
102 want to install the python-docs package, which contains Python
103 documentation.
105 %if %{include_tkinter}
106 %package tkinter
107 Summary: A graphical user interface for the Python scripting language.
108 Group: Development/Languages
109 Prereq: python%{binsuffix} = %{PACKAGE_VERSION}-%{release}
111 %description tkinter
112 The Tkinter (Tk interface) program is an graphical user interface for
113 the Python scripting language.
115 You should install the tkinter package if you'd like to use a graphical
116 user interface for Python programming.
117 %endif
119 %package tools
120 Summary: A collection of development tools included with Python.
121 Group: Development/Tools
122 Prereq: python%{binsuffix} = %{PACKAGE_VERSION}-%{release}
124 %description tools
125 The Python package includes several development tools that are used
126 to build python programs. This package contains a selection of those
127 tools, including the IDLE Python IDE.
129 Install python-tools if you want to use these tools to develop
130 Python programs. You will also need to install the python and
131 tkinter packages.
133 %if %{include_docs}
134 %package docs
135 Summary: Python-related documentation.
136 Group: Development/Documentation
138 %description docs
139 Documentation relating to the Python programming language in HTML and info
140 formats.
141 %endif
143 %changelog
144 * Mon Dec 20 2004 Sean Reifschneider <jafo-rpms@tummy.com> [2.4-2pydotorg]
145 - Changing the idle wrapper so that it passes arguments to idle.
147 * Tue Oct 19 2004 Sean Reifschneider <jafo-rpms@tummy.com> [2.4b1-1pydotorg]
148 - Updating to 2.4.
150 * Thu Jul 22 2004 Sean Reifschneider <jafo-rpms@tummy.com> [2.3.4-3pydotorg]
151 - Paul Tiemann fixes for %{prefix}.
152 - Adding permission changes for directory as suggested by reimeika.ca
153 - Adding code to detect when it should be using lib64.
154 - Adding a define for the location of /var/www/html for docs.
156 * Thu May 27 2004 Sean Reifschneider <jafo-rpms@tummy.com> [2.3.4-2pydotorg]
157 - Including changes from Ian Holsman to build under Red Hat 7.3.
158 - Fixing some problems with the /usr/local path change.
160 * Sat Mar 27 2004 Sean Reifschneider <jafo-rpms@tummy.com> [2.3.2-3pydotorg]
161 - Being more agressive about finding the paths to fix for
162 #!/usr/local/bin/python.
164 * Sat Feb 07 2004 Sean Reifschneider <jafo-rpms@tummy.com> [2.3.3-2pydotorg]
165 - Adding code to remove "#!/usr/local/bin/python" from particular files and
166 causing the RPM build to terminate if there are any unexpected files
167 which have that line in them.
169 * Mon Oct 13 2003 Sean Reifschneider <jafo-rpms@tummy.com> [2.3.2-1pydotorg]
170 - Adding code to detect wether documentation is available to build.
172 * Fri Sep 19 2003 Sean Reifschneider <jafo-rpms@tummy.com> [2.3.1-1pydotorg]
173 - Updating to the 2.3.1 release.
175 * Mon Feb 24 2003 Sean Reifschneider <jafo-rpms@tummy.com> [2.3b1-1pydotorg]
176 - Updating to 2.3b1 release.
178 * Mon Feb 17 2003 Sean Reifschneider <jafo-rpms@tummy.com> [2.3a1-1]
179 - Updating to 2.3 release.
181 * Sun Dec 23 2001 Sean Reifschneider <jafo-rpms@tummy.com>
182 [Release 2.2-2]
183 - Added -docs package.
184 - Added "auto" config_tkinter setting which only enables tk if
185 /usr/bin/wish exists.
187 * Sat Dec 22 2001 Sean Reifschneider <jafo-rpms@tummy.com>
188 [Release 2.2-1]
189 - Updated to 2.2.
190 - Changed the extension to "2" from "2.2".
192 * Tue Nov 18 2001 Sean Reifschneider <jafo-rpms@tummy.com>
193 [Release 2.2c1-1]
194 - Updated to 2.2c1.
196 * Thu Nov 1 2001 Sean Reifschneider <jafo-rpms@tummy.com>
197 [Release 2.2b1-3]
198 - Changed the way the sed for fixing the #! in pydoc works.
200 * Wed Oct 24 2001 Sean Reifschneider <jafo-rpms@tummy.com>
201 [Release 2.2b1-2]
202 - Fixed missing "email" package, thanks to anonymous report on sourceforge.
203 - Fixed missing "compiler" package.
205 * Mon Oct 22 2001 Sean Reifschneider <jafo-rpms@tummy.com>
206 [Release 2.2b1-1]
207 - Updated to 2.2b1.
209 * Mon Oct 9 2001 Sean Reifschneider <jafo-rpms@tummy.com>
210 [Release 2.2a4-4]
211 - otto@balinor.mat.unimi.it mentioned that the license file is missing.
213 * Sun Sep 30 2001 Sean Reifschneider <jafo-rpms@tummy.com>
214 [Release 2.2a4-3]
215 - Ignacio Vazquez-Abrams pointed out that I had a spruious double-quote in
216 the spec files. Thanks.
218 * Wed Jul 25 2001 Sean Reifschneider <jafo-rpms@tummy.com>
219 [Release 2.2a1-1]
220 - Updated to 2.2a1 release.
221 - Changed idle and pydoc to use binsuffix macro
223 #######
224 # PREP
225 #######
226 %prep
227 %setup -n Python-%{version}
229 ########
230 # BUILD
231 ########
232 %build
233 echo "Setting for ipv6: %{ipv6}"
234 echo "Setting for pymalloc: %{pymalloc}"
235 echo "Setting for binsuffix: %{binsuffix}"
236 echo "Setting for include_tkinter: %{include_tkinter}"
237 echo "Setting for libdirname: %{libdirname}"
238 echo "Setting for sharedlib: %{sharedlib}"
239 echo "Setting for include_sharedlib: %{include_sharedlib}"
240 ./configure --enable-unicode=ucs4 %{sharedlib} %{ipv6} %{pymalloc} --prefix=%{__prefix}
241 make
243 ##########
244 # INSTALL
245 ##########
246 %install
247 # set the install path
248 echo '[install_scripts]' >setup.cfg
249 echo 'install_dir='"${RPM_BUILD_ROOT}%{__prefix}/bin" >>setup.cfg
251 [ -d "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
252 mkdir -p $RPM_BUILD_ROOT%{__prefix}/%{libdirname}/python%{libvers}/lib-dynload
253 make prefix=$RPM_BUILD_ROOT%{__prefix} install
255 # REPLACE PATH IN PYDOC
256 if [ ! -z "%{binsuffix}" ]
257 then
259 cd $RPM_BUILD_ROOT%{__prefix}/bin
260 mv pydoc pydoc.old
261 sed 's|#!.*|#!%{__prefix}/bin/env python'%{binsuffix}'|' \
262 pydoc.old >pydoc
263 chmod 755 pydoc
264 rm -f pydoc.old
268 # add the binsuffix
269 if [ ! -z "%{binsuffix}" ]
270 then
271 rm -f $RPM_BUILD_ROOT%{__prefix}/bin/python[0-9a-zA-Z]*
272 ( cd $RPM_BUILD_ROOT%{__prefix}/bin;
273 for file in *; do mv "$file" "$file"%{binsuffix}; done )
274 ( cd $RPM_BUILD_ROOT%{_mandir}/man1; mv python.1 python%{binsuffix}.1 )
277 ########
278 # Tools
279 echo '#!%{__prefix}/bin/env python%{binsuffix}' >${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix}
280 echo 'import os, sys' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix}
281 echo 'os.execvp("%{__prefix}/bin/python%{binsuffix}", ["%{__prefix}/bin/python%{binsuffix}", "%{__prefix}/lib/python%{libvers}/idlelib/idle.py"] + sys.argv[1:])' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix}
282 echo 'print "Failed to exec Idle"' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix}
283 echo 'sys.exit(1)' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix}
284 chmod 755 $RPM_BUILD_ROOT%{__prefix}/bin/idle%{binsuffix}
285 cp -a Tools $RPM_BUILD_ROOT%{__prefix}/%{libdirname}/python%{libvers}
287 # MAKE FILE LISTS
288 rm -f mainpkg.files
289 find "$RPM_BUILD_ROOT""%{__prefix}"/%{libdirname}/python%{libvers} -type f |
290 sed "s|^${RPM_BUILD_ROOT}|/|" |
291 grep -v -e '/python%{libvers}/config$' -e '_tkinter.so$' >mainpkg.files
292 find "$RPM_BUILD_ROOT""%{__prefix}"/bin -type f -o -type l |
293 sed "s|^${RPM_BUILD_ROOT}|/|" |
294 grep -v -e '/bin/2to3%{binsuffix}$' |
295 grep -v -e '/bin/pydoc%{binsuffix}$' |
296 grep -v -e '/bin/smtpd.py%{binsuffix}$' |
297 grep -v -e '/bin/idle%{binsuffix}$' >>mainpkg.files
299 rm -f tools.files
300 find "$RPM_BUILD_ROOT""%{__prefix}"/%{libdirname}/python%{libvers}/idlelib \
301 "$RPM_BUILD_ROOT""%{__prefix}"/%{libdirname}/python%{libvers}/Tools -type f |
302 sed "s|^${RPM_BUILD_ROOT}|/|" >tools.files
303 echo "%{__prefix}"/bin/2to3%{binsuffix} >>tools.files
304 echo "%{__prefix}"/bin/pydoc%{binsuffix} >>tools.files
305 echo "%{__prefix}"/bin/smtpd.py%{binsuffix} >>tools.files
306 echo "%{__prefix}"/bin/idle%{binsuffix} >>tools.files
308 ######
309 # Docs
310 %if %{include_docs}
311 mkdir -p "$RPM_BUILD_ROOT"%{config_htmldir}
313 cd "$RPM_BUILD_ROOT"%{config_htmldir}
314 bunzip2 < %{SOURCE1} | tar x
316 %endif
318 # fix the #! line in installed files
319 find "$RPM_BUILD_ROOT" -type f -print0 |
320 xargs -0 grep -l /usr/local/bin/python | while read file
322 FIXFILE="$file"
323 sed 's|^#!.*python|#!%{__prefix}/bin/env python'"%{binsuffix}"'|' \
324 "$FIXFILE" >/tmp/fix-python-path.$$
325 cat /tmp/fix-python-path.$$ >"$FIXFILE"
326 rm -f /tmp/fix-python-path.$$
327 done
329 # check to see if there are any straggling #! lines
330 find "$RPM_BUILD_ROOT" -type f | xargs egrep -n '^#! */usr/local/bin/python' \
331 | grep ':1:#!' >/tmp/python-rpm-files.$$ || true
332 if [ -s /tmp/python-rpm-files.$$ ]
333 then
334 echo '*****************************************************'
335 cat /tmp/python-rpm-files.$$
336 cat <<@EOF
337 *****************************************************
338 There are still files referencing /usr/local/bin/python in the
339 install directory. They are listed above. Please fix the .spec
340 file and try again. If you are an end-user, you probably want
341 to report this to jafo-rpms@tummy.com as well.
342 *****************************************************
343 @EOF
344 rm -f /tmp/python-rpm-files.$$
345 exit 1
347 rm -f /tmp/python-rpm-files.$$
349 ########
350 # CLEAN
351 ########
352 %clean
353 [ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT
354 rm -f mainpkg.files tools.files
356 ########
357 # FILES
358 ########
359 %files -f mainpkg.files
360 %defattr(-,root,root)
361 %doc Misc/README Misc/cheatsheet Misc/Porting
362 %doc LICENSE Misc/ACKS Misc/HISTORY Misc/NEWS
363 %{_mandir}/man1/python%{binsuffix}.1*
365 %attr(755,root,root) %dir %{__prefix}/include/python%{libvers}
366 %attr(755,root,root) %dir %{__prefix}/%{libdirname}/python%{libvers}/
367 %if %{include_sharedlib}
368 %{__prefix}/%{libdirname}/libpython*
369 %endif
371 %files devel
372 %defattr(-,root,root)
373 %{__prefix}/include/python%{libvers}/*.h
374 %{__prefix}/%{libdirname}/python%{libvers}/config
376 %files -f tools.files tools
377 %defattr(-,root,root)
379 %if %{include_tkinter}
380 %files tkinter
381 %defattr(-,root,root)
382 %{__prefix}/%{libdirname}/python%{libvers}/lib-tk
383 %{__prefix}/%{libdirname}/python%{libvers}/lib-dynload/_tkinter.so*
384 %endif
386 %if %{include_docs}
387 %files docs
388 %defattr(-,root,root)
389 %{config_htmldir}/*
390 %endif