revert python2 and python3, 2 is option now

This commit is contained in:
Alexander Stefanov 2020-02-09 21:20:48 +00:00
parent 0fbbb00238
commit 68ef283f30

View file

@ -1,23 +1,27 @@
# Python module not linking to libpython
%global _disable_ld_no_undefined 1
%bcond_without python2
%bcond_with check
%define tarname cython %define tarname cython
%define py2dir python2
# Force python3 build - required by new hplip %global optflags %optflags -O3
# % {?build_python3}%{?!build_python3:%bcond_without python3}
%bcond_without python3
Summary: Language for writing C extensions to Python Summary: Language for writing C extensions to Python
Name: python-cython Name: python-cython
License: Apache License
Group: Development/Python
Url: http://www.cython.org
Version: 0.29.14 Version: 0.29.14
Release: 3 Release: 4
Source0: https://github.com/cython/cython/archive/%{version}%{?rctag:%{rctag}}/%{tarname}-%{version}%{?rctag:%{rctag}}.tar.gz License: Python
Source100: %{name}.rpmlintrc Group: Development/Python
BuildRequires: python-devel Url: http://www.cython.org
BuildRequires: dos2unix Source0: https://github.com/cython/cython/archive/%{version}.tar.gz
BuildRequires: python-distribute Source1: %{name}.rpmlintrc
%if %{with python3} BuildRequires: dos2unix
BuildRequires: python3-distribute %if %{with check}
BuildRequires: gdb
BuildRequires: gomp-devel
BuildRequires: python-numpy-devel
%endif %endif
%description %description
@ -25,78 +29,94 @@ Cython is a language that facilitates the writing of C extensions for
the Python language. It is based on Pyrex, but provides more cutting the Python language. It is based on Pyrex, but provides more cutting
edge functionality and optimizations. edge functionality and optimizations.
%if %{with python3}
%package -n python3-cython %package -n python3-cython
Summary: Language for writing C extensions to Python Summary: Language for writing C extensions to Python
Group: Development/Python Group: Development/Python
BuildRequires: python3-devel BuildRequires: pkgconfig(python3)
BuildRequires: python3-setuptools
Provides: python-cython = %{version}-%{release}
%description -n python3-cython %description -n python3-cython
Cython is a language that facilitates the writing of C extensions for Cython is a language that facilitates the writing of C extensions for
the Python language. It is based on Pyrex, but provides more cutting the Python language. It is based on Pyrex, but provides more cutting
edge functionality and optimizations. edge functionality and optimizations.
%if %{with python2}
%package -n python2-cython
Summary: Language for writing C extensions to Python
Group: Development/Python
BuildRequires: pkgconfig(python2)
BuildRequires: python2-setuptools
%description -n python2-cython
Cython is a language that facilitates the writing of C extensions for
the Python language. It is based on Pyrex, but provides more cutting
edge functionality and optimizations.
%endif %endif
%prep %prep
%setup -q -c %autosetup -p1 -n %{tarname}-%{version}
mv %{tarname}-%{version} python2 %if %{with python2}
%if %{with python3} rm -rf %{py2dir}
cp -r python2 python3 mkdir %{py2dir}
%endif tar -xvf %{SOURCE0} -C %{py2dir}
find %{py2dir} -name '*.py' | xargs sed -i '1s|^#!python|#!python2|'
%endif # with_python2
find -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python}|'
%build %build
pushd python2 %setup_compile_flags
python setup.py build CFLAGS="%{optflags}" %{__python3} setup.py build
popd %if %{with python2}
%if %{with python3} cd %{py2dir}/%{tarname}-%{version}
pushd python3 CFLAGS="%{optflags}" %{__python2} setup.py build
python3 setup.py build cd -
popd %endif # with_python2
%endif
%install %install
pushd python2 # Must do the python2 install first because the scripts in /usr/bin are
find -name .*DS_Store* | xargs rm -rf # overwritten with every setup.py install (and we want the python3 version
# to be the default).
PYTHONDONTWRITEBYTECODE= python setup.py install --root %{buildroot} %if %{with python2}
cd %{py2dir}/%{tarname}-%{version}
%{__python2} setup.py install --skip-build --root %{buildroot}
mv %{buildroot}/usr/bin/cython %{buildroot}/usr/bin/cython2 mv %{buildroot}/usr/bin/cython %{buildroot}/usr/bin/cython2
mv %{buildroot}/usr/bin/cygdb %{buildroot}/usr/bin/cygdb2 mv %{buildroot}/usr/bin/cygdb %{buildroot}/usr/bin/cygdb2
mv %{buildroot}/usr/bin/cythonize %{buildroot}/usr/bin/cythonize2 rm -rf %{buildroot}%{python2_sitelib}/setuptools/tests
cd -
pushd Tools
dos2unix cython-mode.el
install -m 755 -d %{buildroot}%{_sysconfdir}/emacs/site-start.d
install -m 644 *.el* %{buildroot}%{_sysconfdir}/emacs/site-start.d
popd
popd
%if %{with python3}
pushd python3
PYTHONDONTWRITEBYTECODE= python3 setup.py install --root %{buildroot}
popd
%endif %endif
#%%check %{__python3} setup.py install -O1 --skip-build --root %{buildroot}
#PYTHONPATH=`pwd`/../build/lib make test clean rm -rf %{buildroot}%{python3_sitelib}/setuptools/tests
rm -rf %{buildroot}/%{python3_sitearch}/__pycache__/
%files %if %{with check}
%{_sysconfdir}/emacs/site-start.d/*.el* %check
%{_bindir}/cython2 python runtests.py
%{_bindir}/cygdb2 %if %{with python2}
%{_bindir}/cythonize2 cd %{py2dir}/%{tarname}-%{version}
%{py_platsitedir}/Cython* python2 setup.py test
%{py_platsitedir}/cython* cd -
%{py_platsitedir}/pyximport* %endif # with_python2
%endif
%if %{with python3}
%files -n python3-cython %files -n python3-cython
%{_bindir}/cython %{_bindir}/cython
%{_bindir}/cygdb
%{_bindir}/cythonize %{_bindir}/cythonize
%{py3_platsitedir}/__pycache__/* %{_bindir}/cygdb
%{py3_platsitedir}/Cython* %{py3_platsitedir}/Cython
%{py3_platsitedir}/Cython-%{version}-*.egg-info
%{py3_platsitedir}/cython* %{py3_platsitedir}/cython*
%{py3_platsitedir}/pyximport* %{py3_platsitedir}/pyximport
%{py3_platsitedir}/__pycache__/*.py?
%if %{with python2}
%files -n python2-cython
%{_bindir}/cython2
%{_bindir}/cygdb2
%{py2_platsitedir}/Cython
%{py2_platsitedir}/Cython-%{version}-*.egg-info
%{py2_platsitedir}/cython*
%{py2_platsitedir}/pyximport
%endif %endif