File python3.spec of Package python3-base

# spec file for package python3
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

Name:           python3
BuildRequires:  automake
BuildRequires:  db-devel
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  gdbm-devel
BuildRequires:  gettext-tools
BuildRequires:  gmp-devel
BuildRequires:  intltool
BuildRequires:  libbz2-devel
BuildRequires:  libexpat-devel
BuildRequires:  libffi-devel
BuildRequires:  libopenssl-devel
BuildRequires:  lzma-devel
BuildRequires:  ncurses-devel
BuildRequires:  readline-devel
BuildRequires:  sqlite-devel
BuildRequires:  tk-devel
BuildRequires:  xorg-x11-devel
BuildRequires:  xz
Summary:        Python3 Interpreter
License:        Python-2.0
Group:          Development/Languages/Python
Version:        3.3.3
Release:        0
%define         tarversion %{version}
%define         tarname        Python-%{tarversion}

Requires:       python3-base = %{version}

Source1:        baselibs.conf
#Source11:       testfiles.tar.bz2
# issues with copyrighted Unicode testing files

# do not add patches here, please edit python3-base.spec instead
# and run
# see PACKAGING-NOTES for details


# implement "--record-rpm" option for distutils installations
Patch01:        Python-3.0b1-record-rpm.patch
# support lib-vs-lib64 distinction
Patch02:        Python-3.3.0b2-multilib.patch
# securing usage of readlink/realpath in PySys_SetArgv
Patch03:        python-2.6b1-canonicalize2.patch
# support finding packages in /usr/local, install to /usr/local by default
Patch04:        python-3.3.0b1-localpath.patch
# replace DATE, TIME and COMPILER by fixed definitions to aid reproducible builds
Patch06:        python-3.3.0b1-fix_date_time_compiler.patch
# fix wrong include path in curses-panel module
Patch07:        python-3.3.0b1-curses-panel.patch
# POSIX_FADV_WILLNEED throws EINVAL. Use a different constant in test
Patch09:        python-3.3.0b1-test-posix_fadvise.patch
# Add missing bits for aarch64 in libffi
Patch10:        ctypes-libffi-aarch64.patch
# Disable SO_REUSEPORT constant in tests, because it's not supported on older kernels
Patch11:        python-3.3.2-no-REUSEPORT.patch
# Disable global and distutils sysconfig comparison test, we deviate from the default depending on optflags
Patch12:        python-3.3.3-skip-distutils-test_sysconfig_module.patch
# Add support for ppc64le (ELFv2) to libffi copy for ctypes
Patch13:        libffi-ppc64le.diff

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

# do not add defs here, please edit python3-base.spec instead
# and run
# see PACKAGING-NOTES for details


# the versions are autogenerated from
# based on the current source tarball
%define         python_version  3.3

%define         python_version_abitag   33
%define         python_version_soname   3_3

%define         sitedir         %{_libdir}/python%{python_version}

# three possible ABI kinds: m - pymalloc, d - debug build
# see PEP 3149
%define         abi_kind m
# python ABI version - used in some file names
%define         python_abi %{python_version}%{abi_kind}
# soname ABI tag defined in PEP 3149
%define         abi_tag %{python_version_abitag}%{abi_kind}

%define         so_version %{python_version_soname}%{abi_kind}1_0

%define dynlib() %{sitedir}/lib-dynload/%{1}.cpython-%{abi_tag}.so

# some compatibility Provides
Provides:       python = %{python_version}
Provides:       python3 = %{python_version}

Provides:       python3-xml = %{version}
Obsoletes:      python3-xml < %{version}

Python 3 is modern interpreted, object-oriented programming language,
often compared to Tcl, Perl, Scheme, or Java.  You can find an overview
of Python in the documentation and tutorials included in the python-doc
(HTML) or python-doc-pdf (PDF) packages.

If you want to install third party modules using distutils, you need to
install python-devel package.

    Guido van Rossum <>

%package tk
Requires:       %{name} = %{version}
Summary:        TkInter - Python Tk Interface
Group:          Development/Libraries/Python

%description tk
Python interface to Tk. Tk is the GUI toolkit that comes with Tcl. The
"xrpm" package uses this Python interface.

%package curses
Requires:       %{name} = %{version}
Summary:        Python Interface to the (N)Curses Library
Group:          Development/Libraries/Python

%description curses
An easy to use interface to the (n)curses CUI library. CUI stands for
Console User Interface.

%package dbm
Requires:       %{name} = %{version}
Summary:        Python Interface to the GDBM Library
Group:          Development/Languages/Python

