A new user interface for you! Read more...

File python3.spec of Package python3

#
# spec file for package python3
#
# Copyright (c) 2019 SUSE LINUX 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 https://bugs.opensuse.org/
#


# do not add defs here, please edit python3-base.spec instead
# and run pre_checkin.sh
#
# see PACKAGING-NOTES for details
#
### COMMON-DEF-BEGIN ###
%define         tarversion %{version}
%define         tarname    Python-%{tarversion}
# the versions are autogenerated from pre_checkin.sh
# based on the current source tarball
%define         python_version          3.7
%define         python_version_abitag   37
%define         python_version_soname   3_7
%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}
# version part of "libpython" package
%define         so_major 1
%define         so_minor 0
%define         so_version %{python_version_soname}%{abi_kind}%{so_major}_%{so_minor}
# rpm and python have different ideas about what is an arch-dependent name, so:
%if %{__isa_name} == ppc
%define archname %(echo %{_arch} | sed s/ppc/powerpc/)
%else
%define archname %{_arch}
%endif
# our arm has Hardware-Floatingpoint
%if %{_arch} == arm
%define armsuffix hf
%endif
# pyexpat.cpython-35m-x86_64-linux-gnu
# pyexpat.cpython-35m-powerpc64le-linux-gnu
# pyexpat.cpython-35m-armv7-linux-gnueabihf
%define dynlib() %{sitedir}/lib-dynload/%{1}.cpython-%{abi_tag}-%{archname}-%{_os}%{?_gnu}%{?armsuffix}.so
### COMMON-DEF-END ###
#
Name:           python3
Version:        3.7.2
Release:        0
Summary:        Python 3 Interpreter
License:        Python-2.0
Group:          Development/Languages/Python
URL:            http://www.python.org/
Source0:        http://www.python.org/ftp/python/%{version}/%{tarname}.tar.xz
Source1:        http://www.python.org/ftp/python/%{version}/%{tarname}.tar.xz.asc
BuildRequires:  automake
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  gdbm-devel
# Not using gettext-tools to avoid pulling glib2 dependencies to the chain
BuildRequires:  gettext-runtime-mini
BuildRequires:  gmp-devel
BuildRequires:  intltool
BuildRequires:  libbz2-devel
BuildRequires:  libexpat-devel
BuildRequires:  libffi-devel
# Installed libnsl-devel leads to build failures on nismodule.o
# https://bugs.python.org/issue32007
# %%if 0%%{?sle_version} >= 1500 && 0%%{?is_opensuse}
# BuildRequires:  libnsl-devel
# %%endif
BuildRequires:  bluez-devel
BuildRequires:  lzma-devel
BuildRequires:  ncurses-devel
BuildRequires:  netcfg
BuildRequires:  openssl-devel
BuildRequires:  pkgconfig
BuildRequires:  readline-devel
BuildRequires:  sqlite-devel
BuildRequires:  timezone
BuildRequires:  tk-devel
BuildRequires:  xz
BuildRequires:  pkgconfig(x11)
Requires:       python3-base = %{version}
Recommends:     python3-curses
Recommends:     python3-dbm
Recommends:     python3-pip
Provides:       python = %{python_version}
#
# do not add patches here, please edit python3-base.spec instead
# and run pre_checkin.sh
#
# see PACKAGING-NOTES for details
#
### COMMON-PATCH-BEGIN ###
# support lib-vs-lib64 distinction
# New version from https://bugs.python.org/issue34032
# Patch02:        python-3.6.0-multilib-new.patch
# Unfortunately, the new version is still broken, so we have to use the
# old one
Patch02:        python-3.6.0-multilib.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
# POSIX_FADV_WILLNEED throws EINVAL. Use a different constant in test
Patch09:        python-3.3.0b1-test-posix_fadvise.patch
# Raise timeout value for test_subprocess
Patch15:        subprocess-raise-timeout.patch
# skip some tests only for PowerPC
Patch23:        skip_random_failing_tests.patch
# Fix SOURCE_DATE_EPOCH problems (bpo-34022, bpo-29708)
# https://github.com/python/cpython/pull/10775
# https://github.com/python/cpython/pull/10327
Patch24:        bpo34022-stop_hash-based_invalidation_w_SOURCE_DATE_EPOCH.patch
Patch25:        python3-imp-returntype.patch
# https://github.com/python/cpython/pull/7778
Patch26:        raise_SIGING_not_handled.patch
# Fix installation in /usr/local (boo#1071941), originally from Fedora
# https://src.fedoraproject.org/rpms/python3/blob/master/f/00251-change-user-install-location.patch
# Set values of prefix and exec_prefix in distutils install command
# to /usr/local if executable is /usr/bin/python* and RPM build
# is not detected to make pip and distutils install into separate location
Patch27:        boo1071941-make-install-in-sep-loc.patch
Patch100:        reproducible-distutils.patch
# PATCH-FIX-UPSTREAM CVE-2019-5010-null-defer-x509-cert-DOS.patch bnc#1122191 mcepl@suse.com
# https://github.com/python/cpython/pull/11569
# Fix segfault in ssl's cert parser
Patch28:        CVE-2019-5010-null-defer-x509-cert-DOS.patch
### COMMON-PATCH-END ###

