Blame python34.spec

e32ce1
# ======================================================
e32ce1
# Conditionals and other variables controlling the build
e32ce1
# ======================================================
e32ce1
e32ce1
%global pybasever 3.4
e32ce1
e32ce1
# pybasever without the dot:
e32ce1
%global pyshortver 34
e32ce1
e32ce1
%global pylibdir %{_libdir}/python%{pybasever}
e32ce1
%global dynload_dir %{pylibdir}/lib-dynload
e32ce1
e32ce1
# SOABI is defined in the upstream configure.in from Python-3.2a2 onwards,
e32ce1
# for PEP 3149:
e32ce1
#   http://www.python.org/dev/peps/pep-3149/
e32ce1
e32ce1
# ("configure.in" became "configure.ac" in Python 3.3 onwards, and in
e32ce1
# backports)
e32ce1
e32ce1
# ABIFLAGS, LDVERSION and SOABI are in the upstream Makefile
e32ce1
# With Python 3.3, we lose the "u" suffix due to PEP 393
e32ce1
%global ABIFLAGS_optimized m
e32ce1
%global ABIFLAGS_debug     dm
e32ce1
e32ce1
%global LDVERSION_optimized %{pybasever}%{ABIFLAGS_optimized}
e32ce1
%global LDVERSION_debug     %{pybasever}%{ABIFLAGS_debug}
e32ce1
e32ce1
%global SOABI_optimized cpython-%{pyshortver}%{ABIFLAGS_optimized}
e32ce1
%global SOABI_debug     cpython-%{pyshortver}%{ABIFLAGS_debug}
e32ce1
e32ce1
# All bytecode files are now in a __pycache__ subdirectory, with a name
e32ce1
# reflecting the version of the bytecode (to permit sharing of python libraries
e32ce1
# between different runtimes)
e32ce1
# See http://www.python.org/dev/peps/pep-3147/
e32ce1
# For example,
e32ce1
#   foo/bar.py
e32ce1
# now has bytecode at:
e32ce1
#   foo/__pycache__/bar.cpython-34.pyc
e32ce1
#   foo/__pycache__/bar.cpython-34.pyo
e32ce1
%global bytecode_suffixes .cpython-34.py?
e32ce1
e32ce1
# Python's configure script defines SOVERSION, and this is used in the Makefile
e32ce1
# to determine INSTSONAME, the name of the libpython DSO:
e32ce1
#   LDLIBRARY='libpython$(VERSION).so'
e32ce1
#   INSTSONAME="$LDLIBRARY".$SOVERSION
e32ce1
# We mirror this here in order to make it easier to add the -gdb.py hooks.
e32ce1
# (if these get out of sync, the payload of the libs subpackage will fail
e32ce1
# and halt the build)
e32ce1
%global py_SOVERSION 1.0
e32ce1
%global py_INSTSONAME_optimized libpython%{LDVERSION_optimized}.so.%{py_SOVERSION}
e32ce1
%global py_INSTSONAME_debug     libpython%{LDVERSION_debug}.so.%{py_SOVERSION}
e32ce1
d28efa
%global with_debug_build 0
e32ce1
e32ce1
%global with_gdb_hooks 1
e32ce1
e32ce1
%global with_systemtap 1
e32ce1
e32ce1
# some arches don't have valgrind so we need to disable its support on them
e32ce1
%ifnarch s390
e32ce1
%global with_valgrind 1
e32ce1
%else
e32ce1
%global with_valgrind 0
e32ce1
%endif
e32ce1
e32ce1
%global with_gdbm 1
e32ce1
e32ce1
# Change from yes to no to turn this off
e32ce1
%global with_computed_gotos yes
e32ce1
e32ce1
# Turn this to 0 to turn off the "check" phase:
e32ce1
%global run_selftest_suite 1
e32ce1
e32ce1
# We want to byte-compile the .py files within the packages using the new
e32ce1
# python3 binary.
e32ce1
# 
e32ce1
# Unfortunately, rpmbuild's infrastructure requires us to jump through some
e32ce1
# hoops to avoid byte-compiling with the system python 2 version:
e32ce1
#   /usr/lib/rpm/redhat/macros sets up build policy that (amongst other things)
e32ce1
# defines __os_install_post.  In particular, "brp-python-bytecompile" is
e32ce1
# invoked without an argument thus using the wrong version of python
e32ce1
# (/usr/bin/python, rather than the freshly built python), thus leading to
e32ce1
# numerous syntax errors, and incorrect magic numbers in the .pyc files.  We
e32ce1
# thus override __os_install_post to avoid invoking this script:
e32ce1
%global __os_install_post /usr/lib/rpm/brp-compress \
e32ce1
  %{!?__debug_package:/usr/lib/rpm/brp-strip %{__strip}} \
e32ce1
  /usr/lib/rpm/brp-strip-static-archive %{__strip} \
e32ce1
  /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump} \
e32ce1
  /usr/lib/rpm/brp-python-hardlink 
