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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines