ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/python.spec
Revision: 1.94
Committed: Tue Aug 21 07:53:36 2012 UTC (12 years, 8 months ago) by davidlt
Branch: MAIN
CVS Tags: CMSSW_6_0_1_PostLS1v2_patch4, CMSSW_6_0_1_PostLS1v2_patch3-slc5_amd64_gcc462, CMSSW_6_0_1_PostLS1v2_patch3, daForCMSSW_6_0_1_PostLS1v2_patch3-slc5_amd64_gcc462, CMSSW_6_0_1_PostLS1v2_patch2-slc5_amd64_gcc462, CMSSW_6_0_1_PostLS1v2_patch2, daForCMSSW_6_0_1_PostLS1v2_patch2-slc5_amd64_gcc462, CMSSW_6_0_1_PostLS1v2_patch1-slc5_amd64_gcc462, CMSSW_6_0_1_PostLS1v2_patch1, daForCMSSW_6_0_1_PostLS1v2_patch1-slc5_amd64_gcc462, CMSSW_6_0_1_PostLS1v2, CMSSW_6_0_1_PostLS1v1-slc5_amd64_gcc472, CMSSW_6_0_1_PostLS1v1-slc5_amd64_gcc462, CMSSW_6_0_1_PostLS1v1, daForCMSSW_6_0_1_PostLS1v1-slc5_amd64_gcc472, daForCMSSW_6_0_1_PostLS1v1-slc5_amd64_gcc462, CMSSW_6_0_1-osx107_amd64_gcc462, CMSSW_6_0_1-slc6_amd64_gcc462, ForCMSSW_6_0_1-slc6_amd64_gcc462, daForCMSSW_6_0_1-osx107_amd64_gcc462, CMSSW_6_0_1-slc5_amd64_gcc472, CMSSW_6_0_1-slc5_amd64_gcc462, CMSSW_6_0_1, daForCMSSW_6_0_1-slc5_amd64_gcc472, daForCMSSW_6_0_1-slc5_amd64_gcc462, davidlt_20121022_1024-60X-osx107, davidlt_20121022_1027-60X-slc6, davidlt_20121022_1019-60X-gcc472, davidlt_20121022_1013-60X, CMSSW_6_1_0_pre1-slc6_amd64_gcc462, ForCMSSW_6_1_0_pre1-slc6_amd64_gcc462, CMSSW_6_1_0_pre1-slc5_amd64_gcc470, CMSSW_6_1_0_pre1, davidlt-20120904-1046-61X-osx108_amd64_gcc470, daForCMSSW_6_1_0_pre1-slc5_amd64_gcc470, daForCMSSW_6_1_0_pre1-slc5_amd64_gcc462, fw20120831_before_the_merge, davidlt_20120831_0948-61X-osx107, davidlt_20120831_0947-61X-slc6, davidlt_20120831_0937-61X-gcc470, davidlt_20120831_0930-61X, cmsForCMSSW_6_1_X_2012-08-30-1000-slc5_amd64_gcc470, davidlt_20120830_0812-61X-osx107, davidlt_20120830_1035-61X-slc6, davidlt_20120830_0810-61X-gcc470, davidlt_20120830_0810-61X, davidlt_20120829_1119-61X-osx107, davidlt_20120829_1117-61X-slc6, davidlt_20120829_1116-61X-gcc470, davidlt_20120829_1115-61X, davidlt-20120827-1519-61X-osx108_amd64_gcc470, davidlt-20120827-1506-61X-osx108_amd64_gcc470, davidlt-20120827-1431-61X-osx108_amd64_gcc470, davidlt_20120824_1354-61X-osx107, davidlt_20120824_1352-61X-slc6, davidlt_20120824_1351-61X, davidlt_20120824_1352-61X-gcc470, davidlt_20120824_0928-61X-osx107, davidlt_20120824_0927-61X-slc6, davidlt_20120824_0926-61X, davidlt_20120824_0926-61X-gcc470, davidlt_20120822_1706-61X, davidlt_20120822_0925-61X-osx107, davidlt_20120822_1136-61X-slc6, davidlt_20120822_0921-61X-gcc470, davidlt_20120822_0921-61X
Changes since 1.93: +1 -1 lines
Log Message:
Fix typo in patch name.