e32ce1
# to remove the invocation of brp-python-bytecompile, whilst keeping the
e32ce1
# invocation of brp-python-hardlink (since this should still work for python3
e32ce1
# pyc/pyo files)
e32ce1
e32ce1
e32ce1
# We need to get a newer configure generated out of configure.in for the following
e32ce1
# patches:
e32ce1
#   patch 55 (systemtap)
e32ce1
#   patch 113 (more config flags)
e32ce1
#
e32ce1
# For patch 55 (systemtap), we need to get a new header for configure to use
e32ce1
#
e32ce1
# configure.in requires autoconf-2.65, but the version in Fedora is currently
e32ce1
# autoconf-2.66
e32ce1
#
e32ce1
# For now, we'll generate a patch to the generated configure script and
e32ce1
# pyconfig.h.in on a machine that has a local copy of autoconf 2.65
e32ce1
#
e32ce1
# Instructions on obtaining such a copy can be seen at
e32ce1
#   http://bugs.python.org/issue7997
e32ce1
#
e32ce1
# To make it easy to regenerate the patch, this specfile can be run in two
e32ce1
# ways:
e32ce1
# (i) regenerate_autotooling_patch  0 : the normal approach: prep the
e32ce1
# source tree using a pre-generated patch to the "configure" script, and do a
e32ce1
# full build
e32ce1
# (ii) regenerate_autotooling_patch 1 : intended to be run on a developer's
e32ce1
# workstation: prep the source tree without patching configure, then rerun a
e32ce1
# local copy of autoconf-2.65, regenerate the patch, then exit, without doing
e32ce1
# the rest of the build
e32ce1
%global regenerate_autotooling_patch 0
e32ce1
e32ce1
e32ce1
# ==================
e32ce1
# Top-level metadata
e32ce1
# ==================
590bf1
Summary: Version 3.4 of the Python programming language
b5ef39
Name: python%{pyshortver}
57f132
Version: %{pybasever}.5
b68910
Release: 2%{?dist}
e32ce1
License: Python
e32ce1
Group: Development/Languages
e32ce1
e32ce1
e32ce1
# =======================
e32ce1
# Build-time requirements
e32ce1
# =======================
e32ce1
e32ce1
# (keep this list alphabetized)
e32ce1
e32ce1
BuildRequires: autoconf
e32ce1
BuildRequires: bluez-libs-devel
e32ce1
BuildRequires: bzip2
e32ce1
BuildRequires: bzip2-devel
e32ce1
BuildRequires: db4-devel >= 4.7
e32ce1
e32ce1
# expat 2.1.0 added the symbol XML_SetHashSalt without bumping SONAME.  We use
e32ce1
# it (in pyexpat) in order to enable the fix in Python-3.2.3 for CVE-2012-0876:
e32ce1
BuildRequires: expat-devel >= 2.1.0
e32ce1
e32ce1
BuildRequires: findutils
e32ce1
BuildRequires: gcc-c++
e32ce1
%if %{with_gdbm}
e32ce1
BuildRequires: gdbm-devel
e32ce1
%endif
e32ce1
BuildRequires: glibc-devel
e32ce1
BuildRequires: gmp-devel
e32ce1
BuildRequires: libffi-devel
e32ce1
BuildRequires: libGL-devel
e32ce1
BuildRequires: libX11-devel
e32ce1
BuildRequires: ncurses-devel
e32ce1
# workaround http://bugs.python.org/issue19804 (test_uuid requires ifconfig)
e32ce1
BuildRequires: net-tools
e32ce1
BuildRequires: pkgconfig
e32ce1
BuildRequires: readline-devel
e32ce1
BuildRequires: sqlite-devel
e32ce1
92f62d
%if 0%{?fedora} >= 26
92f62d
BuildRequires: compat-openssl10-devel
92f62d
%else
92f62d
BuildRequires: openssl-devel
92f62d
%endif
92f62d
e32ce1
%if 0%{?with_systemtap}
e32ce1
BuildRequires: systemtap-sdt-devel
e32ce1
# (this introduces a dependency on "python", in that systemtap-sdt-devel's
e32ce1
# /usr/bin/dtrace is a python 2 script)
e32ce1
%global tapsetdir      /usr/share/systemtap/tapset
e32ce1
%endif # with_systemtap
e32ce1
e32ce1
BuildRequires: tar
e32ce1
BuildRequires: tcl-devel
e32ce1
BuildRequires: tix-devel
e32ce1
BuildRequires: tk-devel
e32ce1
e32ce1
%if 0%{?with_valgrind}
e32ce1
BuildRequires: valgrind-devel
e32ce1
%endif
e32ce1
e32ce1
BuildRequires: xz-devel
e32ce1
BuildRequires: zlib-devel
e32ce1
590bf1
Requires: expat >= 2.1.0
590bf1
BuildRequires: python-rpm-macros
590bf1
e32ce1
e32ce1
# =======================
e32ce1
# Source code and patches
e32ce1
# =======================
e32ce1
e32ce1
Source: http://www.python.org/ftp/python/%{version}/Python-%{version}.tar.xz
e32ce1
e32ce1
# Supply an RPM macro "py_byte_compile" for the python3-devel subpackage
e32ce1
# to enable specfiles to selectively byte-compile individual files and paths
e32ce1
# with different Python runtimes as necessary:
e32ce1
Source3: macros.pybytecompile%{pybasever}
e32ce1
e32ce1
# Systemtap tapset to make it easier to use the systemtap static probes
e32ce1
# (actually a template; LIBRARY_PATH will get fixed up during install)
e32ce1
# Written by dmalcolm; not yet sent upstream
e32ce1
Source5: libpython.stp
e32ce1
e32ce1
# Example systemtap script using the tapset
e32ce1
# Written by wcohen, mjw, dmalcolm; not yet sent upstream
e32ce1
Source6: systemtap-example.stp
e32ce1
e32ce1
# Another example systemtap script that uses the tapset
e32ce1
# Written by dmalcolm; not yet sent upstream
e32ce1
Source7: pyfuntop.stp
e32ce1
e32ce1
# A simple script to check timestamps of bytecode files
e32ce1
# Run in check section with Python that is currently being built
e32ce1
# Written by bkabrda
e32ce1
Source8: check-pyc-and-pyo-timestamps.py
e32ce1
e32ce1
# Fixup distutils/unixccompiler.py to remove standard library path from rpath:
e32ce1
# Was Patch0 in ivazquez' python3000 specfile:
e32ce1
Patch1:         Python-3.1.1-rpath.patch
e32ce1
e32ce1
# 00055 #
e32ce1
# Systemtap support: add statically-defined probe points
e32ce1
# Patch sent upstream as http://bugs.python.org/issue14776
e32ce1
# with some subsequent reworking to cope with LANG=C in an rpmbuild
e32ce1
# (where sys.getfilesystemencoding() == 'ascii')
e32ce1
Patch55: 00055-systemtap.patch
e32ce1
e32ce1
Patch102: 00102-lib64.patch
e32ce1
e32ce1
# 00104 #
e32ce1
# Only used when "%{_lib}" == "lib64"
e32ce1
# Another lib64 fix, for distutils/tests/test_install.py; not upstream:
e32ce1
Patch104: 00104-lib64-fix-for-test_install.patch
e32ce1
e32ce1
# 00111 #
e32ce1
# Patch the Makefile.pre.in so that the generated Makefile doesn't try to build
e32ce1
# a libpythonMAJOR.MINOR.a (bug 550692):
e32ce1
# Downstream only: not appropriate for upstream
e32ce1
Patch111: 00111-no-static-lib.patch
e32ce1
e32ce1
# 00113 #
e32ce1
# Add configure-time support for the COUNT_ALLOCS and CALL_PROFILE options
e32ce1
# described at http://svn.python.org/projects/python/trunk/Misc/SpecialBuilds.txt
e32ce1
# so that if they are enabled, they will be in that build's pyconfig.h, so that
e32ce1
# extension modules will reliably use them
e32ce1
# Not yet sent upstream
e32ce1
Patch113: 00113-more-configuration-flags.patch
e32ce1
e32ce1
# 00125 #
e32ce1
# COUNT_ALLOCS is useful for debugging, but the upstream behaviour of always
e32ce1
# emitting debug info to stdout on exit is too verbose and makes it harder to
e32ce1
# use the debug build.  Add a "PYTHONDUMPCOUNTS" environment variable which
e32ce1
# must be set to enable the output on exit
e32ce1
# Not yet sent upstream
e32ce1
Patch125: 00125-less-verbose-COUNT_ALLOCS.patch
e32ce1
e32ce1
# 00131 #
e32ce1
# The four tests in test_io built on top of check_interrupted_write_retry
e32ce1
# fail when built in Koji, for ppc and ppc64; for some reason, the SIGALRM
e32ce1
# handlers are never called, and the call to write runs to completion
e32ce1
# (rhbz#732998)
e32ce1
Patch131: 00131-disable-tests-in-test_io.patch
e32ce1
e32ce1
# 00132 #
e32ce1
# Add non-standard hooks to unittest for use in the "check" phase below, when
e32ce1
# running selftests within the build:
e32ce1
#   @unittest._skipInRpmBuild(reason)
e32ce1
# for tests that hang or fail intermittently within the build environment, and:
e32ce1
#   @unittest._expectedFailureInRpmBuild
e32ce1
# for tests that always fail within the build environment
e32ce1
#
e32ce1
# The hooks only take effect if WITHIN_PYTHON_RPM_BUILD is set in the
e32ce1
# environment, which we set manually in the appropriate portion of the "check"
e32ce1
# phase below (and which potentially other python-* rpms could set, to reuse
e32ce1
# these unittest hooks in their own "check" phases)
e32ce1
Patch132: 00132-add-rpmbuild-hooks-to-unittest.patch
e32ce1
e32ce1
# 00134 #
e32ce1
# Fix a failure in test_sys.py when configured with COUNT_ALLOCS enabled
e32ce1
# Not yet sent upstream
e32ce1
Patch134: 00134-fix-COUNT_ALLOCS-failure-in-test_sys.patch
e32ce1
e32ce1
# 00135 #
e32ce1
# test_weakref's test_callback_in_cycle_resurrection doesn't work with
e32ce1
# COUNT_ALLOCS, as the metrics keep "C" alive.  Work around this for our
e32ce1
# debug build:
e32ce1
# Not yet sent upstream
e32ce1
Patch135: 00135-fix-test-within-test_weakref-in-debug-build.patch
e32ce1
e32ce1
# 00137 #
e32ce1
# Some tests within distutils fail when run in an rpmbuild:
e32ce1
Patch137: 00137-skip-distutils-tests-that-fail-in-rpmbuild.patch
e32ce1
e32ce1
# 00139 #
e32ce1
# ARM-specific: skip known failure in test_float:
e32ce1
#  http://bugs.python.org/issue8265 (rhbz#706253)
e32ce1
Patch139: 00139-skip-test_float-known-failure-on-arm.patch
e32ce1
e32ce1
# ideally short lived patch disabling a test thats fragile on different arches
e32ce1
Patch140: python3-arm-skip-failing-fragile-test.patch
e32ce1
e32ce1
# 00141 #
e32ce1
# Fix tests for case when  tests for case when configured with
e32ce1
# COUNT_ALLOCS (debug build): http://bugs.python.org/issue19527
e32ce1
# Applies to: test_gc, test_module, test_io, test_logging, test_warnings,
e32ce1
#             test_threading
e32ce1
Patch141: 00141-fix-tests_with_COUNT_ALLOCS.patch
e32ce1
e32ce1
# 00143 #
e32ce1
# Fix the --with-tsc option on ppc64, and rework it on 32-bit ppc to avoid
e32ce1
# aliasing violations (rhbz#698726)
e32ce1
# Sent upstream as http://bugs.python.org/issue12872
e32ce1
Patch143: 00143-tsc-on-ppc.patch
e32ce1
e32ce1
# 00146 #
e32ce1
# Support OpenSSL FIPS mode (e.g. when OPENSSL_FORCE_FIPS_MODE=1 is set)
e32ce1
# - handle failures from OpenSSL (e.g. on attempts to use MD5 in a
e32ce1
#   FIPS-enforcing environment)
e32ce1
# - add a new "usedforsecurity" keyword argument to the various digest
e32ce1
#   algorithms in hashlib so that you can whitelist a callsite with
e32ce1
#   "usedforsecurity=False"
e32ce1
# (sent upstream for python 3 as http://bugs.python.org/issue9216 ; see RHEL6
e32ce1
# python patch 119)
e32ce1
# - enforce usage of the _hashlib implementation: don't fall back to the _md5
e32ce1
#   and _sha* modules (leading to clearer error messages if fips selftests
e32ce1
#   fail)
e32ce1
# - don't build the _md5 and _sha* modules; rely on the _hashlib implementation
e32ce1
#   of hashlib
e32ce1
# (rhbz#563986)
e32ce1
# Note: Up to Python 3.4.0.b1, upstream had their own implementation of what
e32ce1
# they assumed would become sha3. This patch was adapted to give it the
e32ce1
# usedforsecurity argument, even though it did nothing (OpenSSL didn't have
e32ce1
# sha3 implementation at that time).In 3.4.0.b2, sha3 implementation was reverted
e32ce1
# (see http://bugs.python.org/issue16113), but the alterations were left in the
e32ce1
# patch, since they may be useful again if upstream decides to rerevert sha3
e32ce1
# implementation and OpenSSL still doesn't support it. For now, they're harmless.
e32ce1
Patch146: 00146-hashlib-fips.patch
e32ce1
e32ce1
# 00150 #
e32ce1
# temporarily disable rAssertAlmostEqual in test_cmath on PPC (bz #750811)
e32ce1
# caused by a glibc bug. This patch can be removed when we have a glibc with
e32ce1
# the patch mentioned here:
e32ce1
#   http://sourceware.org/bugzilla/show_bug.cgi?id=13472
e32ce1
Patch150: 00150-disable-rAssertAlmostEqual-cmath-on-ppc.patch
e32ce1
e32ce1
# 00155 #
e32ce1
# Avoid allocating thunks in ctypes unless absolutely necessary, to avoid
e32ce1
# generating SELinux denials on "import ctypes" and "import uuid" when
e32ce1
# embedding Python within httpd (rhbz#814391)
e32ce1
Patch155: 00155-avoid-ctypes-thunks.patch
e32ce1
e32ce1
# 00157 #
e32ce1
# Update uid/gid handling throughout the standard library: uid_t and gid_t are
e32ce1
# unsigned 32-bit values, but existing code often passed them through C long
e32ce1
# values, which are signed 32-bit values on 32-bit architectures, leading to
e32ce1
# negative int objects for uid/gid values >= 2^31 on 32-bit architectures.
e32ce1
#
e32ce1
# Introduce _PyObject_FromUid/Gid to convert uid_t/gid_t values to python
e32ce1
# objects, using int objects where the value will fit (long objects otherwise),
e32ce1
# and _PyArg_ParseUid/Gid to convert int/long to uid_t/gid_t, with -1 allowed
e32ce1
# as a special case (since this is given special meaning by the chown syscall)
e32ce1
#
e32ce1
# Update standard library to use this throughout for uid/gid values, so that
e32ce1
# very large uid/gid values are round-trippable, and -1 remains usable.
e32ce1
# (rhbz#697470)
e32ce1
Patch157: 00157-uid-gid-overflows.patch
e32ce1
e32ce1
# 00160 #
e32ce1
# Python 3.3 added os.SEEK_DATA and os.SEEK_HOLE, which may be present in the
e32ce1
# header files in the build chroot, but may not be supported in the running
e32ce1
# kernel, hence we disable this test in an rpm build.
e32ce1
# Adding these was upstream issue http://bugs.python.org/issue10142
e32ce1
# Not yet sent upstream
e32ce1
Patch160: 00160-disable-test_fs_holes-in-rpm-build.patch
e32ce1
e32ce1
# 00163 #
e32ce1
# Some tests within test_socket fail intermittently when run inside Koji;
e32ce1
# disable them using unittest._skipInRpmBuild
e32ce1
# Not yet sent upstream
e32ce1
Patch163: 00163-disable-parts-of-test_socket-in-rpm-build.patch
e32ce1
e32ce1
# 0164 #
e32ce1
# some tests in test._io interrupted_write-* fail on PPC (rhbz#846849)
e32ce1
# testChainingDescriptors  test in test_exceptions fails on PPc, too (rhbz#846849)
e32ce1
# disable those tests so that rebuilds on PPC can continue
e32ce1
Patch164: 00164-disable-interrupted_write-tests-on-ppc.patch
e32ce1
e32ce1
# 00170 #                                                                                           
e32ce1
# In debug builds, try to print repr() when a C-level assert fails in the                           
e32ce1
# garbage collector (typically indicating a reference-counting error                                
e32ce1
# somewhere else e.g in an extension module)                                                        
e32ce1
# Backported to 2.7 from a patch I sent upstream for py3k                                           
e32ce1
#   http://bugs.python.org/issue9263  (rhbz#614680)                                                 
e32ce1
# hiding the proposed new macros/functions within gcmodule.c to avoid exposing                      
e32ce1
# them within the extension API.                                                                    
e32ce1
# (rhbz#850013
e32ce1
Patch170: 00170-gc-assertions.patch
e32ce1
e32ce1
# 00173 #
e32ce1
# Workaround for ENOPROTOOPT seen in Koji withi test.support.bind_port()
e32ce1
# (rhbz#913732)
e32ce1
Patch173: 00173-workaround-ENOPROTOOPT-in-bind_port.patch
e32ce1
e32ce1
# 00178 #
e32ce1
# Don't duplicate various FLAGS in sysconfig values
e32ce1
# http://bugs.python.org/issue17679
e32ce1
# Does not affect python2 AFAICS (different sysconfig values initialization)
e32ce1
Patch178: 00178-dont-duplicate-flags-in-sysconfig.patch
e32ce1
e32ce1
# 00179 #
e32ce1
# Workaround for https://bugzilla.redhat.com/show_bug.cgi?id=951802
e32ce1
# Reported upstream in http://bugs.python.org/issue17737
e32ce1
# This patch basically looks at every frame and if it is somehow corrupted,
e32ce1
# it just stops printing the traceback - it doesn't fix the actual bug.
e32ce1
# This bug seems to only affect ARM.
e32ce1
# Doesn't seem to affect Python 2 AFAICS.
e32ce1
Patch179: 00179-dont-raise-error-on-gdb-corrupted-frames-in-backtrace.patch
e32ce1
e32ce1
# 00180 #
e32ce1
# Enable building on ppc64p7
e32ce1
# Not appropriate for upstream, Fedora-specific naming
e32ce1
Patch180: 00180-python-add-support-for-ppc64p7.patch
e32ce1
e32ce1
# 00184 #
e32ce1
# Fix for https://bugzilla.redhat.com/show_bug.cgi?id=979696
e32ce1
# Fixes build of ctypes against libffi with multilib wrapper
e32ce1
# Python recognizes ffi.h only if it contains "#define LIBFFI_H",
e32ce1
# but the wrapper doesn't contain that, which makes the build fail
e32ce1
# We patch this by also accepting "#define ffi_wrapper_h"
e32ce1
Patch184: 00184-ctypes-should-build-with-libffi-multilib-wrapper.patch
e32ce1
e32ce1
# 00186 #
e32ce1
# Fix for https://bugzilla.redhat.com/show_bug.cgi?id=1023607
e32ce1
# Previously, this fixed a problem where some *.py files were not being
e32ce1
# bytecompiled properly during build. This was result of py_compile.compile
e32ce1
# raising exception when trying to convert test file with bad encoding, and
e32ce1
# thus not continuing bytecompilation for other files.
e32ce1
# This was fixed upstream, but the test hasn't been merged yet, so we keep it
e32ce1
Patch186: 00186-dont-raise-from-py_compile.patch
e32ce1
e32ce1
# 00188 #
e32ce1
# Downstream only patch that should be removed when we compile all guaranteed
e32ce1
# hashlib algorithms properly. The problem is this:
e32ce1
# - during tests, test_hashlib is imported and executed before test_lib2to3
e32ce1
# - if at least one hash function has failed, trying to import it triggers an
e32ce1
#   exception that is being caught and exception is logged:
e32ce1
#   http://hg.python.org/cpython/file/2de806c8b070/Lib/hashlib.py#l217
e32ce1
# - logging the exception makes logging module run basicConfig
e32ce1
# - when lib2to3 tests are run again, lib2to3 runs basicConfig again, which
e32ce1
#   doesn't do anything, because it was run previously
e32ce1
#   (logging.root.handlers != []), which means that the default setup
e32ce1
#   (most importantly logging level) is not overriden. That means that a test
e32ce1
#   relying on this will fail (test_filename_changing_on_output_single_dir)
e32ce1
Patch188: 00188-fix-lib2to3-tests-when-hashlib-doesnt-compile-properly.patch
e32ce1
e32ce1
# Tests requiring SIGHUP to work don't work in Koji
e32ce1
# see rhbz#1088233
e32ce1
Patch194: temporarily-disable-tests-requiring-SIGHUP.patch
e32ce1
e32ce1
# 00196
e32ce1
#
e32ce1
#  Fix test_gdb failure on ppc64le
e32ce1
Patch196: 00196-test-gdb-match-addr-before-builtin.patch
e32ce1
e32ce1
# 00200 #                                                                                           
e32ce1
# Fix for gettext plural form headers (lines that begin with "#")                                   
e32ce1
# Note: Backported from scl
e32ce1
Patch200: 00200-gettext-plural-fix.patch
e32ce1
e32ce1
# 00201 #                                                                                           
e32ce1
# Fixes memory leak in gdbm module (rhbz#977308)                                                    
e32ce1
# This was upstreamed as a part of bigger patch, but for our purposes                               
e32ce1
# this is ok: http://bugs.python.org/issue18404                                                     
e32ce1
# Note: Backported from scl
e32ce1
Patch201: 00201-fix-memory-leak-in-gdbm.patch 
e32ce1
e32ce1
# test_threading fails in koji dues to it's handling of signals
e32ce1
Patch203: 00203-disable-threading-test-koji.patch
e32ce1
e32ce1
# 00212 #
e32ce1
# Fix test breakage with version 2.2.0 of Expat
e32ce1
# rhbz#1353918: https://bugzilla.redhat.com/show_bug.cgi?id=1353918
e32ce1
# NOT YET FIXED UPSTREAM: http://bugs.python.org/issue27369
e32ce1
Patch212: 00212-fix-test-pyexpat-failure.patch
e32ce1
e32ce1
# (New patches go here ^^^)
e32ce1
#
e32ce1
# When adding new patches to "python" and "python3" in Fedora 17 onwards,
e32ce1
# please try to keep the patch numbers in-sync between the two specfiles:
e32ce1
#
e32ce1
#   - use the same patch number across both specfiles for conceptually-equivalent
e32ce1
#     fixes, ideally with the same name
e32ce1
#
e32ce1
#   - when a patch is relevant to both specfiles, use the same introductory
e32ce1
#     comment in both specfiles where possible (to improve "diff" output when
e32ce1
#     comparing them)
e32ce1
#
e32ce1
#   - when a patch is only relevant for one of the two specfiles, leave a gap
e32ce1
#     in the patch numbering in the other specfile, adding a comment when
e32ce1
#     omitting a patch, both in the manifest section here, and in the "prep"
e32ce1
#     phase below
e32ce1
#
e32ce1
# Hopefully this will make it easier to ensure that all relevant fixes are
e32ce1
# applied to both versions.
e32ce1
e32ce1
# This is the generated patch to "configure"; see the description of
e32ce1
#   %{regenerate_autotooling_patch}
e32ce1
# above:
e32ce1
Patch5000: 05000-autotool-intermediates.patch
e32ce1
e32ce1
BuildRoot: %{_tmppath}/%{name}-%{version}-root
e32ce1
e32ce1
# ======================================================
e32ce1
# Additional metadata, and subpackages
e32ce1
# ======================================================
e32ce1
e32ce1
URL: http://www.python.org/
e32ce1
a8b851
# We don't want to provide this
590bf1
# No package in Fedora shall ever depend on this
f3528a
%global __requires_exclude ^python\\(abi\\) = 3\\..$
f3528a
%global __provides_exclude ^python\\(abi\\) = 3\\..$
e32ce1
fb1058
# We keep those inside on purpose
fb1058
Provides: bundled(python3-pip) = 6.0.8
fb1058
Provides: bundled(python3-setuptools) = 12.0.5
fb1058
e32ce1
%description
b68910
Python %{pybasever} package for developers.
b68910
b68910
This package exists to allow developers to test their code against an older
b68910
version of Python. This is not a full Python stack and if you wish to run
b68910
your applications with Python %{pybasever}, see other distributions
b68910
that support it, such as CentOS or RHEL with Software Collections.
b68910
e32ce1
e32ce1
# ======================================================
e32ce1
# The prep phase of the build:
e32ce1
# ======================================================
e32ce1
e32ce1
%prep
e32ce1
%setup -q -n Python-%{version}%{?prerel}
e32ce1
e32ce1
%if 0%{?with_systemtap}
e32ce1
# Provide an example of usage of the tapset:
e32ce1
cp -a %{SOURCE6} .
e32ce1
cp -a %{SOURCE7} .
e32ce1
%endif # with_systemtap
e32ce1
e32ce1
# Ensure that we're using the system copy of various libraries, rather than
e32ce1
# copies shipped by upstream in the tarball:
e32ce1
#   Remove embedded copy of expat:
e32ce1
rm -r Modules/expat || exit 1
e32ce1
e32ce1
#   Remove embedded copy of libffi:
e32ce1
for SUBDIR in darwin libffi libffi_arm_wince libffi_msvc libffi_osx ; do
e32ce1
  rm -r Modules/_ctypes/$SUBDIR || exit 1 ;
e32ce1
done
e32ce1
e32ce1
#   Remove embedded copy of zlib:
e32ce1
rm -r Modules/zlib || exit 1
e32ce1
e32ce1
# Don't build upstream Python's implementation of these crypto algorithms;
e32ce1
# instead rely on _hashlib and OpenSSL.
e32ce1
#
e32ce1
# For example, in our builds hashlib.md5 is implemented within _hashlib via
e32ce1
# OpenSSL (and thus respects FIPS mode), and does not fall back to _md5
e32ce1
# TODO: there seems to be no OpenSSL support in Python for sha3 so far
e32ce1
# when it is there, also remove _sha3/ dir
e32ce1
for f in md5module.c sha1module.c sha256module.c sha512module.c; do
e32ce1
    rm Modules/$f
e32ce1
done
e32ce1
e32ce1
#
e32ce1
# Apply patches:
e32ce1
#
e32ce1
%patch1 -p1
e32ce1
# 3: upstream as of Python 3.3.1
e32ce1
e32ce1
%if 0%{?with_systemtap}
e32ce1
%patch55 -p1 -b .systemtap
e32ce1
%endif
e32ce1
e32ce1
%if "%{_lib}" == "lib64"
e32ce1
%patch102 -p1
e32ce1
%patch104 -p1
e32ce1
%endif
e32ce1
e32ce1
e32ce1
%patch111 -p1
e32ce1
%patch113 -p1
e32ce1
e32ce1
%patch125 -p1 -b .less-verbose-COUNT_ALLOCS
e32ce1
e32ce1
%ifarch ppc %{power64}
e32ce1
%patch131 -p1
e32ce1
%endif
e32ce1
e32ce1
%patch132 -p1
e32ce1
%patch134 -p1
e32ce1
%patch135 -p1
e32ce1
%patch137 -p1
714415
e32ce1
%ifarch %{arm}
e32ce1
%patch139 -p1
e32ce1
%patch140 -p1
e32ce1
%endif
714415
e32ce1
%patch141 -p1
e32ce1
%patch143 -p1 -b .tsc-on-ppc
e32ce1
%patch146 -p1
714415
e32ce1
%ifarch ppc %{power64}
e32ce1
%patch150 -p1
e32ce1
%endif
714415
e32ce1
%patch155 -p1
e32ce1
%patch157 -p1
e32ce1
%patch160 -p1
e32ce1
%patch163 -p1
714415
e32ce1
%ifarch ppc %{power64}
e32ce1
%patch164 -p1
e32ce1
%endif
714415
e32ce1
%patch173 -p1
e32ce1
%patch178 -p1
e32ce1
%patch179 -p1
e32ce1
%patch180 -p1
e32ce1
%patch184  -p1
e32ce1
%patch186 -p1
e32ce1
%patch188 -p1
e32ce1
e32ce1
%patch194 -p1
e32ce1
%patch196 -p1
e32ce1
%patch203 -p1
e32ce1
%patch212 -p1
e32ce1
e32ce1
# Currently (2010-01-15), http://docs.python.org/library is for 2.6, and there
e32ce1
# are many differences between 2.6 and the Python 3 library.
e32ce1
#
e32ce1
# Fix up the URLs within pydoc to point at the documentation for this
e32ce1
# MAJOR.MINOR version:
e32ce1
#
e32ce1
sed --in-place \
e32ce1
    --expression="s|http://docs.python.org/library|http://docs.python.org/%{pybasever}/library|g" \
e32ce1
    Lib/pydoc.py || exit 1
e32ce1
e32ce1
%if ! 0%{regenerate_autotooling_patch}
e32ce1
# Normally we apply the patch to "configure"
e32ce1
# We don't apply the patch if we're working towards regenerating it
e32ce1
%patch5000 -p0 -b .autotool-intermediates
e32ce1
%endif
e32ce1
e32ce1
# ======================================================
e32ce1
# Configuring and building the code:
e32ce1
# ======================================================
e32ce1
e32ce1
%build
e32ce1
topdir=$(pwd)
e32ce1
export CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
e32ce1
export CXXFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
e32ce1
export CPPFLAGS="`pkg-config --cflags-only-I libffi`"
e32ce1
export OPT="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
e32ce1
export LINKCC="gcc"
e32ce1
export CFLAGS="$CFLAGS `pkg-config --cflags openssl`"
e32ce1
export LDFLAGS="$RPM_LD_FLAGS `pkg-config --libs-only-L openssl`"
e32ce1
e32ce1
%if 0%{regenerate_autotooling_patch}
e32ce1
# If enabled, this code regenerates the patch to "configure", using a
e32ce1
# local copy of autoconf-2.65, then exits the build
e32ce1
#
e32ce1
# The following assumes that the copy is installed to ~/autoconf-2.65/bin
e32ce1
# as per these instructions:
e32ce1
#   http://bugs.python.org/issue7997
e32ce1
e32ce1
for f in pyconfig.h.in configure ; do
e32ce1
    cp $f $f.autotool-intermediates ;
