LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File python3-base.spec of Package python3-base (Project home:in4ops:lang--c--procedure--o--python--f--python3)

# spec file for package python3-base
# Copyright (c) 2018 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 http://bugs.opensuse.org/

# !!!!
# this is the master spec file, but changes should be submitted
# against python3, not python3-base
# see PACKAGING-NOTES for details
# !!!!
%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.6
%define         python_version_abitag   36
%define         python_version_soname   3_6
%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/)
%define archname %{_arch}
# our arm has Hardware-Floatingpoint
%if %{_arch} == arm
%define armsuffix hf
# 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
# that thing where "without" means "default=on" and vice versa
%bcond_without testsuite
%if 0%{?do_profiling}
%bcond_without profileopt
%bcond_with    profileopt
Name:           python3-base
Version:        3.6.5
Release:        0
Summary:        Python 3 Interpreter and Stdlib Core
License:        Python-2.0
Group:          Development/Languages/Python
URL:            http://www.python.org/
##### SOURCE FILES #####
Source0:        http://www.python.org/ftp/python/%{version}/%{tarname}.tar.xz
Source1:        http://www.python.org/ftp/python/%{version}/%{tarname}.tar.xz.asc
Source2:        python.keyring
Source3:        baselibs.conf
Source4:        README.SUSE
Source8:        macros.python3
Source9:        import_failed.py
Source10:       import_failed.map
# The following files are not used in the build.
# They are listed here to work around missing functionality in rpmbuild,
# which would otherwise exclude them from distributed src.rpm files.
Source100:      PACKAGING-NOTES
Source101:      python3-rpmlintrc
Source102:      pre_checkin.sh
Source103:      skipped_tests.py
Requires:       python-rpm-macros
Recommends:     python3 = %{version}
#Recommends:     python3-ensurepip
# python 3.1 didn't have a separate python-base, so it is wrongly
# not a conflict to have python3-3.1 and python3-base > 3.1
Obsoletes:      python3 < 3.2
# no Provides, because python3 is obviously provided by package python3
# python 3.4 provides asyncio
Provides:       python3-asyncio = %{version}
Obsoletes:      python3-asyncio < %{version}
# python 3.6 provides typing
Provides:       python3-typing = %{version}
Obsoletes:      python3-typing < %{version}
# python3-xml was merged into python3, now moved into -base
Provides:       python3-xml = %{version}
Obsoletes:      python3-xml < %{version}
# SECTION required for basic build
BuildRequires:  automake
BuildRequires:  pkgconfig
# SECTION required for core modules
# The compression-related ones could be moved to python3 if necessary, with the exception of zlib.
# _bz2
BuildRequires:  libbz2-devel
# pyexpat, _elementtree
BuildRequires:  libexpat-devel
# _ctypes
BuildRequires:  libffi-devel
# nis
BuildRequires:  libnsl-devel
# _lzma
BuildRequires:  lzma-devel
# ssl
BuildRequires:  openssl-devel >= 1.0.2
# zlib
BuildRequires:  zlib-devel
# SECTION required for build and testsuite
BuildRequires:  fdupes
# netcfg is needed *only* for /etc/services for one test in test_asyncio
# this could be moved to python3 if needed, it's just more convenient here
BuildRequires:  netcfg
BuildRequires:  timezone
BuildRequires:  xz
# implement "--record-rpm" option for distutils installations
Patch01:        Python-3.0b1-record-rpm.patch
# support lib-vs-lib64 distinction
Patch02:        python-3.6.0-multilib-new.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
# 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
# Raise timeout value for test_subprocess
Patch15:        subprocess-raise-timeout.patch
# PATCH-FIX-UPSTREAM bmwiedemann@suse.de -- https://github.com/python/cpython/pull/296
Patch21:        0001-allow-for-reproducible-builds-of-python-packages.patch
# PATCH-FEATURE-OPENSUSE order files for compilation until the underlying cause of bsc#1049186 is resolved
Patch22:        distutils-reproducible-compile.patch
# skip some tests only for PowerPC
Patch23:        skip_random_failing_tests.patch
# PATCH-FIX-UPSTREAM sorted tar https://github.com/python/cpython/pull/2263
Patch24:        python3-sorted_tar.patch

Python is an interpreted, object-oriented programming language, and is
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

This package contains the interpreter core and most commonly used modules
from the standard library. This is sufficient for many usecases, but it
excludes components that depend on external libraries, most notably XML,
database and UI toolkits support.

%package -n python3-tools
Summary:        Python Utility and Demonstration Scripts
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Obsoletes:      python3-demo < %{version}
Provides:       python3-demo = %{version}
Obsoletes:      python3-2to3 < %{version}
Provides:       python3-2to3 = %{version}

%description -n python3-tools
A number of scripts that are useful for building, testing or extending Python,
and a set of demonstration programs.

%package -n python3-idle
Summary:        An Integrated Development Environment for Python
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Requires:       python3-tk

%description -n python3-idle
IDLE is a Tkinter based integrated development environment for Python.
It features a multi-window text editor with multiple undo, Python
colorizing, and many other things, as well as a Python shell window and
a debugger.

