ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/python.spec
(Generate patch)

Comparing COMP/CMSDIST/python.spec (file contents):
Revision 1.56 by andreasp, Sat Nov 7 07:56:36 2009 UTC vs.
Revision 1.86 by davidlt, Mon Jun 18 11:41:33 2012 UTC

# Line 1 | Line 1
1 < ### RPM external python 2.4.2-CMS19
1 > ### RPM external python 2.7.3
2   ## INITENV +PATH PATH %i/bin
3   ## INITENV +PATH LD_LIBRARY_PATH %i/lib
4 + ## INITENV SETV PYTHON_LIB_SITE_PACKAGES lib/python%{python_major_version}/site-packages
5 + ## INITENV SETV PYTHONHASHSEED random
6   # OS X patches and build fudging stolen from fink
7 < %define closingbrace )
8 < %define online %(case %cmsplatf in *onl_*_*%closingbrace echo true;; *%closingbrace echo flase;; esac)
7 > %{expand:%%define python_major_version %(echo %realversion | cut -d. -f1,2)}
8 > %define online %(case %cmsplatf in (*onl_*_*) echo true;; (*) echo false;; esac)
9  
10   Requires: expat bz2lib db4 gdbm
11  
12   %if "%online" != "true"
13 < Requires: zlib openssl
13 > Requires: zlib openssl sqlite
14   %endif
15  
16   # FIXME: readline, crypt
17   # FIXME: gmp, panel, tk/tcl, x11
18  
19   Source0: http://www.python.org/ftp/%n/%realversion/Python-%realversion.tgz
20 < Patch0: python-Include-pyport.h
21 < Patch1: python-Lib-plat-mac-applesingle.py
20 < Patch2: python-Lib-site.py
21 < Patch3: python-Mac-OSX-Makefile
22 < Patch4: python-Makefile.pre.in
23 < Patch5: python-configure
24 < Patch6: python-setup.py
25 <
20 > Patch0: python-2.7.3-dont-detect-dbm
21 > Patch1: python-fix-macosx-relocation
22  
23   %prep
24   %setup -n Python-%realversion
25 < #%patch0
26 < #%patch1
27 < #%patch2
28 < #%patch3
29 < #%patch4
30 < #%patch5
31 < #%patch6
36 < perl -p -i -e "s|#!.*/usr/local/bin/python|#!/usr/bin/env python|" Lib/cgi.py
37 <
38 < %ifos darwin
39 < sed 's|@PREFIX@|%i|g' < %_sourcedir/python-osx | patch -p1
40 < %endif
25 > find . -type f | while read f; do
26 >  if head -n1 $f | grep -q /usr/local; then
27 >    perl -p -i -e "s|#!.*/usr/local/bin/python|#!/usr/bin/env python|" $f
28 >  else :; fi
29 > done
30 > %patch0 -p1
31 > %patch1 -p0
32  
33   %build
34   # Python is awkward about passing other include or library directories
# Line 51 | Line 42 | perl -p -i -e "s|#!.*/usr/local/bin/pyth
42   # see above for the commented-out list of packages that could be
43   # linked specifically, or could be built by ourselves, depending on
44   # whether we like to pick up system libraries or want total control.
45 < mkdir -p %i/include %i/lib
45 > #mkdir -p %i/include %i/lib
46 > mkdir -p %i/include %i/lib %i/bin
47  
48   %if "%online" != "true"
49 < %define extradirs $ZLIB_ROOT $OPENSSL_ROOT
49 > %define extradirs $ZLIB_ROOT $OPENSSL_ROOT $SQLITE_ROOT
50   %else
51   %define extradirs %{nil}
52   %endif
53  
54   dirs="$EXPAT_ROOT $BZ2LIB_ROOT $NCURSES_ROOT $DB4_ROOT $GDBM_ROOT %{extradirs}"
55  
56 + # We need to export it because setup.py now uses it to determine the actual
57 + # location of DB4, this was needed to avoid having it picked up from the system.
58 + export DB4_ROOT
59 +
60 + # Python's configure parses LDFLAGS and CPPFLAGS to look for aditional library and include directories
61   echo $dirs
62 + LDFLAGS=""
63 + CPPFLAGS=""
64   for d in $dirs; do
65 <  for f in $d/include/*; do
66 <    [ -e $f ] || continue
68 <    rm -f %i/include/$(basename $f)
69 <    ln -s $f %i/include
70 <  done
71 <  for f in $d/lib/*; do
72 <    [ -e $f ] || continue
73 <    rm -f %i/lib/$(basename $f)
74 <    ln -s $f %i/lib
75 <  done
65 >  LDFLAGS="$LDFLAGS -L $d/lib"
66 >  CPPFLAGS="$CPPFLAGS -I $d/include"
67   done
68 + export LDFLAGS
69 + export CPPFLAGS
70  
71   additionalConfigureOptions=""
72   case %cmsplatf in
# Line 85 | Line 78 | esac
78   ./configure --prefix=%i $additionalConfigureOptions --enable-shared \
79              --without-tkinter --disable-tkinter
80  
81 + # Modify pyconfig.h to match macros from GLIBC features.h on Linux machines.
82 + # _POSIX_C_SOURCE and _XOPEN_SOURCE macros are not identical anymore
83 + # starting GLIBC 2.10.1. Python.h is not included before standard headers
84 + # in CMSSW and pyconfig.h is not smart enough to detect already defined
85 + # macros on Linux. The following problem does not exists on BSD machines as
86 + # cdefs.h does not define these macros.
87 + case %cmsplatf in
88 +  slc6*)
89 +    rm -f cms_configtest.cpp
90 +    cat <<CMS_EOF > cms_configtest.cpp
91 + #include <features.h>
92 +
93 + int main() {
94 +  return 0;
95 + }
96 + CMS_EOF
97 +
98 +    FEATURES=$(g++ -dM -E -DGNU_GCC=1 -D_GNU_SOURCE=1 -D_DARWIN_SOURCE=1 cms_configtest.cpp \
99 +      | grep -E '_POSIX_C_SOURCE |_XOPEN_SOURCE ')
100 +    rm -f cms_configtest.cpp a.out
101 +
102 +    POSIX_C_SOURCE=$(echo "${FEATURES}" | grep _POSIX_C_SOURCE | cut -d ' ' -f 3)
103 +    XOPEN_SOURCE=$(echo "${FEATURES}" | grep _XOPEN_SOURCE | cut -d ' ' -f 3)
104 +
105 +    sed -ibak "s/\(#define _POSIX_C_SOURCE \)\(.*\)/\1${POSIX_C_SOURCE}/g" pyconfig.h
106 +    sed -ibak "s/\(#define _XOPEN_SOURCE \)\(.*\)/\1${XOPEN_SOURCE}/g" pyconfig.h
107 +  ;;
108 + esac
109 +
110   # The following is a kludge around the fact that the /usr/lib/libreadline.so
111   # symlink (for 32-bit lib) is missing on the 64bit machines
112 < %if "%cmsplatf" == "slc4_ia32_gcc345"
113 <  mkdir -p %{i}/lib
114 <  ln -s /usr/lib/libreadline.so.4.3 %{i}/lib/libreadline.so
115 < %endif
116 < %if "%cmsplatf" == "slc4_ia32_gcc412"
117 <  mkdir -p %{i}/lib
118 <  ln -s /usr/lib/libreadline.so.4.3 %{i}/lib/libreadline.so
97 < %endif
112 > case %cmsplatf in
113 >  slc4_ia32* )
114 >    mkdir -p %{i}/lib
115 >    ln -s /usr/lib/libreadline.so.4.3 %{i}/lib/libreadline.so
116 >  ;;
117 > esac
118 >
119   make %makeprocesses
120  
121   %install
122 + # We need to export it because setup.py now uses it to determine the actual
123 + # location of DB4, this was needed to avoid having it picked up from the system.
124 + export DB4_ROOT
125   make install
126   %define pythonv %(echo %realversion | cut -d. -f 1,2)
127  
128 < #if [ $(uname) = Darwin ]; then
129 <  # make install prefix=%i
130 <  # (cd Misc; /bin/rm -rf RPM)
131 <  # mkdir -p %i/share/doc/%n
132 <  # cp -R Demo Doc %i/share/doc/%n
133 <  # cp -R Misc Tools %i/lib/python%{pythonv}
134 < #  gcc -dynamiclib -all_load -single_module \
135 < #    -framework System -framework CoreServices -framework Foundation \
136 < #    %i/lib/python%{pythonv}/config/libpython%{pythonv}.a \
137 < #    -undefined dynamic_lookup \
138 < #    -o %i/lib/python%{pythonv}/config/libpython%{pythonv}.dylib \
139 < #    -install_name %i/lib/python%{pythonv}/config/libpython%{pythonv}.dylib \
140 < #    -current_version %{pythonv} -compatibility_version %{pythonv} -ldl
141 < #  ln -s libpython%{pythonv}.dylib %i/lib/python%{pythonv}/config/libpython%{pythonv}.dylib # for boost
142 <  # (cd %i/lib/python%{pythonv}/config; mv Makefile Makefile.orig;
143 <  #  sed 's|-fno-common||g' < Makefile.orig > Makefile; /bin/rm -f Makefile.orig)
144 < #fi
145 <
146 < perl -p -i -e "s|^#!.*python|#!/usr/bin/env python|" %{i}/bin/idle \
147 <                    %{i}/bin/pydoc \
148 <                    %{i}/bin/smtpd.py \
149 <                    %{i}/lib/python2.4/bsddb/dbshelve.py \
150 <                    %{i}/lib/python2.4/test/test_bz2.py \
151 <                    %{i}/lib/python2.4/test/test_largefile.py \
152 <                    %{i}/lib/python2.4/test/test_optparse.py
153 < # boost.spec rfio.spec
154 < #
155 < #
156 < rm  `find %{i}/lib -maxdepth 1 -mindepth 1 ! -name '*python*'`
157 < rm  `find %{i}/include -maxdepth 1 -mindepth 1 ! -name '*python*'`
128 > case %cmsplatf in
129 >  osx*)
130 >   make install prefix=%i
131 >   (cd Misc; /bin/rm -rf RPM)
132 >   mkdir -p %i/share/doc/%n
133 >   cp -R Demo Doc %i/share/doc/%n
134 >   cp -R Misc Tools %i/lib/python%{pythonv}
135 >   gcc -dynamiclib -all_load -single_module \
136 >    -framework System -framework CoreServices -framework Foundation \
137 >    %i/lib/python%{pythonv}/config/libpython%{pythonv}.a \
138 >    -undefined dynamic_lookup \
139 >    -o %i/lib/python%{pythonv}/config/libpython%{pythonv}.dylib \
140 >    -install_name %i/lib/python%{pythonv}/config/libpython%{pythonv}.dylib \
141 >    -current_version %{pythonv} -compatibility_version %{pythonv} -ldl
142 >   (cd %i/lib/python%{pythonv}/config
143 >    perl -p -i -e 's|-fno-common||g' Makefile)
144 >
145 >   find %i/lib/python%{pythonv}/config -name 'libpython*' -exec mv -f {} %i/lib \;
146 >  ;;
147 > esac
148 >
149 > perl -p -i -e "s|^#!.*python|#!/usr/bin/env python|" %{i}/bin/idle \
150 >                     %{i}/bin/pydoc \
151 >                     %{i}/bin/python-config \
152 >                     %{i}/bin/2to3 \
153 >                     %{i}/bin/python2.7-config \
154 >                     %{i}/bin/smtpd.py
155 >
156 > find %{i}/lib -maxdepth 1 -mindepth 1 ! -name '*python*' -exec rm {} \;
157 > find %{i}/include -maxdepth 1 -mindepth 1 ! -name '*python*' -exec rm {} \;
158 >
159 > # remove executable permission anything which is *.py script,
160 > # is executable, but does not start with she-bang so not valid
161 > # executable; this avoids problems with rpm 4.8+ find-requires
162 > find %i -name '*.py' -perm +0111 | while read f; do
163 >  if head -n1 $f | grep -q '"'; then chmod -x $f; else :; fi
164 > done
165  
135 %if "%online" == "true"
166   # remove tkinter that brings dependency on libtk:
167   find %{i}/lib -type f -name "_tkinter.so" -exec rm {} \;
138 %endif
168  
169 < # SCRAM ToolBox toolfile
170 < mkdir -p %i/etc/scram.d
171 < cat << \EOF_TOOLFILE >%i/etc/scram.d/%n
172 < <doc type=BuildSystem::ToolDoc version=1.0>
173 < <Tool name=%n version=%v>
174 < <lib name=python2.4>
175 < <Client>
176 < <Environment name=PYTHON_BASE default="%i"></Environment>
177 < <Environment name=LIBDIR default="$PYTHON_BASE/lib"></Environment>
178 < <Environment name=INCLUDE default="$PYTHON_BASE/include/python2.4"></Environment>
179 < <Environment name=PYTHON_COMPILE default="$PYTHON_BASE/lib/python2.4/compileall.py"></Environment>
180 < </Client>
181 < <use name=sockets>
182 < <Runtime name=PYTHONHOME value="$PYTHON_BASE">
183 < <Runtime name=PATH value="$PYTHON_BASE/bin" type=path>
184 < </Tool>
185 < EOF_TOOLFILE
169 > # Remove documentation, examples and test files.
170 > %define drop_files { %i/share %{i}/lib/python%{pythonv}/test \
171 >                   %{i}/lib/python%{pythonv}/distutils/tests \
172 >                   %{i}/lib/python%{pythonv}/json/tests \
173 >                   %{i}/lib/python%{pythonv}/ctypes/test \
174 >                   %{i}/lib/python%{pythonv}/sqlite3/test \
175 >                   %{i}/lib/python%{pythonv}/bsddb/test \
176 >                   %{i}/lib/python%{pythonv}/email/test \
177 >                   %{i}/lib/python%{pythonv}/lib2to3/tests }
178 >
179 > # Remove .pyo files
180 > find %i -name '*.pyo' -exec rm {} \;
181 >
182 > # Generate dependencies-setup.{sh,csh} so init.{sh,csh} picks full environment.
183 > mkdir -p %i/etc/profile.d
184 > : > %i/etc/profile.d/dependencies-setup.sh
185 > : > %i/etc/profile.d/dependencies-setup.csh
186 > for tool in $(echo %{requiredtools} | sed -e's|\s+| |;s|^\s+||'); do
187 >  root=$(echo $tool | tr a-z- A-Z_)_ROOT; eval r=\$$root
188 >  if [ X"$r" != X ] && [ -r "$r/etc/profile.d/init.sh" ]; then
189 >    echo "test X\$$root != X || . $r/etc/profile.d/init.sh" >> %i/etc/profile.d/dependencies-setup.sh
190 >    echo "test X\$$root != X || source $r/etc/profile.d/init.csh" >> %i/etc/profile.d/dependencies-setup.csh
191 >  fi
192 > done
193  
194   %post
195 < find $RPM_INSTALL_PREFIX/%pkgrel/lib -type l | xargs ls -la | sed -e "s|.*[ ]\(/.*\) -> \(.*\)| \2 \1|;s|[ ]/[^ ]*/external| $RPM_INSTALL_PREFIX/%cmsplatf/external|g" | xargs -n2 ln -sf
196 < %{relocateConfig}etc/scram.d/%n
195 > %{relocateConfig}lib/python2.6/config/Makefile
196 > %{relocateConfig}etc/profile.d/dependencies-setup.*sh

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines