ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/python.spec
Revision: 1.87
Committed: Wed Jun 20 08:54:31 2012 UTC (12 years, 10 months ago) by davidlt
Branch: MAIN
CVS Tags: CMSSW_6_0_0_pre7py273, daForCMSSW_6_0_0_pre7py273-osx107_amd64_gcc462, daForCMSSW_6_0_0_pre7py273-slc5_amd64_gcc462, davidlt_20120625_1521-osx107, davidlt_20120625_1518-CMSSW_6_0_0_pre7, davidlt_test_py273
Changes since 1.86: +5 -5 lines
Log Message:
- Drop dbm patch.
- For dbm module use gdbm + compatibility layer.
- Remove not working configure options.

File Contents

# User Rev Content
1 davidlt 1.86 ### 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 steen 1.19
22 argiro 1.1 %prep
23 dsr 1.62 %setup -n Python-%realversion
24 lat 1.74 find . -type f | while read f; do
25     if head -n1 $f | grep -q /usr/local; then
26     perl -p -i -e "s|#!.*/usr/local/bin/python|#!/usr/bin/env python|" $f
27     else :; fi
28     done
29 diego 1.85 %patch1 -p0
30 argiro 1.1
31     %build
32     # Python is awkward about passing other include or library directories
33     # to it. Basically there is no way to pass anything from configure to
34     # make, or down to python itself. To get python detect the extensions
35     # we want to enable, we simply have to link the contents into python's
36     # own include/lib directories. Ugh.
37     #
38     # NB: It would sort-of make sense to link more stuff from /sw on OS X,
39     # but we simply cannot link the whole world. If you need something,
40     # see above for the commented-out list of packages that could be
41     # linked specifically, or could be built by ourselves, depending on
42     # whether we like to pick up system libraries or want total control.
43 dsr 1.62 #mkdir -p %i/include %i/lib
44     mkdir -p %i/include %i/lib %i/bin
45 ratnik 1.34
46 elmer 1.55 %if "%online" != "true"
47 dsr 1.62 %define extradirs $ZLIB_ROOT $OPENSSL_ROOT $SQLITE_ROOT
48 ratnik 1.34 %else
49     %define extradirs %{nil}
50     %endif
51    
52     dirs="$EXPAT_ROOT $BZ2LIB_ROOT $NCURSES_ROOT $DB4_ROOT $GDBM_ROOT %{extradirs}"
53    
54 eulisse 1.70 # We need to export it because setup.py now uses it to determine the actual
55     # location of DB4, this was needed to avoid having it picked up from the system.
56     export DB4_ROOT
57    
58 davidlt 1.83 # Python's configure parses LDFLAGS and CPPFLAGS to look for aditional library and include directories
59 eulisse 1.16 echo $dirs
60 davidlt 1.83 LDFLAGS=""
61     CPPFLAGS=""
62 argiro 1.1 for d in $dirs; do
63 davidlt 1.83 LDFLAGS="$LDFLAGS -L $d/lib"
64     CPPFLAGS="$CPPFLAGS -I $d/include"
65 argiro 1.1 done
66 davidlt 1.83 export LDFLAGS
67     export CPPFLAGS
68 argiro 1.1
69 eulisse 1.39 additionalConfigureOptions=""
70     case %cmsplatf in
71     osx105* )
72     additionalConfigureOptions="--disable-readline"
73     ;;
74     esac
75    
76 davidlt 1.87 # Bugfix for dbm package. Use ndbm.h header and gdbm compatibility layer.
77     sed -ibak "s/ndbm_libs = \[\]/ndbm_libs = ['gdbm', 'gdbm_compat']/" setup.py
78    
79     ./configure --prefix=%i $additionalConfigureOptions --enable-shared
80 eulisse 1.39
81 davidlt 1.86 # 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     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 ratnik 1.38 make %makeprocesses
120 ratnik 1.37
121 argiro 1.1 %install
122 eulisse 1.71 # 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 fwyzard 1.81 make install
126 dsr 1.62 %define pythonv %(echo %realversion | cut -d. -f 1,2)
127 eulisse 1.8
128 dsr 1.62 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 eulisse 1.9
149 diego 1.85 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 davidlt 1.86 %{i}/bin/python2.7-config \
154     %{i}/bin/smtpd.py
155 eulisse 1.67
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 muzaffar 1.28
159 lat 1.74 # 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    
166 valya 1.48 # remove tkinter that brings dependency on libtk:
167 elmer 1.58 find %{i}/lib -type f -name "_tkinter.so" -exec rm {} \;
168 valya 1.48
169 eulisse 1.77 # Remove documentation, examples and test files.
170 diego 1.85 %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 diego 1.75
179     # Remove .pyo files
180     find %i -name '*.pyo' -exec rm {} \;
181    
182 lat 1.68 # Generate dependencies-setup.{sh,csh} so init.{sh,csh} picks full environment.
183 diego 1.63 mkdir -p %i/etc/profile.d
184 lat 1.68 : > %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 diego 1.63 done
193    
194 eulisse 1.16 %post
195 davidlt 1.87 %{relocateConfig}lib/python2.7/config/Makefile
196 lat 1.68 %{relocateConfig}etc/profile.d/dependencies-setup.*sh