e32ce1
done
e32ce1
e32ce1
# Rerun the autotools:
e32ce1
autoreconf
e32ce1
e32ce1
# Regenerate the patch:
e32ce1
gendiff . .autotool-intermediates > %{PATCH5000}
e32ce1
e32ce1
e32ce1
# Exit the build
e32ce1
exit 1
e32ce1
%endif
e32ce1
e32ce1
# Define a function, for how to perform a "build" of python for a given
e32ce1
# configuration:
e32ce1
BuildPython() {
e32ce1
  ConfName=$1	      
e32ce1
  BinaryName=$2
e32ce1
  SymlinkName=$3
e32ce1
  ExtraConfigArgs=$4
e32ce1
  PathFixWithThisBinary=$5
e32ce1
  MoreCFlags=$6
e32ce1
e32ce1
  ConfDir=build/$ConfName
e32ce1
e32ce1
  echo STARTING: BUILD OF PYTHON FOR CONFIGURATION: $ConfName - %{_bindir}/$BinaryName
e32ce1
  mkdir -p $ConfDir
e32ce1
e32ce1
  pushd $ConfDir
e32ce1
e32ce1
  # Use the freshly created "configure" script, but in the directory two above:
e32ce1
  %global _configure $topdir/configure
e32ce1
e32ce1
%configure \
e32ce1
  --enable-ipv6 \
e32ce1
  --enable-shared \
e32ce1
  --with-computed-gotos=%{with_computed_gotos} \
e32ce1
  --with-dbmliborder=gdbm:ndbm:bdb \
e32ce1
  --with-system-expat \
e32ce1
  --with-system-ffi \
e32ce1
  --enable-loadable-sqlite-extensions \
e32ce1
%if 0%{?with_systemtap}
e32ce1
  --with-systemtap \
e32ce1
%endif
e32ce1
%if 0%{?with_valgrind}
e32ce1
  --with-valgrind \
e32ce1
%endif
e32ce1
  $ExtraConfigArgs \
e32ce1
  %{nil}
e32ce1
e32ce1
  # Set EXTRA_CFLAGS to our CFLAGS (rather than overriding OPT, as we've done
e32ce1
  # in the past).
e32ce1
  # This should fix a problem with --with-valgrind where it adds
e32ce1
  #   -DDYNAMIC_ANNOTATIONS_ENABLED=1
e32ce1
  # to OPT which must be passed to all compilation units in the build,
e32ce1
  # otherwise leading to linker errors, e.g.
e32ce1
  #    missing symbol AnnotateRWLockDestroy
e32ce1
  #
e32ce1
  # Invoke the build:
e32ce1
  make EXTRA_CFLAGS="$CFLAGS $MoreCFlags" %{?_smp_mflags}
e32ce1
e32ce1
  popd
e32ce1
  echo FINISHED: BUILD OF PYTHON FOR CONFIGURATION: $ConfDir
e32ce1
}
e32ce1
e32ce1
# Use "BuildPython" to support building with different configurations:
e32ce1
e32ce1
%if 0%{?with_debug_build}
e32ce1
BuildPython debug \
e32ce1
  python-debug \
e32ce1
  python%{pybasever}-debug \
e32ce1
%ifarch %{ix86} x86_64 ppc %{power64}
e32ce1
  "--with-pydebug --with-tsc --with-count-allocs --with-call-profile --without-ensurepip" \
e32ce1
%else
e32ce1
  "--with-pydebug --with-count-allocs --with-call-profile --without-ensurepip" \
e32ce1
%endif
e32ce1
  false \
e32ce1
  -O0
e32ce1
%endif # with_debug_build
e32ce1
e32ce1
BuildPython optimized \
e32ce1
  python \
e32ce1
  python%{pybasever} \
e32ce1
  "--without-ensurepip" \
e32ce1
  true
