File opt-python34.spec of Package opt-python34

%define pyversion        3.4.3
%define vmajor           %(echo %{pyversion} | head -c 1)
%define vminor           %(echo %{pyversion} | head -c 3 | tail -c 1)
%define vmicro           %(echo %{pyversion} | head -c 5 | tail -c 1)
%define pyver            %{vmajor}.%{vminor}
%define nver             %{vmajor}%{vminor}
%define _prefix          /opt/python
%define _libdir          %{_prefix}/lib
%define python_sitelib   %{_libdir}/python%{pyver}/site-packages

Name:           opt-python%{nver}
Version:        %{pyversion}
Release:        1
Summary:        Python Interpreter
License:        Python-2.0
Group:          Development/Languages/Python
Url:            http://www.python.org/
Source0:        http://www.python.org/ftp/python/%{version}/Python-%{version}.tar.xz
# Deliberately abstain from applying any patches.  These are test
# versions.  Do not need production quality.  Opt for simplicity
# rather then for fine tuning.
BuildRequires:  db-devel
BuildRequires:  fdupes
BuildRequires:  gdbm-devel
BuildRequires:  gmp-devel
BuildRequires:  libbz2-devel
BuildRequires:  libopenssl-devel
BuildRequires:  ncurses-devel
BuildRequires:  python-base
BuildRequires:  readline-devel
BuildRequires:  sqlite-devel
BuildRequires:  tk-devel
BuildRequires:  xorg-x11-devel
BuildRequires:  xz
Provides:       %{name} = %{pyver}
Requires:       opt-python-libpython3
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
#!BuildIgnore:  post-build-checks

%description
Python is an interpreted, object-oriented programming language, and is
often compared to Tcl, Perl, Scheme, or Java.

This package is installed in /opt/python in such a way that multiple
Python version may live there next to each other.

%package -n opt-python-libpython3
Summary:        Python Interpreter
Requires:       %{name} = %{pyver}

%description -n opt-python-libpython3
Python is an interpreted, object-oriented programming language, and is
often compared to Tcl, Perl, Scheme, or Java.

This package contains a single symbol link to resolve a conflict
between libpython3 versions.  (See http://bugs.python.org/issue17975)


%prep
%setup -q -n Python-%{version}


%build

# Tell the linker to set the rpath in the python executable.
export LD_RUN_PATH=%{_libdir}

./configure \
    --prefix=%{_prefix} \
    --libdir=%{_libdir} \
    --enable-ipv6 \
    --with-fpectl \
    --enable-shared \
    --enable-unicode=ucs4
make

# replace rest of /usr/local/bin/python or /usr/bin/env python* with
# /opt/python/bin/python%{pyver}.
find . -path "./Parser" -prune -o -path "./Python/makeopcodetargets.py" -prune -o -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]+)?)?@#! %{_prefix}/bin/python%{pyver}@'


%install

# Tell the linker to set the rpath in the python executable.
export LD_RUN_PATH=%{_libdir}

make altinstall DESTDIR=%{buildroot}

# See http://bugs.python.org/issue17975
# All Python versions starting with 3.2 install libpython3.so which
# conflicts between versions.  We resort in renaming libpython3.so,
# adding a symlink, and packaging the symlink in a separate package.
# This way one can install all Python packages along with one of the
# symlink packages pointing to the library verions of choice.
mv -f %{buildroot}%{_libdir}/libpython3.so \
      %{buildroot}%{_libdir}/libpython%{pyver}.so
ln -s libpython%{pyver}.so %{buildroot}%{_libdir}/libpython3.so

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


# Deliberately do not include %post scripts to add /opt/python/lib to
# the ld.so.conf and run ldconfig in order to avoid interfering with
# the system Python installation.  Set the rpath in the binaries
# instead, see setting of LD_RUN_PATH above.


%files
%defattr(-, root, root)
%{_prefix}
%exclude %{_libdir}/python%{pyver}/test
%exclude %{_libdir}/libpython3.so

%files -n opt-python-libpython3
%defattr(-, root, root)
%{_libdir}/libpython3.so


%changelog
openSUSE Build Service is sponsored by