%description
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 python3-doc
package.

This package supplies rich command line features provided by readline,
and sqlite3 support for the interpreter core, thus forming a so called
"extended" runtime.
Installing "python3" is sufficient for the vast majority of usecases.
In addition, recommended packages provide UI toolkit support (python3-curses,
python3-tk), legacy UNIX database bindings (python3-dbm), and the IDLE
development environment (python3-idle).

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

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

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

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

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

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

%prep
%setup -q -n %{tarname}
### COMMON-PREP-BEGIN ###
%patch02 -p1
%patch04
%patch06 -p1
%patch09 -p1
# %%patch12 -p1
%patch15 -p1
%ifarch ppc ppc64 ppc64le
%patch23 -p1
%endif
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
# vv bmw vv
%patch100 -p1
# ^^ bmw ^^

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

# fix shebangs - convert /usr/local/bin/python and /usr/bin/env/python to /usr/bin/python3
for dir in Lib Tools; do
    # find *.py, filter to files that contain bad shebangs
    # break up "/""usr" like this to prevent replacing with %%{_prefix}
    find $dir -name '*.py' -type f -print0 \
        | xargs -0 grep -lE '^#! *(/''usr/.*bin/(env +)?)?python' \
        | xargs sed -r -i -e '1s@^#![[:space:]]*(/''usr/(local/)?bin/(env +)?)?python([0-9]+(\.[0-9]+)?)?@#!%{_bindir}/python3@'
done

# drop in-tree libffi and expat
rm -r Modules/_ctypes/libffi* Modules/_ctypes/darwin
rm -r Modules/expat

# drop duplicate README from site-packages
rm Lib/site-packages/README.txt

### COMMON-PREP-END ###

%build
### COMMON-CONFIG-BEGIN ###
# use rpm_opt_flags
export OPT="%{optflags} -DOPENSSL_LOAD_CONF -fwrapv $(pkg-config --cflags-only-I libffi)"

touch -r %{SOURCE0} Makefile.pre.in

autoreconf -fvi

%if 0%{?sles_version}
sed -e 's/-fprofile-correction//' -i Makefile.pre.in
%endif

%configure \
    --docdir=%{_docdir}/python \
    --enable-ipv6 \
    --enable-shared \
    --with-ensurepip=no \
    --with-system-ffi \
    --with-system-expat \
%if 0%{?sle_version} >= 150000 && 0%{?is_opensuse}
    --with-lto \
%endif
%if %{with profileopt}
    --enable-optimizations \
%endif
    --enable-loadable-sqlite-extensions

%ifarch aarch64
# Builds fail on aarch64 because test_threading locks up
export PROFILE_TASK="-m test.regrtest --pgo -x test_threading"
%endif

# prevent make from trying to rebuild PYTHON_FOR_GEN stuff
make -t Python/Python-ast.c \
        Include/Python-ast.h \
        Objects/typeslots.inc \
        Python/opcode_targets.h \
        Include/opcode.h