e32ce1
e32ce1
# ======================================================
e32ce1
# Installing the built code:
e32ce1
# ======================================================
e32ce1
e32ce1
%install
e32ce1
topdir=$(pwd)
e32ce1
rm -fr %{buildroot}
e32ce1
mkdir -p %{buildroot}%{_prefix} %{buildroot}%{_mandir}
e32ce1
e32ce1
InstallPython() {
e32ce1
e32ce1
  ConfName=$1	      
e32ce1
  PyInstSoName=$2
e32ce1
  MoreCFlags=$3
e32ce1
e32ce1
  ConfDir=build/$ConfName
e32ce1
e32ce1
  echo STARTING: INSTALL OF PYTHON FOR CONFIGURATION: $ConfName
e32ce1
  mkdir -p $ConfDir
e32ce1
e32ce1
  pushd $ConfDir
e32ce1
e32ce1
make install DESTDIR=%{buildroot} INSTALL="install -p" EXTRA_CFLAGS="$MoreCFlags"
e32ce1
e32ce1
  popd
e32ce1
e32ce1
  # We install a collection of hooks for gdb that make it easier to debug
e32ce1
  # executables linked against libpython3* (such as /usr/bin/python3 itself)
e32ce1
  #
e32ce1
  # These hooks are implemented in Python itself (though they are for the version
e32ce1
  # of python that gdb is linked with, in this case Python 2.7)
e32ce1
  #
e32ce1
  # gdb-archer looks for them in the same path as the ELF file, with a -gdb.py suffix.
e32ce1
  # We put them in the debuginfo package by installing them to e.g.:
e32ce1
  #  /usr/lib/debug/usr/lib/libpython3.2.so.1.0.debug-gdb.py
e32ce1
  #
e32ce1
  # See https://fedoraproject.org/wiki/Features/EasierPythonDebugging for more
e32ce1
  # information
e32ce1
  #
e32ce1
  # Copy up the gdb hooks into place; the python file will be autoloaded by gdb
e32ce1
  # when visiting libpython.so, provided that the python file is installed to the
e32ce1
  # same path as the library (or its .debug file) plus a "-gdb.py" suffix, e.g:
e32ce1
  #  /usr/lib/debug/usr/lib64/libpython3.2.so.1.0.debug-gdb.py
e32ce1
  # (note that the debug path is /usr/lib/debug for both 32/64 bit)
e32ce1
  #
e32ce1
  # Initially I tried:
e32ce1
  #  /usr/lib/libpython3.1.so.1.0-gdb.py
e32ce1
  # but doing so generated noise when ldconfig was rerun (rhbz:562980)
e32ce1
  #
e32ce1
%if 0%{?with_gdb_hooks}
e32ce1
  DirHoldingGdbPy=%{_prefix}/lib/debug/%{_libdir}
e32ce1
  PathOfGdbPy=$DirHoldingGdbPy/$PyInstSoName.debug-gdb.py
e32ce1
e32ce1
  mkdir -p %{buildroot}$DirHoldingGdbPy
e32ce1
  cp Tools/gdb/libpython.py %{buildroot}$PathOfGdbPy
e32ce1
%endif # with_gdb_hooks
e32ce1
e32ce1
  echo FINISHED: INSTALL OF PYTHON FOR CONFIGURATION: $ConfName
e32ce1
}
e32ce1
e32ce1
# Use "InstallPython" to support building with different configurations:
e32ce1
e32ce1
# Install the "debug" build first, so that we can move some files aside
e32ce1
%if 0%{?with_debug_build}
e32ce1
InstallPython debug \
e32ce1
  %{py_INSTSONAME_debug} \
e32ce1
  -O0
e32ce1
%endif # with_debug_build
e32ce1
e32ce1
# Now the optimized build:
e32ce1
InstallPython optimized \
e32ce1
  %{py_INSTSONAME_optimized}
e32ce1
e32ce1
install -d -m 0755 ${RPM_BUILD_ROOT}%{pylibdir}/site-packages/__pycache__
e32ce1
e32ce1
mv ${RPM_BUILD_ROOT}%{_bindir}/2to3 ${RPM_BUILD_ROOT}%{_bindir}/python3-2to3
e32ce1
e32ce1
# Development tools
e32ce1
install -m755 -d ${RPM_BUILD_ROOT}%{pylibdir}/Tools
e32ce1
install Tools/README ${RPM_BUILD_ROOT}%{pylibdir}/Tools/
e32ce1
cp -ar Tools/freeze ${RPM_BUILD_ROOT}%{pylibdir}/Tools/
e32ce1
cp -ar Tools/i18n ${RPM_BUILD_ROOT}%{pylibdir}/Tools/
e32ce1
cp -ar Tools/pynche ${RPM_BUILD_ROOT}%{pylibdir}/Tools/
e32ce1
cp -ar Tools/scripts ${RPM_BUILD_ROOT}%{pylibdir}/Tools/
e32ce1
e32ce1
# Documentation tools
e32ce1
install -m755 -d %{buildroot}%{pylibdir}/Doc
e32ce1
cp -ar Doc/tools %{buildroot}%{pylibdir}/Doc/
e32ce1
e32ce1
# Demo scripts
e32ce1
cp -ar Tools/demo %{buildroot}%{pylibdir}/Tools/
e32ce1
e32ce1
# Fix for bug #136654
e32ce1
rm -f %{buildroot}%{pylibdir}/email/test/data/audiotest.au %{buildroot}%{pylibdir}/test/audiotest.au
e32ce1
e32ce1
%if "%{_lib}" == "lib64"
e32ce1
install -d -m 0755 %{buildroot}/%{_prefix}/lib/python%{pybasever}/site-packages/__pycache__
e32ce1
%endif
e32ce1
e32ce1
# Make python3-devel multilib-ready (bug #192747, #139911)
e32ce1
%global _pyconfig32_h pyconfig-32.h
e32ce1
%global _pyconfig64_h pyconfig-64.h
e32ce1
e32ce1
%ifarch %{power64} s390x x86_64 ia64 alpha sparc64 aarch64
e32ce1
%global _pyconfig_h %{_pyconfig64_h}
e32ce1
%else
e32ce1
%global _pyconfig_h %{_pyconfig32_h}
e32ce1
%endif
e32ce1
e32ce1
# ABIFLAGS, LDVERSION and SOABI are in the upstream Makefile
e32ce1
%global ABIFLAGS_optimized m
e32ce1
%global ABIFLAGS_debug     dm
e32ce1
e32ce1
%global LDVERSION_optimized %{pybasever}%{ABIFLAGS_optimized}
e32ce1
%global LDVERSION_debug     %{pybasever}%{ABIFLAGS_debug}
e32ce1
e32ce1
%global SOABI_optimized cpython-%{pyshortver}%{ABIFLAGS_optimized}
e32ce1
%global SOABI_debug     cpython-%{pyshortver}%{ABIFLAGS_debug}
e32ce1
e32ce1
%if 0%{?with_debug_build}
e32ce1
%global PyIncludeDirs python%{LDVERSION_optimized} python%{LDVERSION_debug}
e32ce1
e32ce1
%else
e32ce1
%global PyIncludeDirs python%{LDVERSION_optimized}
e32ce1
%endif
e32ce1
e32ce1
for PyIncludeDir in %{PyIncludeDirs} ; do
e32ce1
  mv %{buildroot}%{_includedir}/$PyIncludeDir/pyconfig.h \
e32ce1
     %{buildroot}%{_includedir}/$PyIncludeDir/%{_pyconfig_h}
e32ce1
  cat > %{buildroot}%{_includedir}/$PyIncludeDir/pyconfig.h << EOF
e32ce1
#include <bits wordsize.h="">
e32ce1
e32ce1
#if __WORDSIZE == 32
e32ce1
#include "%{_pyconfig32_h}"
e32ce1
#elif __WORDSIZE == 64
e32ce1
#include "%{_pyconfig64_h}"
e32ce1
#else
e32ce1
#error "Unknown word size"
e32ce1
#endif
e32ce1
EOF
e32ce1
done
e32ce1
e32ce1
# Fix for bug 201434: make sure distutils looks at the right pyconfig.h file
e32ce1
# Similar for sysconfig: sysconfig.get_config_h_filename tries to locate
e32ce1
# pyconfig.h so it can be parsed, and needs to do this at runtime in site.py
e32ce1
# when python starts up (bug 653058)
e32ce1
#
e32ce1
# Split this out so it goes directly to the pyconfig-32.h/pyconfig-64.h
e32ce1
# variants:
e32ce1
sed -i -e "s/'pyconfig.h'/'%{_pyconfig_h}'/" \
e32ce1
  %{buildroot}%{pylibdir}/distutils/sysconfig.py \
e32ce1
  %{buildroot}%{pylibdir}/sysconfig.py
e32ce1
e32ce1
# Switch all shebangs to refer to the specific Python version.
e32ce1
LD_LIBRARY_PATH=./build/optimized ./build/optimized/python \
e32ce1
  Tools/scripts/pathfix.py \
e32ce1
  -i "%{_bindir}/python%{pybasever}" \
