# Patching guideline for python : # - no big patch with invasive change not # approved by upstream ( ie not coming from upstream svn ) # - small bugfix must be sent to upstream and approved if they # change any interface # - all patchs should be commented ( unless for security, # as they are usually easy to spot ) %define docver 2.7.9 %define dirver 2.7 %define lib_major %{dirver} %define lib_name_orig libpython %define lib_name %mklibname %{name} %{lib_major} %define dev_name %mklibname %{name} -d %define arch_has_valgrind 1 %ifarch %arm %mips %define arch_has_valgrind 0 %endif %if %arch_has_valgrind %bcond_without valgrind %else %bcond_with valgrind %endif %define with_rewheel 1 # Some defines to ease files list %define pylibdir %{_libdir}/python%{dirver} %define dynload_dir %{pylibdir}/lib-dynload %define site_packages %{pylibdir}/site-packages # Some of the files below /usr/lib/pythonMAJOR.MINOR/test (e.g. bad_coding.py) # are deliberately invalid, leading to SyntaxError exceptions if they get # byte-compiled. # # These errors are ignored by the normal python build, and aren't normally a # problem in the buildroots since /usr/bin/python isn't present. # # So we disable here brp-python-bytecompile # %define _python_bytecompile_build 0 %define subrel 1 Summary: An interpreted, interactive object-oriented programming language Name: python Version: 2.7.9 Release: %mkrel 2 License: Modified CNRI Open Source License Group: Development/Python Url: http://www.python.org/ Source0: http://www.python.org/ftp/python/%{version}/Python-%{version}.tar.xz Source1: http://www.python.org/ftp/python/doc/%{docver}/python-%{docver}-docs-html.tar.bz2 Source2: python2.macros Source4: python-mode-1.0.tar.bz2 Patch0: python-2.7.5-module-linkage.patch # Don't include /usr/local/* in search path Patch3: Python-2.7.6-no-local-incpath.patch # Support */lib64 convention on x86_64, sparc64, etc. # similar patches reported upstream on http://bugs.python.org/issue1294959 Patch4: python-lib64.patch # Do handle headers in h2py.py # FIXME: incomplete for proper bi-arch support as #if/#else/#endif # clauses generally should have been handled # to send upstream after cleaning Patch5: Python-2.2.2-biarch-headers.patch # add mandriva to the list of supported distribution, applied upstream Patch10: python-2.5.1-detect-mandriva.patch # from Fedora, fixes gettext.py parsing of Plural-Forms: header (fixes mdv bugs #49475, #44088) # to send upstream Patch16: python-2.5.1-plural-fix.patch # ffi checks for MIPS_LINUX instead of MIPS Patch23: python-2.7-mips-ffi.patch # do not use uname -m to get the exact name on mips/arm Patch24: python_arch.patch # fix https://bugs.mageia.org/show_bug.cgi?id=481 # mdv bug #62281 # patch to cope with lack of /dev/shm in iurt Patch25: python-2.7.5-skip-shm-test.patch Patch130: Python-2.7.5-check-for-XML_SetHashSalt.diff # 00173 # # Workaround for ENOPROTOOPT seen in bs within # test.test_support.bind_port() # from Fedora (rhbz#913732) Patch173: 00173-workaround-ENOPROTOOPT-in-bind_port.patch # Enable loading sqlite extensions. This patch isn't needed for # python3.spec, since Python 3 has a configuration option for this. # rhbz#1066708 # Patch provided by John C. Peterson Patch193: 00193-enable-loading-sqlite-extensions.patch %if 0%{with_rewheel} Patch198: 00198-add-rewheel-module.patch %endif # OpenSSL disabled SSLv3 in SSLv23 method # This patch alters python tests to reflect this change # Issue: http://bugs.python.org/issue22638 Upstream discussion about SSLv3 in Python Patch199: 00199-alter-tests-to-reflect-sslv3-disabled.patch Patch200: 00200-replace-512-bit-dh-key-with-a-2014-bit-one.patch Conflicts: tkinter < %{version} Conflicts: python-devel < 2.7-6 Requires: %{lib_name} = %{version}-%{release} BuildRequires: blt BuildRequires: db5-devel BuildRequires: emacs-bin BuildRequires: pkgconfig(expat) BuildRequires: pkgconfig(libffi) BuildRequires: gdbm-devel BuildRequires: gmp-devel BuildRequires: ncursesw-devel BuildRequires: openssl-devel BuildRequires: readline-devel BuildRequires: termcap-devel BuildRequires: tk-devel BuildRequires: tix BuildRequires: autoconf2.5 BuildRequires: bzip2-devel BuildRequires: sqlite3-devel BuildRequires: emacs %if %{with valgrind} BuildRequires: valgrind-devel %endif %if 0%{?with_rewheel} BuildRequires: python-setuptools BuildRequires: python-pip %endif # (2010/03/21, misc: interfere with test__all ) BuildConflicts: python-pyxml Provides: python(abi) = %dirver %rename python-ctypes %rename python-elementtree Obsoletes: python-base < 2.6 Provides: python-base = %version Provides: python2 Recommends: tkinter-apps Recommends: python-docs %description Python is an interpreted, interactive, object-oriented programming language often compared to Tcl, Perl, Scheme or Java. Python includes modules, classes, exceptions, very high level dynamic data types and dynamic typing. Python supports interfaces to many system calls and libraries, as well as to various windowing systems (X11, Motif, Tk, Mac and MFC). Programmers can write new built-in modules for Python in C or C++. Python can be used as an extension language for applications that need a programmable interface. This package contains most of the standard Python modules, as well as modules for interfacing to the Tix widget set for Tk and RPM. Note that documentation for Python is provided in the python-docs package. %package -n %{lib_name} Summary: Shared libraries for Python %{version} Group: System/Libraries Requires: %{lib_name}-stdlib = %{version}-%{release} %description -n %{lib_name} This packages contains Python shared object library. Python is an interpreted, interactive, object-oriented programming language often compared to Tcl, Perl, Scheme or Java. %package -n %{lib_name}-stdlib Summary: Python %{version} standard library Group: Development/Python Conflicts: python < 2.7.9-2 %description -n %{lib_name}-stdlib This package contains Python 2.7's standard library. It is normally not used on its own, but as a dependency of Python %{version}. %package -n %{lib_name}-testsuite Summary: Testsuite for the Python %{version} standard library Group: Development/Python Conflicts: python < 2.7.9-2 Requires: %{lib_name}-stdlib = %{version}-%{release} Requires: %{lib_name} = %{version}-%{release} Recommends: tkinter %description -n %{lib_name}-testsuite The complete testsuite for the Python standard library. It is normally not used on its own, but as a dependency of Python %{version}. %package -n %{dev_name} Summary: The libraries and header files needed for Python development Group: Development/Python Requires: %{name} = %version Requires: %{lib_name} = %{version}-%{release} Obsoletes: %{name}-devel < %{version} # (misc) needed to ease upgrade , see #47803 Obsoletes: %mklibname -d %{name} 2.5 Obsoletes: %mklibname -d %{name} 2.6 Obsoletes: %{mklibname -d %{name} 2.7} < 2.7-4 Provides: %{name}-devel = %{version}-%{release} Provides: %{lib_name_orig}-devel = %{version}-%{release} %description -n %{dev_name} The Python programming language's interpreter can be extended with dynamically loaded extensions and can be embedded in other programs. This package contains the header files and libraries needed to do these types of tasks. Install %{dev_name} if you want to develop Python extensions. The python package will also need to be installed. You'll probably also want to install the python-docs package, which contains Python documentation. %package docs Summary: Documentation for the Python programming language Requires: python = %version Provides: python2-docs Requires: xdg-utils Group: Development/Python BuildArch: noarch %description docs The python-docs package contains documentation on the Python programming language and interpreter. The documentation is provided in ASCII text files and in LaTeX source files. Install the python-docs package if you'd like to use the documentation for the Python language. %package -n tkinter Summary: A graphical user interface for the Python scripting language Group: Development/Python Requires: python = %version Requires: tcl tk %description -n tkinter The Tkinter (Tk interface) program is an graphical user interface for the Python scripting language. You should install the tkinter package if you'd like to use a graphical user interface for Python programming. %package -n tkinter-apps Summary: Various applications written using tkinter Group: Development/Python Requires: tkinter %description -n tkinter-apps Various applications written using tkinter %prep %setup -q -n Python-%{version} %patch0 -p0 # local include %patch3 -p0 # lib64 %patch4 -p0 -b .lib64 # biarch header %patch5 -p0 # add mandriva to the list of supported distribution %patch10 -p0 %patch16 -p1 -b .plural-fix %patch23 -p1 -b .mips %patch24 -p1 -b .arch %patch25 -p1 %patch130 -p1 -b .check-for-XML_SetHashSalt %patch173 -p1 %if 0%{with_rewheel} %patch198 -p1 %endif %patch199 -p1 %patch200 -p1 autoconf mkdir html bzcat %{SOURCE1} | tar x -C html find html -type d |xargs chmod 755 find html -type f |xargs chmod 644 find . -type f -print0 | xargs -0 perl -p -i -e 's@/usr/local/bin/python@/usr/bin/python@' tar --strip-components=1 -xjf %{SOURCE4} -C Misc cat > README.mga << EOF Python interpreter support readline completion by default. This is only used with the interpreter. In order to remove it, you can : 1) unset PYTHONSTARTUP when you login 2) create a empty file \$HOME/.pythonrc.py 3) change %{_sysconfdir}/pythonrc.py EOF # make sur the IN.py TYPES.py and DLFCN.py are correct # for current arch otherwise things will start failing # in weird ways pushd Lib/plat-linux2/ ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/dlfcn.h popd %build rm -f Modules/Setup.local cat > Modules/Setup.local << EOF linuxaudiodev linuxaudiodev.c EOF OPT="$RPM_OPT_FLAGS -g" export OPT # to fix curses module build # https://bugs.mageia.org/show_bug.cgi?id=5524 export CFLAGS="%{optflags} -I/usr/include/ncursesw" export CPPFLAGS="%{optflags} -I/usr/include/ncursesw" # Remove -Wl,--no-undefined in accordance with MGA #9395 and MGA #10102: # https://bugs.mageia.org/show_bug.cgi?id=9395 # https://bugs.mageia.org/show_bug.cgi?id=10102 %define _disable_ld_no_undefined 1 # see https://qa.mandriva.com/show_bug.cgi?id=48570 # for wide unicode support %configure2_5x --with-threads \ --enable-unicode=ucs4 \ --with-dbmliborder=gdbm \ --enable-ipv6 \ --enable-shared \ --with-system-expat \ --with-system-ffi \ %if %{with valgrind} --with-valgrind %endif # fix build #perl -pi -e 's/^(LDFLAGS=.*)/$1 -lstdc++/' Makefile # (misc) if the home is nfs mounted, rmdir fails due to delay export TMP="/tmp" TMPDIR="/tmp" make %check # (misc) if the home is nfs mounted, rmdir fails export TMP="/tmp" TMPDIR="/tmp" # all tests must pass %ifarch %arm # don't know if it's a python issue or a toolchain issue :( # test test_float failed -- Traceback (most recent call last): # File "/home/rtp/deb/python2.6-2.6.4/Lib/test/test_float.py", line 665, in test_from_hex # self.identical(fromHex('0x0.ffffffffffffd6p-1022'), MIN-3*TINY) # File "/home/rtp/deb/python2.6-2.6.4/Lib/test/test_float.py", line 375, in identical # self.fail('%r not identical to %r' % (x, y)) # AssertionError: 2.2250738585071999e-308 not identical to 2.2250738585071984e-308 %define custom_test -x test_float %else %define custom_test "" %endif # if a test doesn't pass, it can be disabled with -x test, but this should be documented in the # spec file, and a bug should be reported if possible ( on python side ) # (misc, 28/10/2010) test_gdb fail, didn't time too look # (misc, 29/10/2010) test_site fail due to one of our patch, will fix later # test_distutils, fail because of lib64 patch ( like test_site ), and because it requires libpython2.7 to be installed # test_io, blocks on my computer on 2nd run # (misc, 22/05/2011) test_urllib2 fail, related to CVE-2011-1521 : # test test_urllib2 failed -- Traceback (most recent call last): # File "/home/iurt/rpm/BUILD/Python-2.7.1/Lib/test/test_urllib2.py", line 990, in test_invalid_redirect # MockHeaders({"location": valid_url})) # File "/home/iurt/rpm/BUILD/Python-2.7.1/Lib/urllib2.py", line 617, in http_error_302 # return self.parent.open(new, timeout=req.timeout) # File "/home/iurt/rpm/BUILD/Python-2.7.1/Lib/urllib2.py", line 219, in __getattr__ # raise AttributeError, attr # AttributeError: timeout WITHIN_PYTHON_RPM_BUILD= make test TESTOPTS="-w -l -x test_gdb -x test_site -x test_io -x test_distutils -x test_urllib2 %custom_test" %install mkdir -p %{buildroot}%{_prefix}/lib/python%{dirver} %if "%{_lib}" == "lib64" mkdir -p %{buildroot}%{_prefix}/lib/python%{dirver}/site-packages %endif # fix Makefile to get rid of reference to distcc perl -pi -e "/^CC=/ and s/distcc/gcc/" Makefile # set the install path echo '[install_scripts]' >setup.cfg echo 'install_dir='"%{buildroot}/usr/bin" >>setup.cfg # python is not GNU and does not know fsstd mkdir -p %{buildroot}%{_mandir} %makeinstall_std (cd %{buildroot}%{_libdir}; ln -sf libpython%{lib_major}.so.* libpython%{lib_major}.so) # Provide a libpython%{dirver}.so symlink in /usr/lib/puthon*/config, so that # the shared library could be found when -L/usr/lib/python*/config is specified (cd %{buildroot}%{_libdir}/python%{dirver}/config; ln -sf ../../libpython%{lib_major}.so .) # emacs, I use it, I want it mkdir -p %{buildroot}%{_datadir}/emacs/site-lisp install -m 644 Misc/python-mode.el %{buildroot}%{_datadir}/emacs/site-lisp emacs -batch -f batch-byte-compile %{buildroot}%{_datadir}/emacs/site-lisp/python-mode.el install -d %{buildroot}%{_sysconfdir}/emacs/site-start.d cat <%{buildroot}%{_sysconfdir}/emacs/site-start.d/%{name}.el (setq auto-mode-alist (cons '("\\\\.py$" . python-mode) auto-mode-alist)) (autoload 'python-mode "python-mode" "Mode for python files." t) EOF #" this comment is just here because vim syntax higlighting is confused by the previous snippet of lisp # smtpd proxy mv -f %{buildroot}%{_bindir}/smtpd.py %{buildroot}%{_libdir}/python%{dirver}/ # idle cp Tools/scripts/idle %{buildroot}%{_bindir}/idle # pynche cat << EOF > %{buildroot}%{_bindir}/pynche #!/bin/bash exec %{_libdir}/python%{dirver}/site-packages/pynche/pynche EOF rm -f Tools/pynche/*.pyw cp -r Tools/pynche %{buildroot}%{_libdir}/python%{dirver}/site-packages/ chmod 755 %{buildroot}%{_bindir}/{idle,pynche} ln -f Tools/pynche/README Tools/pynche/README.pynche %if %{with valgrind} install Misc/valgrind-python.supp -D %{buildroot}%{_libdir}/valgrind/valgrind-python.supp %endif mkdir -p %{buildroot}%{_datadir}/applications cat > %{buildroot}%{_datadir}/applications/%{_real_vendor}-tkinter.desktop << EOF [Desktop Entry] Name=IDLE Comment=IDE for Python Exec=%{_bindir}/idle Icon=development_environment_section Terminal=false Type=Application Categories=Development;IDE; EOF cat > %{buildroot}%{_datadir}/applications/%{_real_vendor}-%{name}-docs.desktop << EOF [Desktop Entry] Name=Python documentation Comment=Python complete reference Exec=%{_bindir}/xdg-open %_defaultdocdir/%{name}-docs/index.html Icon=documentation_section Terminal=false Type=Application Categories=Documentation; EOF # fix non real scripts chmod 644 %{buildroot}%{_libdir}/python*/test/test_{binascii,grp,htmlparser}.py* # fix python library not stripped chmod u+w %{buildroot}%{_libdir}/libpython%{lib_major}.so.1.0 mkdir -p %{buildroot}%{_sysconfdir}/profile.d/ cat > %{buildroot}%{_sysconfdir}/profile.d/30python2.sh << 'EOF' if [ -f $HOME/.pythonrc.py ] ; then export PYTHONSTARTUP=$HOME/.pythonrc.py else export PYTHONSTARTUP=/etc/pythonrc.py fi EOF cat > %{buildroot}%{_sysconfdir}/profile.d/30python2.csh << 'EOF' if ( -f ${HOME}/.pythonrc.py ) then setenv PYTHONSTARTUP ${HOME}/.pythonrc.py else setenv PYTHONSTARTUP /etc/pythonrc.py endif EOF cat > %{buildroot}%{_sysconfdir}/pythonrc.py << EOF try: get_ipython() except: try: # this add completion to python interpreter import readline import rlcompleter # see readline man page for this readline.parse_and_bind("set show-all-if-ambiguous on") readline.parse_and_bind("tab: complete") except: pass # you can place a file .pythonrc.py in your home to overrides this one # but then, this file will not be sourced EOF %multiarch_includes %{buildroot}/usr/include/python*/pyconfig.h mkdir -p %{buildroot}%{_sysconfdir}/rpm/macros.d install -m644 %{SOURCE2} %{buildroot}%{_sysconfdir}/rpm/macros.d/ rm -f %{buildroot}%{pylibdir}/LICENSE.txt %files %doc README.mga %{_sysconfdir}/rpm/macros.d/*.macros %config(noreplace) %{_sysconfdir}/emacs/site-start.d/%{name}.el %config(noreplace) %{_sysconfdir}/profile.d/30python2.* %config(noreplace) %{_sysconfdir}/pythonrc.py %{_bindir}/python2 %{_bindir}/python%{dirver} %{_bindir}/pydoc %{_bindir}/python %{_bindir}/2to3 %{_datadir}/emacs/site-lisp/* %{_mandir}/man*/* %files -n %{lib_name}-stdlib %doc LICENSE %dir %{pylibdir} %dir %{dynload_dir} %{dynload_dir}/Python-%{version}-py%{dirver}.egg-info %exclude %{dynload_dir}/_tkinter.so %exclude %{dynload_dir}/_ctypes_test.so %exclude %{dynload_dir}/_testcapi.so %{dynload_dir}/*.so %dir %{site_packages} %{site_packages}/README %{pylibdir}/*.py* %{pylibdir}/*.doc %{pylibdir}/wsgiref.egg-info %dir %{pylibdir}/bsddb %{pylibdir}/bsddb/*.py* %{pylibdir}/compiler %dir %{pylibdir}/ctypes %{pylibdir}/ctypes/*.py* %{pylibdir}/ctypes/macholib %{pylibdir}/curses %dir %{pylibdir}/distutils %{pylibdir}/distutils/*.py* %{pylibdir}/distutils/README %{pylibdir}/distutils/command %exclude %{pylibdir}/distutils/command/wininst-*.exe %dir %{pylibdir}/email %{pylibdir}/email/*.py* %{pylibdir}/email/mime %{pylibdir}/encodings %{pylibdir}/hotshot %{pylibdir}/idlelib %{pylibdir}/importlib %dir %{pylibdir}/json %{pylibdir}/json/*.py* %{pylibdir}/lib2to3 %exclude %{pylibdir}/lib2to3/tests %{pylibdir}/logging %{pylibdir}/multiprocessing %{pylibdir}/plat-linux2 %{pylibdir}/pydoc_data %dir %{pylibdir}/sqlite3 %{pylibdir}/sqlite3/*.py* %dir %{pylibdir}/test %{pylibdir}/test/test_support.py* %{pylibdir}/test/__init__.py* %{pylibdir}/unittest/*.py* %{pylibdir}/wsgiref %{pylibdir}/xml %if "%{_lib}" == "lib64" %dir %{_prefix}/lib/python%{dirver} %dir %{_prefix}/lib/python%{dirver}/site-packages %endif # "Makefile" and the config.h file are needed by # distutils/sysconfig.py:_init_posix(), so we include them in the libs # package, along with their parent directories (RH bug#531901): %dir %{_libdir}/python%{dirver}/config %{_libdir}/python%{dirver}/config/Makefile %dir %{_includedir}/python%{dirver} %{_includedir}/python%{dirver}/pyconfig.h %multiarch %multiarch_includedir/python%{dirver}/pyconfig.h %dir %{pylibdir}/ensurepip/ %{pylibdir}/ensurepip/*.py* %exclude %{pylibdir}/ensurepip/_bundled %if 0%{?with_rewheel} %dir %{pylibdir}/ensurepip/rewheel/ %{pylibdir}/ensurepip/rewheel/*.py* %endif %files -n %{lib_name} %{_libdir}/libpython*.so.1* %files -n %{dev_name} %{_libdir}/libpython*.so %{_libdir}/pkgconfig/*.pc %{_includedir}/python%{dirver} %{_libdir}/python%{dirver}/config/* %{_bindir}/python%{dirver}-config %{_bindir}/python-config %{_bindir}/python2-config %exclude %{_libdir}/python%{dirver}/config/Makefile %exclude %{_includedir}/python%{dirver}/pyconfig.h %if %{with valgrind} %{_libdir}/valgrind/valgrind-python.supp %endif %files -n %{lib_name}-testsuite %{pylibdir}/bsddb/test %{pylibdir}/ctypes/test %{pylibdir}/distutils/tests %{pylibdir}/email/test %{pylibdir}/json/tests %{pylibdir}/lib2to3/tests %{pylibdir}/sqlite3/test %{pylibdir}/test/* %{pylibdir}/unittest/test # These two are shipped in the main subpackage: %exclude %{pylibdir}/test/test_support.py* %exclude %{pylibdir}/test/__init__.py* %{dynload_dir}/_ctypes_test.so %{dynload_dir}/_testcapi.so %files docs %doc html/*/* %{_datadir}/applications/%{_real_vendor}-%{name}-docs.desktop %files -n tkinter %dir %{pylibdir}/lib-tk %{pylibdir}/lib-tk/*.py* %{pylibdir}/lib-tk/test/ %{dynload_dir}/_tkinter.so %{pylibdir}/idlelib %{site_packages}/pynche %files -n tkinter-apps %{_bindir}/idle %{_bindir}/pynche %{_datadir}/applications/%{_real_vendor}-tkinter.desktop