File opt-python34.spec of Package opt-python34
%define pyversion 3.4.10
%define pipversion 9.0.1
%define stversion 28.8.0
%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
%global with_pip 0
%global with_setuptools 0
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/%{pyversion}/Python-%{pyversion}.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: gcc-c++
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
BuildRequires: xz-devel
Provides: %{name} = %{pyver}
Requires: opt-python-libpython3
BuildRoot: %{_tmppath}/%{name}-%{pyversion}-build
%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.
%if %{with_pip}
%package pip
Version: %{pipversion}
Summary: The PyPA recommended tool for installing Python packages
License: MIT
Url: https://pip.pypa.io/
Requires: %{name} = %{pyver}
BuildArch: noarch
%description pip
The PyPA recommended tool for installing Python packages.
%endif
%if %{with_setuptools}
%package setuptools
Version: %{stversion}
Summary: Easily download, build, install, upgrade, and uninstall Python packages
License: Python-2.0 or ZPL-2.0
Url: https://bitbucket.org/pypa/setuptools
Requires: %{name} = %{pyver}
BuildArch: noarch
%description setuptools
setuptools is a collection of enhancements to the Python distutils
that allow you to more easily build and distribute Python packages,
especially ones that have dependencies on other packages.
%endif
%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-%{pyversion}
%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
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
# Fix RECORD files in dist-info directories.
sed -i -e 's@%{buildroot}@@' \
%{buildroot}%{python_sitelib}/pip*.dist-info/RECORD \
%{buildroot}%{python_sitelib}/setuptools*.dist-info/RECORD
%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 %{_bindir}/easy_install-%{pyver}
%exclude %{_bindir}/pip%{pyver}
%exclude %{_libdir}/libpython3.so
%exclude %{_libdir}/python%{pyver}/test
%exclude %{python_sitelib}/__pycache__
%exclude %{python_sitelib}/easy_install.py
%exclude %{python_sitelib}/pip*
%exclude %{python_sitelib}/pkg_resources
%exclude %{python_sitelib}/setuptools*
%if %{with_pip}
%files pip
%defattr(-, root, root)
%{_bindir}/pip%{pyver}
%{python_sitelib}/pip*
%endif
%if %{with_setuptools}
%files setuptools
%defattr(-, root, root)
%dir %{python_sitelib}/__pycache__
%{_bindir}/easy_install-%{pyver}
%{python_sitelib}/__pycache__/easy_install*
%{python_sitelib}/easy_install.py
%{python_sitelib}/pkg_resources
%{python_sitelib}/setuptools*
%endif
%files -n opt-python-libpython3
%defattr(-, root, root)
%{_libdir}/libpython3.so
%changelog