e32ce1
  %{buildroot}
e32ce1
e32ce1
# Remove shebang lines from .py files that aren't executable, and
e32ce1
# remove executability from .py files that don't have a shebang line:
e32ce1
find %{buildroot} -name \*.py \
e32ce1
  \( \( \! -perm /u+x,g+x,o+x -exec sed -e '/^#!/Q 0' -e 'Q 1' {} \; \
e32ce1
  -print -exec sed -i '1d' {} \; \) -o \( \
e32ce1
  -perm /u+x,g+x,o+x ! -exec grep -m 1 -q '^#!' {} \; \
e32ce1
  -exec chmod a-x {} \; \) \)
e32ce1
e32ce1
# .xpm and .xbm files should not be executable:
e32ce1
find %{buildroot} \
e32ce1
  \( -name \*.xbm -o -name \*.xpm -o -name \*.xpm.1 \) \
e32ce1
  -exec chmod a-x {} \;
e32ce1
e32ce1
# Remove executable flag from files that shouldn't have it:
e32ce1
chmod a-x \
e32ce1
  %{buildroot}%{pylibdir}/distutils/tests/Setup.sample \
e32ce1
  %{buildroot}%{pylibdir}/Tools/README
e32ce1
e32ce1
# Get rid of DOS batch files:
e32ce1
find %{buildroot} -name \*.bat -exec rm {} \;
e32ce1
e32ce1
# Get rid of backup files:
e32ce1
find %{buildroot}/ -name "*~" -exec rm -f {} \;
e32ce1
find . -name "*~" -exec rm -f {} \;
e32ce1
rm -f %{buildroot}%{pylibdir}/LICENSE.txt
e32ce1
# Junk, no point in putting in -test sub-pkg
e32ce1
rm -f ${RPM_BUILD_ROOT}/%{pylibdir}/idlelib/testcode.py*
e32ce1
e32ce1
# Get rid of stray patch file from buildroot:
e32ce1
rm -f %{buildroot}%{pylibdir}/test/test_imp.py.apply-our-changes-to-expected-shebang # from patch 4
e32ce1
e32ce1
# Fix end-of-line encodings:
e32ce1
find %{buildroot}/ -name \*.py -exec sed -i 's/\r//' {} \;
e32ce1
e32ce1
# Fix an encoding:
e32ce1
iconv -f iso8859-1 -t utf-8 %{buildroot}/%{pylibdir}/Demo/rpc/README > README.conv && mv -f README.conv %{buildroot}/%{pylibdir}/Demo/rpc/README
e32ce1
e32ce1
# Note that 
e32ce1
#  %{pylibdir}/Demo/distutils/test2to3/setup.py
e32ce1
# is in iso-8859-1 encoding, and that this is deliberate; this is test data
e32ce1
# for the 2to3 tool, and one of the functions of the 2to3 tool is to fixup
e32ce1
# character encodings within python source code
e32ce1
e32ce1
# Do bytecompilation with the newly installed interpreter.
e32ce1
# This is similar to the script in macros.pybytecompile
e32ce1
# compile *.pyo
e32ce1
find %{buildroot} -type f -a -name "*.py" -print0 | \
e32ce1
    LD_LIBRARY_PATH="%{buildroot}%{dynload_dir}/:%{buildroot}%{_libdir}" \
e32ce1
    PYTHONPATH="%{buildroot}%{_libdir}/python%{pybasever} %{buildroot}%{_libdir}/python%{pybasever}/site-packages" \
e32ce1
    xargs -0 %{buildroot}%{_bindir}/python%{pybasever} -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("%{buildroot}")[2]) for f in sys.argv[1:]]' || :
e32ce1
# compile *.pyc
e32ce1
find %{buildroot} -type f -a -name "*.py" -print0 | \
e32ce1
    LD_LIBRARY_PATH="%{buildroot}%{dynload_dir}/:%{buildroot}%{_libdir}" \
e32ce1
    PYTHONPATH="%{buildroot}%{_libdir}/python%{pybasever} %{buildroot}%{_libdir}/python%{pybasever}/site-packages" \
e32ce1
    xargs -0 %{buildroot}%{_bindir}/python%{pybasever} -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("%{buildroot}")[2], optimize=0) for f in sys.argv[1:]]' || :
e32ce1
e32ce1
# Fixup permissions for shared libraries from non-standard 555 to standard 755:
e32ce1
find %{buildroot} \
e32ce1
    -perm 555 -exec chmod 755 {} \;
e32ce1
e32ce1
# Install macros for rpm:
e32ce1
mkdir -p %{buildroot}/%{_rpmconfigdir}/macros.d/
e32ce1
install -m 644 %{SOURCE3} %{buildroot}/%{_rpmconfigdir}/macros.d/
e32ce1
e32ce1
# Ensure that the curses module was linked against libncursesw.so, rather than
e32ce1
# libncurses.so (bug 539917)
e32ce1
ldd %{buildroot}/%{dynload_dir}/_curses*.so \
e32ce1
    | grep curses \
e32ce1
    | grep libncurses.so && (echo "_curses.so linked against libncurses.so" ; exit 1)