File Contents

# User Rev Content
1 dsr 1.92 ### RPM external python 2.7.3
2 eulisse 1.3 ## INITENV +PATH PATH %i/bin
3     ## INITENV +PATH LD_LIBRARY_PATH %i/lib
4 lat 1.73 ## INITENV SETV PYTHON_LIB_SITE_PACKAGES lib/python%{python_major_version}/site-packages
5 diego 1.85 ## INITENV SETV PYTHONHASHSEED random
6 argiro 1.1 # OS X patches and build fudging stolen from fink
7 lat 1.73 %{expand:%%define python_major_version %(echo %realversion | cut -d. -f1,2)}
8     %define online %(case %cmsplatf in (*onl_*_*) echo true;; (*) echo false;; esac)
9 dsr 1.62
10 ratnik 1.34 Requires: expat bz2lib db4 gdbm
11    
12 elmer 1.55 %if "%online" != "true"
13 dsr 1.62 Requires: zlib openssl sqlite
14 ratnik 1.34 %endif
15    
16 eulisse 1.8 # FIXME: readline, crypt
17 argiro 1.1 # FIXME: gmp, panel, tk/tcl, x11
18    
19 dsr 1.62 Source0: http://www.python.org/ftp/%n/%realversion/Python-%realversion.tgz
20 diego 1.85 Patch1: python-fix-macosx-relocation
21 dsr 1.92 Patch2: python-2.7.3-fix-pyport
22 davidlt 1.94 Patch3: python-2.7.3-ssl-fragment
23 steen 1.19
24 argiro 1.1 %prep
25 dsr 1.62 %setup -n Python-%realversion
26 lat 1.74 find . -type f | while read f; do
27     if head -n1 $f | grep -q /usr/local; then
28     perl -p -i -e "s|#!.*/usr/local/bin/python|#!/usr/bin/env python|" $f
29     else :; fi
30     done
31 diego 1.85 %patch1 -p0
32 dsr 1.92
33     %ifos darwin
34 davidlt 1.88 %patch2 -p1
35 dsr 1.92 %endif
36 davidlt 1.88
37 davidlt 1.93 %patch3 -p1
38    
39 argiro 1.1 %build
40     # Python is awkward about passing other include or library directories
41     # to it. Basically there is no way to pass anything from configure to
42     # make, or down to python itself. To get python detect the extensions
43     # we want to enable, we simply have to link the contents into python's
44     # own include/lib directories. Ugh.
45     #
46     # NB: It would sort-of make sense to link more stuff from /sw on OS X,
47     # but we simply cannot link the whole world. If you need something,
48     # see above for the commented-out list of packages that could be
49     # linked specifically, or could be built by ourselves, depending on
50     # whether we like to pick up system libraries or want total control.
51 dsr 1.62 #mkdir -p %i/include %i/lib
52     mkdir -p %i/include %i/lib %i/bin
53 ratnik 1.34
54 elmer 1.55 %if "%online" != "true"
55 dsr 1.62 %define extradirs $ZLIB_ROOT $OPENSSL_ROOT $SQLITE_ROOT
56 ratnik 1.34 %else
57     %define extradirs %{nil}
58     %endif
59    
60     dirs="$EXPAT_ROOT $BZ2LIB_ROOT $NCURSES_ROOT $DB4_ROOT $GDBM_ROOT %{extradirs}"
61    
62 eulisse 1.70 # We need to export it because setup.py now uses it to determine the actual
63     # location of DB4, this was needed to avoid having it picked up from the system.
64     export DB4_ROOT
65    
66 davidlt 1.83 # Python's configure parses LDFLAGS and CPPFLAGS to look for aditional library and include directories
67 eulisse 1.16 echo $dirs
68 davidlt 1.83 LDFLAGS=""
69     CPPFLAGS=""
70 argiro 1.1 for d in $dirs; do
71 davidlt 1.83 LDFLAGS="$LDFLAGS -L $d/lib"
72     CPPFLAGS="$CPPFLAGS -I $d/include"
73 argiro 1.1 done
74 davidlt 1.83 export LDFLAGS
75     export CPPFLAGS
76 argiro 1.1
77 eulisse 1.39 additionalConfigureOptions=""
78     case %cmsplatf in
79     osx105* )
80     additionalConfigureOptions="--disable-readline"
81     ;;
82     esac
83    
84 dsr 1.92 # Bugfix for dbm package. Use ndbm.h header and gdbm compatibility layer.
85     sed -ibak "s/ndbm_libs = \[\]/ndbm_libs = ['gdbm', 'gdbm_compat']/" setup.py
86    
87     ./configure --prefix=%i $additionalConfigureOptions --enable-shared
88    
89     # Modify pyconfig.h to match macros from GLIBC features.h on Linux machines.
90     # _POSIX_C_SOURCE and _XOPEN_SOURCE macros are not identical anymore
91     # starting GLIBC 2.10.1. Python.h is not included before standard headers
92     # in CMSSW and pyconfig.h is not smart enough to detect already defined
93     # macros on Linux. The following problem does not exists on BSD machines as
94     # cdefs.h does not define these macros.
95     case %cmsplatf in
96     slc6*)
97     rm -f cms_configtest.cpp
98     cat <<CMS_EOF > cms_configtest.cpp
99     #include <features.h>
100    
101     int main() {
102     return 0;
103     }
104     CMS_EOF
105    
106     FEATURES=$(g++ -dM -E -DGNU_GCC=1 -D_GNU_SOURCE=1 -D_DARWIN_SOURCE=1 cms_configtest.cpp \
107     | grep -E '_POSIX_C_SOURCE |_XOPEN_SOURCE ')
108     rm -f cms_configtest.cpp a.out
109    
110     POSIX_C_SOURCE=$(echo "${FEATURES}" | grep _POSIX_C_SOURCE | cut -d ' ' -f 3)
111     XOPEN_SOURCE=$(echo "${FEATURES}" | grep _XOPEN_SOURCE | cut -d ' ' -f 3)
112    
113     sed -ibak "s/\(#define _POSIX_C_SOURCE \)\(.*\)/\1${POSIX_C_SOURCE}/g" pyconfig.h
114     sed -ibak "s/\(#define _XOPEN_SOURCE \)\(.*\)/\1${XOPEN_SOURCE}/g" pyconfig.h
115     ;;
116     esac
117    
118     # The following is a kludge around the fact that the /usr/lib/libreadline.so
119     # symlink (for 32-bit lib) is missing on the 64bit machines
120     case %cmsplatf in
121     slc4_ia32* )
122     mkdir -p %{i}/lib
123     ln -s /usr/lib/libreadline.so.4.3 %{i}/lib/libreadline.so
124     ;;
125     esac
126 davidlt 1.86
127 ratnik 1.38 make %makeprocesses
128 ratnik 1.37
129 argiro 1.1 %install
130 eulisse 1.71 # We need to export it because setup.py now uses it to determine the actual
131     # location of DB4, this was needed to avoid having it picked up from the system.
132     export DB4_ROOT
133 fwyzard 1.81 make install
134 dsr 1.62 %define pythonv %(echo %realversion | cut -d. -f 1,2)
135 eulisse 1.8
136 dsr 1.62 case %cmsplatf in
137     osx*)
138     make install prefix=%i
139     (cd Misc; /bin/rm -rf RPM)
140     mkdir -p %i/share/doc/%n
141     cp -R Demo Doc %i/share/doc/%n
142     cp -R Misc Tools %i/lib/python%{pythonv}
143     gcc -dynamiclib -all_load -single_module \
144     -framework System -framework CoreServices -framework Foundation \
145     %i/lib/python%{pythonv}/config/libpython%{pythonv}.a \
146     -undefined dynamic_lookup \
147     -o %i/lib/python%{pythonv}/config/libpython%{pythonv}.dylib \
148     -install_name %i/lib/python%{pythonv}/config/libpython%{pythonv}.dylib \
149     -current_version %{pythonv} -compatibility_version %{pythonv} -ldl
150     (cd %i/lib/python%{pythonv}/config
151     perl -p -i -e 's|-fno-common||g' Makefile)
152    
153     find %i/lib/python%{pythonv}/config -name 'libpython*' -exec mv -f {} %i/lib \;
154     ;;
155     esac
156 eulisse 1.9
157 diego 1.85 perl -p -i -e "s|^#!.*python|#!/usr/bin/env python|" %{i}/bin/idle \
158     %{i}/bin/pydoc \
159     %{i}/bin/python-config \
160     %{i}/bin/2to3 \
161 dsr 1.92 %{i}/bin/python2.7-config \
162     %{i}/bin/smtpd.py
163 eulisse 1.67
164     find %{i}/lib -maxdepth 1 -mindepth 1 ! -name '*python*' -exec rm {} \;
165     find %{i}/include -maxdepth 1 -mindepth 1 ! -name '*python*' -exec rm {} \;
166 muzaffar 1.28
167 lat 1.74 # remove executable permission anything which is *.py script,
168     # is executable, but does not start with she-bang so not valid
169     # executable; this avoids problems with rpm 4.8+ find-requires
170     find %i -name '*.py' -perm +0111 | while read f; do
171     if head -n1 $f | grep -q '"'; then chmod -x $f; else :; fi
172     done
173    
174 valya 1.48 # remove tkinter that brings dependency on libtk:
175 elmer 1.58 find %{i}/lib -type f -name "_tkinter.so" -exec rm {} \;
176 valya 1.48
177 eulisse 1.77 # Remove documentation, examples and test files.
178 diego 1.85 %define drop_files { %i/share %{i}/lib/python%{pythonv}/test \
179     %{i}/lib/python%{pythonv}/distutils/tests \
180     %{i}/lib/python%{pythonv}/json/tests \
181     %{i}/lib/python%{pythonv}/ctypes/test \
182     %{i}/lib/python%{pythonv}/sqlite3/test \
183     %{i}/lib/python%{pythonv}/bsddb/test \
184     %{i}/lib/python%{pythonv}/email/test \
185     %{i}/lib/python%{pythonv}/lib2to3/tests }
186 diego 1.75
187     # Remove .pyo files
188     find %i -name '*.pyo' -exec rm {} \;
189    
190 lat 1.68 # Generate dependencies-setup.{sh,csh} so init.{sh,csh} picks full environment.
191 diego 1.63 mkdir -p %i/etc/profile.d
192 lat 1.68 : > %i/etc/profile.d/dependencies-setup.sh
193     : > %i/etc/profile.d/dependencies-setup.csh
194     for tool in $(echo %{requiredtools} | sed -e's|\s+| |;s|^\s+||'); do
195     root=$(echo $tool | tr a-z- A-Z_)_ROOT; eval r=\$$root
196     if [ X"$r" != X ] && [ -r "$r/etc/profile.d/init.sh" ]; then
197     echo "test X\$$root != X || . $r/etc/profile.d/init.sh" >> %i/etc/profile.d/dependencies-setup.sh
198     echo "test X\$$root != X || source $r/etc/profile.d/init.csh" >> %i/etc/profile.d/dependencies-setup.csh
199     fi
200 diego 1.63 done
201    
202 eulisse 1.16 %post
203 dsr 1.92 %{relocateConfig}lib/python2.7/config/Makefile
204 lat 1.68 %{relocateConfig}etc/profile.d/dependencies-setup.*sh