python-psycopg2/python-psycopg2.spec

210 lines
5.9 KiB
RPMSpec
Raw Normal View History

2020-06-20 22:00:40 +08:00
%global selfcheck 0
%define release_version %(echo %{version} | awk -F. '{print $1"_"$2"_"$3}')
2020-02-18 15:57:26 +08:00
%bcond_without python3
2020-06-20 22:00:40 +08:00
%bcond_without python3_debug
%bcond_without python2
%bcond_without python2_debug
%if 0%{?selfcheck}
%bcond_without tests
%else
%bcond_with tests
%endif
Name: python-psycopg2
Version: 2.8.4
Release: 1
Summary: PostgreSQL database adapter for the Python programming language
License: LGPLv3+ with exceptions
URL: http://www.psycopg.org/psycopg/
Source0: https://github.com/psycopg/psycopg2/archive/%{release_version}.tar.gz
2020-02-18 15:57:26 +08:00
%global desc Psycopg is the most popular PostgreSQL adapter for the Python \
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.
2020-06-20 22:00:40 +08:00
%global python_runtimes %{?with_python2:python2 python2-debug} \\\
2020-02-18 15:57:26 +08:00
%{?with_python3:python3 python3-debug}
%{!?with_python2:%{!?with_python3:%{error:one python version eneeded}}}
BuildRequires: gcc,pkgconfig(libpq)
2020-06-20 22:00:40 +08:00
%{?with_python2:BuildRequires: python2-debug python2-devel}
%{?with_python3:BuildRequires: python3-debug python3-devel}
2020-02-18 15:57:26 +08:00
2020-06-20 22:00:40 +08:00
%if %{with tests}
BuildRequires: postgresql-test-rpm-macros
2020-02-18 15:57:26 +08:00
%endif
2020-06-20 22:00:40 +08:00
Conflicts: python-psycopg2-zope < %{version}
2020-02-18 15:57:26 +08:00
%description
%{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}
2020-03-10 14:10:46 +08:00
Requires: python2-psycopg2 = %version-%release
2020-02-18 15:57:26 +08:00
%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)
2020-06-20 22:00:40 +08:00
Requires: %{name} = %{version}-%{release}
2020-02-18 15:57:26 +08:00
%{?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
2020-06-20 22:00:40 +08:00
Summary: %{summary}
2020-02-18 15:57:26 +08:00
%{?python_provide:%python_provide python3-psycopg2}
%description -n python3-psycopg2
%{desc}
%package -n python3-psycopg2-tests
2020-06-20 22:00:40 +08:00
Summary: A testsuite for %{summary}
Requires: python3-psycopg2 = %version-%release
2020-02-18 15:57:26 +08:00
%description -n python3-psycopg2-tests
%desc
This sub-package delivers set of tests for the adapter.
%package -n python3-psycopg2-debug
2020-06-20 22:00:40 +08:00
Summary: A PostgreSQL database adapter for Python 3 (debug build)
Requires: python3-psycopg2 = %{version}-%{release}
2020-02-18 15:57:26 +08:00
%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
2020-06-20 22:00:40 +08:00
Summary: Documentation for psycopg python PostgreSQL database adapter
Requires: %{name} = %{version}-%{release}
2020-02-18 15:57:26 +08:00
%{?with_python2:Provides: python2-psycopg2-doc = %{version}-%{release}}
%{?with_python3:Provides: python3-psycopg2-doc = %{version}-%{release}}
%description doc
Documentation and example files for the psycopg python PostgreSQL
database adapter.
%prep
2020-06-20 22:00:40 +08:00
%autosetup -p1 -n psycopg2-%{release_version}
2020-02-18 15:57:26 +08:00
%build
for python in %{python_runtimes} ; do
$python setup.py build
done
for i in `find doc -iname "*.html"`; do sed -i 's/\r//' $i; done
for i in `find doc -iname "*.css"`; do sed -i 's/\r//' $i; done
rm -f doc/html/.buildinfo
%check
2020-06-20 22:00:40 +08:00
%if %{with tests}
2020-02-18 15:57:26 +08:00
export PGTESTS_LOCALE=C.UTF-8
%postgresql_tests_run
export PSYCOPG2_TESTDB=${PGTESTS_DATABASES##*:}
export PSYCOPG2_TESTDB_HOST=$PGHOST
export PSYCOPG2_TESTDB_PORT=$PGPORT
2020-06-20 22:00:40 +08:00
cmd="import tests; tests.unittest.main(defaultTest='tests.test_suite')"
2020-02-18 15:57:26 +08:00
%if %{with python2}
PYTHONPATH=%buildroot%python2_sitearch %__python2 -c "$cmd" --verbose
%endif
%if %{with python3}
PYTHONPATH=%buildroot%python3_sitearch %__python3 -c "$cmd" --verbose
%endif
2020-06-20 22:00:40 +08:00
%endif
2020-02-18 15:57:26 +08:00
%install
2020-06-20 22:00:40 +08:00
export CFLAGS=${RPM_OPT_FLAGS} LDFLAGS=${RPM_LD_FLAGS}
2020-02-18 15:57:26 +08:00
for python in %{python_runtimes} ; do
$python setup.py install --no-compile --root %{buildroot}
done
2020-06-20 22:00:40 +08:00
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
2020-02-18 15:57:26 +08:00
2020-06-20 22:00:40 +08:00
cp -r tests/ %{buildroot}%{python3_sitearch}/psycopg2/tests/
for i in `find %{buildroot}%{python3_sitearch}/psycopg2/tests/ -iname "*.py"`; do
sed -i 's|#!/usr/bin/env python|#!/usr/bin/python3|' $i
done
2020-02-18 15:57:26 +08:00
%{?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
2020-06-20 22:00:40 +08:00
%endif
2020-02-18 15:57:26 +08:00
%if %{with python3}
%files -n python3-psycopg2
%license LICENSE
%doc AUTHORS NEWS README.rst
%dir %{python3_sitearch}/psycopg2
%{python3_sitearch}/psycopg2/*.py
2020-06-20 22:00:40 +08:00
%{python3_sitearch}/psycopg2/_psycopg.cpython-3?[!d]*.so
2020-02-18 15:57:26 +08:00
%dir %{python3_sitearch}/psycopg2/__pycache__
%{python3_sitearch}/psycopg2/__pycache__/*.py{c,o}
%{python3_sitearch}/psycopg2-%{version}-py3*.egg-info
%files -n python3-psycopg2-tests
%{python3_sitearch}/psycopg2/tests
%files -n python3-psycopg2-debug
%license LICENSE
2020-06-20 22:00:40 +08:00
%{python3_sitearch}/psycopg2/_psycopg.cpython-3?d*.so
%endif
2020-02-18 15:57:26 +08:00
%files doc
%license LICENSE
2020-06-20 22:00:40 +08:00
%doc doc
2020-02-18 15:57:26 +08:00
%changelog
2020-06-20 22:00:40 +08:00
* Sat Jun 20 2020 Jeffery.Gao <gaojianxing@huawei.com> - 2.8.4-1
- Upgrade package & fixed build as root errors
2020-03-10 14:10:46 +08:00
* Tue Mar 10 2020 chenli <chenli147@huawei.com> - 2.7.5-3.2
- Fix python2-psycopg2-tests install error
2020-02-18 15:57:26 +08:00
* Wed Feb 12 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.7.5-3.1
- Package init