e32ce1
e32ce1
# Ensure that the debug modules are linked against the debug libpython, and
e32ce1
# likewise for the optimized modules and libpython:
e32ce1
for Module in %{buildroot}/%{dynload_dir}/*.so ; do
e32ce1
    case $Module in
e32ce1
    *.%{SOABI_debug})
e32ce1
        ldd $Module | grep %{py_INSTSONAME_optimized} &&
e32ce1
            (echo Debug module $Module linked against optimized %{py_INSTSONAME_optimized} ; exit 1)
e32ce1
            
e32ce1
        ;;
e32ce1
    *.%{SOABI_optimized})
e32ce1
        ldd $Module | grep %{py_INSTSONAME_debug} &&
e32ce1
            (echo Optimized module $Module linked against debug %{py_INSTSONAME_debug} ; exit 1)
e32ce1
        ;;
e32ce1
    esac
e32ce1
done
e32ce1
e32ce1
#
e32ce1
# Systemtap hooks:
e32ce1
#
e32ce1
%if 0%{?with_systemtap}
e32ce1
# Install a tapset for this libpython into tapsetdir, fixing up the path to the
e32ce1
# library:
e32ce1
mkdir -p %{buildroot}%{tapsetdir}
e32ce1
%ifarch %{power64} s390x x86_64 ia64 alpha sparc64 aarch64
e32ce1
%global libpython_stp_optimized libpython%{pybasever}-64.stp
e32ce1
%global libpython_stp_debug     libpython%{pybasever}-debug-64.stp
e32ce1
%else
e32ce1
%global libpython_stp_optimized libpython%{pybasever}-32.stp
e32ce1
%global libpython_stp_debug     libpython%{pybasever}-debug-32.stp
e32ce1
%endif
e32ce1
e32ce1
sed \
e32ce1
   -e "s|LIBRARY_PATH|%{_libdir}/%{py_INSTSONAME_optimized}|" \
e32ce1
   %{_sourcedir}/libpython.stp \
e32ce1
   > %{buildroot}%{tapsetdir}/%{libpython_stp_optimized}
e32ce1
e32ce1
%if 0%{?with_debug_build}
e32ce1
# In Python 3, python3 and python3-debug don't point to the same binary,
e32ce1
# so we have to replace "python3" with "python3-debug" to get systemtap
e32ce1
# working with debug build
e32ce1
sed \
e32ce1
   -e "s|LIBRARY_PATH|%{_libdir}/%{py_INSTSONAME_debug}|" \
e32ce1
   -e 's|"python3"|"python3-debug"|' \
e32ce1
   %{_sourcedir}/libpython.stp \
e32ce1
   > %{buildroot}%{tapsetdir}/%{libpython_stp_debug}
e32ce1
%endif # with_debug_build
e32ce1
e32ce1
%endif # with_systemtap
e32ce1
e32ce1
# Rename the script that differs on different arches to arch specific name
e32ce1
mv %{buildroot}%{_bindir}/python%{LDVERSION_optimized}-{,`uname -m`-}config
e32ce1
echo -e '#!/bin/sh\nexec `dirname $0`/python%{LDVERSION_optimized}-`uname -m`-config "$@"' > \
e32ce1
  %{buildroot}%{_bindir}/python%{LDVERSION_optimized}-config
e32ce1
echo '[ $? -eq 127 ] && echo "Could not find python%{LDVERSION_optimized}-`uname -m`-config. Look around to see available arches." >&2' >> \
e32ce1
  %{buildroot}%{_bindir}/python%{LDVERSION_optimized}-config
e32ce1
  chmod +x %{buildroot}%{_bindir}/python%{LDVERSION_optimized}-config
e32ce1
3fbbca
# Remove stuff that would conflict with python3 package
3fbbca
mv %{buildroot}%{_bindir}/python{3,%{pyshortver}}
3fbbca
rm %{buildroot}%{_bindir}/*3
3fbbca
rm %{buildroot}%{_bindir}/python3-*
3fbbca
rm %{buildroot}%{_bindir}/pyvenv
3fbbca
rm %{buildroot}%{_libdir}/libpython3.so
3fbbca
rm %{buildroot}%{_mandir}/man1/python3.1*
3fbbca
rm %{buildroot}%{_libdir}/pkgconfig/python3.pc
3fbbca
e32ce1
# ======================================================
e32ce1
# Running the upstream test suite
e32ce1
# ======================================================
e32ce1
e32ce1
%check
e32ce1
e32ce1
# first of all, check timestamps of bytecode files
e32ce1
find %{buildroot} -type f -a -name "*.py" -print0 | \
e32ce1
    LD_LIBRARY_PATH="%{buildroot}%{dynload_dir}/:%{buildroot}%{_libdir}" \
e32ce1
    PYTHONPATH="%{buildroot}%{_libdir}/python%{pybasever} %{buildroot}%{_libdir}/python%{pybasever}/site-packages" \
e32ce1
    xargs -0 %{buildroot}%{_bindir}/python%{pybasever} %{SOURCE8}
e32ce1
e32ce1
e32ce1
topdir=$(pwd)
e32ce1
CheckPython() {
e32ce1
  ConfName=$1	      
e32ce1
  ConfDir=$(pwd)/build/$ConfName
e32ce1
e32ce1
  echo STARTING: CHECKING OF PYTHON FOR CONFIGURATION: $ConfName
e32ce1
e32ce1
  # Note that we're running the tests using the version of the code in the
e32ce1
  # builddir, not in the buildroot.
e32ce1
e32ce1
  # Run the upstream test suite, setting "WITHIN_PYTHON_RPM_BUILD" so that the
e32ce1
  # our non-standard decorators take effect on the relevant tests:
e32ce1
  #   @unittest._skipInRpmBuild(reason)
e32ce1
  #   @unittest._expectedFailureInRpmBuild
e32ce1
  # test_faulthandler.test_register_chain currently fails on ppc64le and
e32ce1
  #   aarch64, see upstream bug http://bugs.python.org/issue21131
e32ce1
  WITHIN_PYTHON_RPM_BUILD= \
e32ce1
  LD_LIBRARY_PATH=$ConfDir $ConfDir/python -m test.regrtest \
e32ce1
    --verbose --findleaks \
e32ce1
    -x test_distutils \
e32ce1
    %ifarch ppc64le aarch64
e32ce1
    -x test_faulthandler \
e32ce1
    %endif
e32ce1
    %ifarch %{power64} s390 s390x armv7hl aarch64
e32ce1
    -x test_gdb
e32ce1
    %endif
e32ce1
e32ce1
  echo FINISHED: CHECKING OF PYTHON FOR CONFIGURATION: $ConfName
e32ce1
e32ce1
}
e32ce1
e32ce1
%if 0%{run_selftest_suite}
e32ce1
e32ce1
# Check each of the configurations:
e32ce1
%if 0%{?with_debug_build}
e32ce1
CheckPython debug
e32ce1
%endif # with_debug_build
e32ce1
CheckPython optimized
e32ce1
e32ce1
%endif # run_selftest_suite
e32ce1
e32ce1
e32ce1
# ======================================================
e32ce1
# Scriptlets
e32ce1
# ======================================================
e32ce1
590bf1
%post -p /sbin/ldconfig
e32ce1
590bf1
%postun -p /sbin/ldconfig
e32ce1
e32ce1
e32ce1
e32ce1
%files
e32ce1
%defattr(-, root, root)
e32ce1
%doc LICENSE README
08fb60
%doc Misc/README.valgrind Misc/valgrind-python.supp Misc/gdbinit
08fb60
3fbbca
%{_bindir}/pydoc%{pybasever}
e32ce1
%{_bindir}/python%{pybasever}
3fbbca
%{_bindir}/python%{pyshortver}
e32ce1
%{_bindir}/python%{pybasever}m
e32ce1
%{_bindir}/pyvenv-%{pybasever}
e32ce1
%{_mandir}/*/*
e32ce1
08fb60
%{pylibdir}/
e32ce1
e32ce1
%if "%{_lib}" == "lib64"
e32ce1
%attr(0755,root,root) %dir %{_prefix}/lib/python%{pybasever}
e32ce1
%attr(0755,root,root) %dir %{_prefix}/lib/python%{pybasever}/site-packages
e32ce1
%attr(0755,root,root) %dir %{_prefix}/lib/python%{pybasever}/site-packages/__pycache__/
e32ce1
%endif
e32ce1
e32ce1
%{_libdir}/%{py_INSTSONAME_optimized}
e32ce1
%if 0%{?with_systemtap}
e32ce1
%dir %(dirname %{tapsetdir})
e32ce1
%dir %{tapsetdir}
e32ce1
%{tapsetdir}/%{libpython_stp_optimized}
e32ce1
%doc systemtap-example.stp pyfuntop.stp
e32ce1
%endif
e32ce1
08fb60
%{_includedir}/python%{LDVERSION_optimized}/
590bf1
e32ce1
%{_bindir}/python%{pybasever}-config
e32ce1
%{_bindir}/python%{LDVERSION_optimized}-config
e32ce1
%{_bindir}/python%{LDVERSION_optimized}-*-config
e32ce1
%{_libdir}/libpython%{LDVERSION_optimized}.so
e32ce1
%{_libdir}/pkgconfig/python-%{LDVERSION_optimized}.pc
e32ce1
%{_libdir}/pkgconfig/python-%{pybasever}.pc
08fb60
%exclude %{_rpmconfigdir}/macros.d/macros.pybytecompile%{pybasever}
e32ce1
e32ce1
%{_bindir}/2to3-%{pybasever}
3fbbca
%{_bindir}/idle%{pybasever}
e32ce1
e32ce1
%if 0%{?with_debug_build}
e32ce1
%{_bindir}/python%{LDVERSION_debug}
e32ce1
e32ce1
%{_libdir}/%{py_INSTSONAME_debug}
e32ce1
%if 0%{?with_systemtap}
e32ce1
%{tapsetdir}/%{libpython_stp_debug}
e32ce1
%endif
e32ce1
e32ce1
%{_includedir}/python%{LDVERSION_debug}
e32ce1
%{_bindir}/python%{LDVERSION_debug}-config
e32ce1
%{_libdir}/libpython%{LDVERSION_debug}.so
08fb60
%{_libdir}/libpython%{LDVERSION_debug}.so.1.0
e32ce1
%{_libdir}/pkgconfig/python-%{LDVERSION_debug}.pc
e32ce1
e32ce1
%endif # with_debug_build
e32ce1
e32ce1
e32ce1
# ======================================================
e32ce1
# Finally, the changelog:
e32ce1
# ======================================================
e32ce1
e32ce1
%changelog
b68910
* Fri Oct 21 2016 Miro Hrončok <mhroncok@redhat.com> - 3.4.5-2
b68910
- Reword the description
92f62d
- On Fedora 26+, BR compat-openssl10-devel
b68910
57f132
* Thu Sep 22 2016 Miro Hrončok <mhroncok@redhat.com> - 3.4.5-1
57f132
- Updated to 3.4.5
57f132
b5ef39
* Thu Aug 11 2016 Miro Hrončok <mhroncok@redhat.com> - 3.4.3-11
b5ef39
- Imported from F23