### COMMON-CONFIG-END ###

make %{?_smp_mflags}

%check
# exclude test_gdb -- it doesn't run in buildservice anyway, and fails on missing debuginfos
# when you install gdb into your test env
EXCLUDE="test_gdb"
# we patch out the message to recommend zypper in and thus this would fail
EXCLUDE="$EXCLUDE test_pydoc"

%ifarch %{arm} s390x
# test_multiprocessing_forkserver is racy
EXCLUDE="$EXCLUDE test_multiprocessing_forkserver"
%endif
%ifarch ppc ppc64 ppc64le
# exclue test_faulthandler due to bnc#831629
EXCLUDE="$EXCLUDE test_faulthandler"
%endif
# some tests break in QEMU
%if 0%{?qemu_user_space_build} > 0
EXCLUDE="$EXCLUDE test_asyncio test_multiprocessing_fork test_multiprocessing_forkserver test_multiprocessing_main_handling test_multiprocessing_spawn test_threading test_threadedtempfile test_io test_posix test_ioctl test_mmap test_openpty test_pty test_time test_subprocess test_asyncore test_asyncio test_os test_faulthandler"
# qemu bug (siginterrupt handling)
EXCLUDE="$EXCLUDE test_signal"
%endif

# This test (part of test_uuid) requires real network interfaces
# so that ifconfig output has "HWaddr <something>".  Some kvm instances
# done have any such interface breaking the uuid module.
EXCLUDE="$EXCLUDE test_uuid"

# # https://bugs.python.org/issue34022
# # There seems to be troubles with the following tests when reproducible
# # build (with SOURCE_DATE_EPOCH environmental variable set) is run
EXCLUDE="$EXCLUDE test_cmd_line_script test_multiprocessing_main_handling test_runpy"

# Limit virtual memory to avoid spurious failures
if test $(ulimit -v) = unlimited || test $(ulimit -v) -gt 10000000; then
  ulimit -v 10000000 || :
fi

export PYTHONPATH="$(pwd -P)/Lib" 
make -j1 test TESTOPTS="-u curses -v -x $EXCLUDE"
# use network, be verbose:
#make test TESTOPTS="-l -u network -v"

%install
%make_install

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

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

rm -r %{buildroot}%{sitedir}/config*
find %{buildroot}%{sitedir} -name "*.egg-info" -delete
rm -r %{buildroot}%{sitedir}/__pycache__
rm -r %{buildroot}%{sitedir}/site-packages
rm %{buildroot}%{sitedir}/*.*

for module in \
    asyncio ctypes collections concurrent distutils email encodings \
    ensurepip html http \
    importlib json logging multiprocessing pydoc_data unittest \
    urllib venv wsgiref lib2to3 test idlelib turtledemo \
    xml xmlrpc
do
    rm -r %{buildroot}%{sitedir}/$module
done

for library in \
    array _asyncio audioop binascii _bisect _bz2 cmath _codecs_* \
    _contextvars _crypt _csv _ctypes _datetime _decimal fcntl grp \
    _hashlib _heapq _json _lsprof _lzma math mmap _multibytecodec \
    _multiprocessing _opcode ossaudiodev parser _pickle _posixsubprocess \
    _queue _random resource select _ssl _socket spwd _struct syslog termios \
    _testbuffer _testimportmultiple _testmultiphase unicodedata zlib \
    _ctypes_test _testcapi xxlimited _xxtestfuzz _elementtree pyexpat \
    _md5 _sha1 _sha256 _sha512 _blake2 _sha3
do
    eval rm "%{buildroot}%{sitedir}/lib-dynload/$library.*"
done

%fdupes %{buildroot}/%{_libdir}/python%{python_version}

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

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

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

%files
%defattr(644, root, root, 755)
%dir %{sitedir}
%dir %{sitedir}/lib-dynload
%{sitedir}/sqlite3
%exclude %{sitedir}/sqlite3/test
%if 0%{?suse_version} < 1500
%{dynlib nis}
%endif
%{dynlib readline}
%{dynlib _sqlite3}

%changelog