%package -n python3-devel
Summary:        Include Files and Libraries Mandatory for Building Python Modules
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description -n python3-devel
The Python programming language's interpreter can be extended with
dynamically loaded extensions and can be embedded in other programs.

This package contains header files, a static library, and development
tools for building Python modules, extending the Python interpreter or
embedding Python in applications.

This also includes the Python distutils, which were in the Python
package up to version 2.2.2.

%package -n python3-testsuite
Summary:        Unit tests for Python and its standard library
Group:          Development/Languages/Python
Requires:       python3 = %{version}
Requires:       python3-tk = %{version}

%description -n python3-testsuite
Unit tests that are useful for verifying integrity and functionality
of the installed Python interpreter and standard library.
They are a documented part of stdlib, as a module 'test'.

%package -n libpython%{so_version}
Summary:        Python Interpreter shared library
Group:          Development/Languages/Python

%description -n libpython%{so_version}
Python is an interpreted, object-oriented programming language, and is
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.

This package contains libpython3.2 shared library for embedding in
other applications.

%setup -q -n %{tarname}

%patch01 -p1
%patch02 -p1
%patch06 -p1
%patch09 -p1
%patch12 -p1
%patch15 -p1
%patch21 -p1
%patch22 -p1
%ifarch ppc ppc64 ppc64le
%patch23 -p1
%patch24 -p1

# 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@'

# 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


# use rpm_opt_flags
export OPT="%{optflags} -DOPENSSL_LOAD_CONF $(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

%configure \
    --docdir=%{_docdir}/python \
    --enable-ipv6 \
    --with-fpectl \
    --enable-shared \
    --with-ensurepip=no \
    --with-system-ffi \
    --with-system-expat \

# 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 \


%if %{with profileopt}
    make %{?_smp_mflags} $target


# remove .a
find %{buildroot} -name "*.a" -exec rm {} ";"
# install "site-packages" and __pycache__ for third parties
install -d -m 755 %{buildroot}%{sitedir}/site-packages
install -d -m 755 %{buildroot}%{sitedir}/site-packages/__pycache__
# and their 32bit counterparts explicitly
mkdir -p %{buildroot}%{_prefix}/lib/python%{python_version}/site-packages/__pycache__

