remove python2 dependency

This commit is contained in:
jinzhimin369 2020-10-29 15:03:58 +08:00
parent 7434b6e765
commit 08abc80488

View File

@ -2,8 +2,6 @@
%define release_version %(echo %{version} | awk -F. '{print $1"_"$2"_"$3}')
%bcond_without python3
%bcond_without python3_debug
%bcond_without python2
%bcond_without python2_debug
%if 0%{?selfcheck}
%bcond_without tests
%else
@ -11,7 +9,7 @@
%endif
Name: python-psycopg2
Version: 2.8.4
Release: 1
Release: 2
Summary: PostgreSQL database adapter for the Python programming language
License: LGPLv3+ with exceptions
URL: http://www.psycopg.org/psycopg/
@ -22,14 +20,12 @@ programming language. Its core is a complete implementation of the Python DB \
API 2.0 specifications. Several extensions allow access to many of the \
features offered by PostgreSQL.
%global python_runtimes %{?with_python2:python2 python2-debug} \\\
%{?with_python3:python3 python3-debug}
%global python_runtimes %{?with_python3:python3 python3-debug}
%{!?with_python2:%{!?with_python3:%{error:one python version eneeded}}}
BuildRequires: gcc,pkgconfig(libpq)
%{?with_python2:BuildRequires: python2-debug python2-devel}
%{?with_python3:BuildRequires: python3-debug python3-devel}
%if %{with tests}
@ -41,33 +37,7 @@ Conflicts: python-psycopg2-zope < %{version}
%{desc}
%package -n python2-psycopg2
%{?python_provide:%python_provide python2-psycopg2}
Summary: %{summary}
%description -n python2-psycopg2
%{desc}
%package -n python2-psycopg2-tests
Summary: A testsuite for %{summary}
Requires: python2-psycopg2 = %version-%release
%description -n python2-psycopg2-tests
%desc
This sub-package delivers set of tests for the adapter.
%package -n python2-psycopg2-debug
Summary: A PostgreSQL database adapter for Python 2 (debug build)
Requires: %{name} = %{version}-%{release}
%{?python_provide:%python_provide python2-psycopg2-debug}
%description -n python2-psycopg2-debug
This is a build of the psycopg PostgreSQL database adapter for the debug
build of Python 2.
%if %{with python3}
%package -n python3-psycopg2
Summary: %{summary}
%{?python_provide:%python_provide python3-psycopg2}
@ -91,13 +61,11 @@ Requires: python3-psycopg2 = %{version}-%{release}
%description -n python3-psycopg2-debug
This is a build of the psycopg PostgreSQL database adapter for the debug
build of Python 3.
%endif # python3
%package doc
Summary: Documentation for psycopg python PostgreSQL database adapter
Requires: %{name} = %{version}-%{release}
%{?with_python2:Provides: python2-psycopg2-doc = %{version}-%{release}}
%{?with_python3:Provides: python3-psycopg2-doc = %{version}-%{release}}
%description doc
@ -109,6 +77,7 @@ database adapter.
%build
export CFLAGS=${RPM_OPT_FLAGS} LDFLAGS=${RPM_LD_FLAGS}
for python in %{python_runtimes} ; do
$python setup.py build
done
@ -127,24 +96,14 @@ export PSYCOPG2_TESTDB_HOST=$PGHOST
export PSYCOPG2_TESTDB_PORT=$PGPORT
cmd="import tests; tests.unittest.main(defaultTest='tests.test_suite')"
%if %{with python2}
PYTHONPATH=%buildroot%python2_sitearch %__python2 -c "$cmd" --verbose
%endif
%if %{with python3}
PYTHONPATH=%buildroot%python3_sitearch %__python3 -c "$cmd" --verbose
%endif
%endif
%install
export CFLAGS=${RPM_OPT_FLAGS} LDFLAGS=${RPM_LD_FLAGS}
for python in %{python_runtimes} ; do
$python setup.py install --no-compile --root %{buildroot}
done
cp -r tests/ %{buildroot}%{python2_sitearch}/psycopg2/tests/
for i in `find %{buildroot}%{python2_sitearch}/psycopg2/tests/ -iname "*.py"`; do
sed -i 's|#!/usr/bin/env python|#!/usr/bin/python2|' $i
done
cp -r tests/ %{buildroot}%{python3_sitearch}/psycopg2/tests/
for i in `find %{buildroot}%{python3_sitearch}/psycopg2/tests/ -iname "*.py"`; do
@ -152,29 +111,7 @@ for i in `find %{buildroot}%{python3_sitearch}/psycopg2/tests/ -iname "*.py"`; d
done
%{?with_python3:rm -r %{buildroot}%{python3_sitearch}/psycopg2/tests/test_async_keyword.py}
%if %{with python2}
%files -n python2-psycopg2
%license LICENSE
%doc AUTHORS NEWS README.rst
%dir %{python2_sitearch}/psycopg2
%{python2_sitearch}/psycopg2/*.py
%{python2_sitearch}/psycopg2/*.pyc
%{python2_sitearch}/psycopg2/_psycopg.so
%{python2_sitearch}/psycopg2/*.pyo
%{python2_sitearch}/psycopg2-%{version}-py2*.egg-info
%files -n python2-psycopg2-tests
%{python2_sitearch}/psycopg2/tests
%files -n python2-psycopg2-debug
%license LICENSE
%{python2_sitearch}/psycopg2/_psycopg_d.so
%endif
%if %{with python3}
%files -n python3-psycopg2
%license LICENSE
%doc AUTHORS NEWS README.rst
@ -192,13 +129,15 @@ done
%files -n python3-psycopg2-debug
%license LICENSE
%{python3_sitearch}/psycopg2/_psycopg.cpython-3?d*.so
%endif
%files doc
%license LICENSE
%doc doc
%changelog
* Thu Oct 29 2020 xinghe <xinghe1@huawei.com> - 2.8.4-2
- remove python2 dependency
* Sat Jun 20 2020 Jeffery.Gao <gaojianxing@huawei.com> - 2.8.4-1
- Upgrade package & fixed build as root errors