%description dbm
An easy to use interface for Unix DBM databases, and more specifically,
the GNU implementation GDBM.

%setup -q -n %{tarname}

%patch01 -p1
%patch02 -p1
#- canonicalize disabled, needs testing whether the exploit still works
%patch06 -p1
%patch09 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p0

# drop Autoconf version requirement
sed -i 's/^AC_PREREQ/dnl AC_PREREQ/'


export OPT="%{optflags} -DOPENSSL_LOAD_CONF"

autoreconf -f -i .
# prevent make from trying to rebuild asdl stuff, which requires existing
# python installation
touch Parser/asdl* Python/Python-ast.c Include/Python-ast.h Objects/

./configure \
    --prefix=%{_prefix} \
    --libdir=%{_libdir} \
    --mandir=%{_mandir} \
    --docdir=%{_docdir}/python \
    --enable-ipv6 \
    --with-fpectl \
    --enable-shared \
    --with-system-ffi \

make %{?_smp_mflags} # DESTDIR=$RPM_BUILD_ROOT

# Limit virtual memory to avoid spurious failures
if test $(ulimit -v) = unlimited || test $(ulimit -v) -gt 10000000; then
  ulimit -v 10000000 || :
# only test the parts skipped in python3-base
TESTS="test_dbm_gnu test_dbm_ndbm test_readline test_ssl test_tcl test_tk test_ttk_guionly test_ttk_textonly test_curses test_socketserver test_sqlite test_hashlib test_smtpnet"
make test TESTOPTS="-u -network,-gui $TESTS"

make \
    OPT="%{optflags} -fPIC" \

# clean out stuff that is in python-base and subpackages

rm $RPM_BUILD_ROOT%{_bindir}/*
rm $RPM_BUILD_ROOT%{_libdir}/lib*
rm -r $RPM_BUILD_ROOT%{_libdir}/pkgconfig
rm -r $RPM_BUILD_ROOT%{_mandir}/*
rm -r $RPM_BUILD_ROOT%{_includedir}/*

rm -r $RPM_BUILD_ROOT%{sitedir}/config*
find $RPM_BUILD_ROOT%{sitedir} -name "*.egg-info" -exec rm {} ";"
rm -r $RPM_BUILD_ROOT%{sitedir}/__pycache__
rm -r $RPM_BUILD_ROOT%{sitedir}/site-packages
rm $RPM_BUILD_ROOT%{sitedir}/*.*

for module in \
    ctypes collections concurrent distutils email encodings html http \
    importlib json logging multiprocessing plat-* pydoc_data unittest \
    urllib venv wsgiref lib2to3 test idlelib turtledemo
    rm -r $RPM_BUILD_ROOT%{sitedir}/$module

for library in \
    array atexit audioop binascii _bisect _bz2 cmath _codecs_* _crypt _csv \
    _ctypes _datetime _decimal _elementtree fcntl grp _heapq _json _lsprof \
    _lzma \
    math mmap _multibytecodec _multiprocessing nis ossaudiodev parser _pickle \
    _posixsubprocess _random resource select _socket spwd _struct syslog \
    termios _testbuffer time unicodedata zlib _ctypes_test _testcapi xxlimited \
    _md5 _sha1 _sha256 _sha512
    eval rm "$RPM_BUILD_ROOT%{sitedir}/lib-dynload/$library.*"

# fix shebangs
find $RPM_BUILD_ROOT%{sitedir} -name '*.py' -type f -print0 \
  | xargs -0 sed -r -i -e '1s@^#![[:space:]]*(/usr/(local/)?bin/(env +)?)?python([0-9]+(\.[0-9]+)?)?@#!/usr/bin/python3@'

%fdupes $RPM_BUILD_ROOT/%{_libdir}/python%{python_version}

%files tk
%defattr(644, root, root, 755)
%exclude %{sitedir}/tkinter/test
%{dynlib _tkinter}

%files curses
%defattr(644, root, root, 755)
%{dynlib _curses}
%{dynlib _curses_panel}

%files dbm
%defattr(644, root, root, 755)
%{dynlib _dbm}
%{dynlib _gdbm}

%defattr(644, root, root, 755)
%dir %{sitedir}
%dir %{sitedir}/lib-dynload
%exclude %{sitedir}/sqlite3/test
%{dynlib _hashlib}
%{dynlib pyexpat}
%{dynlib readline}
%{dynlib _sqlite3}
%{dynlib _ssl}