# cleanup parts that don't belong
for dir in curses dbm sqlite3 tkinter; do
    find %{buildroot}%{sitedir}/$dir/* -maxdepth 0 -name "test" -o -exec rm -rf {} ";"
# rm $RPM_BUILD_ROOT%{dynlib pyexpat}

# overwrite the copied binary with a link
ln -sf python%{python_version} %{buildroot}%{_bindir}/python3

# link shared library instead of static library that tools expect
ln -s ../../libpython%{python_abi}.so %{buildroot}%{_libdir}/python%{python_version}/config-%{python_abi}-%{archname}-%{_os}%{?_gnu}%{?armsuffix}/libpython%{python_abi}.so

# replace duplicate .pyo/.pyc with hardlinks
%fdupes %{buildroot}/%{sitedir}

# documentation
export PDOCS=%{buildroot}%{_docdir}/%{name}
install -d -m 755 $PDOCS
install -c -m 644 %{SOURCE4} $PDOCS/
install -c -m 644 LICENSE    $PDOCS/
install -c -m 644 README.rst $PDOCS/

# tools
for x in `find Tools/ \( -not -name Makefile \) -print | sort` ; do
  test -d $x && ( install -c -m 755 -d $PDOCS/$x ) \
             || ( install -c -m 644 $x $PDOCS/$x )
# gdb script is shipped with devel subpackage
rm -r $PDOCS/Tools/gdb
# clean up the bat files
find $PDOCS -name "*.bat" -exec rm {} ";"

# put gdb helper script into place
install -m 755 -D Tools/gdb/libpython.py %{buildroot}%{_datadir}/gdb/auto-load/%{_libdir}/libpython%{python_abi}.so.%{so_major}.%{so_minor}-gdb.py

# install devel files to /config
#cp Makefile Makefile.pre.in Makefile.pre $RPM_BUILD_ROOT%{sitedir}/config-%{python_abi}/

# move idle config into /etc
install -d -m 755 %{buildroot}%{_sysconfdir}/idle3
    cd %{buildroot}/%{sitedir}/idlelib/
    for file in *.def ; do
        mv $file %{buildroot}%{_sysconfdir}/idle3/
        ln -sf %{_sysconfdir}/idle3/$file  %{buildroot}/%{sitedir}/idlelib/

# RPM macros
mkdir -p %{buildroot}%{_sysconfdir}/rpm
install -m 644 %{SOURCE8} %{buildroot}%{_sysconfdir}/rpm # macros.python3

# import_failed hooks
mkdir $FAILDIR
install -m 644 %{SOURCE9} %{SOURCE10} $FAILDIR # import_failed.*
LD_LIBRARY_PATH=. ./python -c "from py_compile import compile; compile('$FAILDIR/import_failed.py', dfile='%{sitedir}/_import_failed/import_failed.py')"
LD_LIBRARY_PATH=. ./python -O -c "from py_compile import compile; compile('$FAILDIR/import_failed.py', dfile='%{sitedir}/_import_failed/import_failed.py')"
    cd $FAILDIR
    while read package modules; do
        for module in $modules; do
            ln import_failed.py $module.py
            pushd __pycache__
            for i in import_failed*; do
                ln $i "$module${i#import_failed}"
    done < %{SOURCE10}
echo %{sitedir}/_import_failed > %{buildroot}/%{sitedir}/site-packages/zzzz-import-failed-hooks.pth

%post -n libpython%{so_version} -p /sbin/ldconfig
%postun -n libpython%{so_version} -p /sbin/ldconfig

%files -n libpython%{so_version}
%defattr(644, root,root)

%files -n python3-tools
%defattr(644, root, root, 755)
%attr(755, root, root)%{_bindir}/2to3-%{python_version}
%doc %{_docdir}/%{name}/Tools

%files -n python3-idle
%defattr(644, root, root, 755)
%dir %{_sysconfdir}/idle3
%config %{_sysconfdir}/idle3/*
%doc Lib/idlelib/NEWS.txt
%doc Lib/idlelib/README.txt
%doc Lib/idlelib/TODO.txt
%doc Lib/idlelib/extend.txt
%doc Lib/idlelib/ChangeLog
%attr(755, root, root) %{_bindir}/idle%{python_version}

%files -n python3-devel
%defattr(644, root, root, 755)
%defattr(755, root, root)
# Own these directories to not depend on gdb
%dir %{_datadir}/gdb
%dir %{_datadir}/gdb/auto-load
%dir %{_datadir}/gdb/auto-load%{_prefix}
%dir %{_datadir}/gdb/auto-load%{_libdir}

%files -n python3-testsuite
%defattr(644, root, root, 755)
%{dynlib _ctypes_test}
%{dynlib _testbuffer}
%{dynlib _testcapi}
%{dynlib _testimportmultiple}
%{dynlib _testmultiphase}
%{dynlib xxlimited}
# workaround for missing packages
%dir %{sitedir}/sqlite3
%dir %{sitedir}/tkinter

%defattr(644, root, root, 755)
# docs
%dir %{_docdir}/%{name}
%doc %{_docdir}/%{name}/README.rst
%license %{_docdir}/%{name}/LICENSE
%doc %{_docdir}/%{name}/README.SUSE
# license text, not a doc because the code can use it at run-time
# RPM macros
# binary parts
%dir %{sitedir}/lib-dynload
%{dynlib array}
%{dynlib _asyncio}
%{dynlib audioop}
%{dynlib binascii}
%{dynlib _bisect}
%{dynlib _bz2}
%{dynlib cmath}
%{dynlib _codecs_cn}
%{dynlib _codecs_hk}
%{dynlib _codecs_iso2022}
%{dynlib _codecs_jp}
%{dynlib _codecs_kr}
%{dynlib _codecs_tw}
%{dynlib _crypt}
%{dynlib _csv}
%{dynlib _ctypes}
%{dynlib _datetime}
%{dynlib _decimal}
%{dynlib _elementtree}
%{dynlib fcntl}
%{dynlib grp}
%{dynlib _hashlib}
%{dynlib _heapq}
%{dynlib _json}
%{dynlib _lsprof}
%{dynlib _lzma}
%{dynlib math}
%{dynlib mmap}
%{dynlib _multibytecodec}
%{dynlib _multiprocessing}
%{dynlib nis}
%{dynlib ossaudiodev}
%{dynlib _opcode}
%{dynlib parser}
%{dynlib _pickle}
%{dynlib _posixsubprocess}
%{dynlib pyexpat}
%{dynlib _random}
%{dynlib resource}
%{dynlib select}
%{dynlib _socket}
%{dynlib _ssl}
%{dynlib spwd}
%{dynlib _struct}
%{dynlib syslog}
%{dynlib termios}
%{dynlib unicodedata}
%{dynlib zlib}
# hashlib fallback modules
%{dynlib _blake2}
%{dynlib _md5}
%{dynlib _sha1}
%{dynlib _sha256}
%{dynlib _sha512}
%{dynlib _sha3}
# python parts
%dir %{_prefix}/lib/python%{python_version}
%dir %{_prefix}/lib/python%{python_version}/site-packages
%dir %{_prefix}/lib/python%{python_version}/site-packages/__pycache__
%dir %{sitedir}
%dir %{sitedir}/site-packages
%dir %{sitedir}/site-packages/__pycache__
%exclude %{sitedir}/*/test
%exclude %{sitedir}/*/tests
# import-failed hooks
# symlinks
# executables
%attr(755, root, root) %{_bindir}/pydoc%{python_version}
%attr(755, root, root) %{_bindir}/python%{python_abi}
%attr(755, root, root) %{_bindir}/python%{python_version}
%attr(755, root, root) %{_bindir}/pyvenv-%{python_version}