zbyszek / rpms / PyGreSQL

Forked from rpms/PyGreSQL 6 years ago
Clone
Blob Blame History Raw
%global sum		A Python client library for PostgreSQL
%global srcname	PyGreSQL

%{!?runselftest:%global runselftest 1}

Name:		%{srcname}
Version:	5.0
Release:	2%{?dist}
Summary:	%{sum}

Group:		Applications/Databases
URL:		http://www.pygresql.org/
# Author states his intention is to dual license under PostgreSQL or Python
# licenses --- this is not too clear from the current tarball documentation,
# but hopefully will be clearer in future releases.
# The PostgreSQL license is very similar to other MIT licenses, but the OSI
# recognizes it as an independent license, so we do as well.
License:	PostgreSQL or Python

Source0:	http://www.pygresql.org/files/PyGreSQL-%{version}.tar.gz

# PyGreSQL was originally shipped as a sub-RPM of the PostgreSQL package;
# these Provides/Obsoletes give a migration path.  Note there is no
# intention of changing the version numbers in future.
Provides:	postgresql-python = 8.5.0-1
Obsoletes:	postgresql-python < 8.5
Provides:	python2-%{name} = %{version}-%{release}
Provides:	python2-%{name}%{?_isa} = %{version}-%{release}
%{?python_provide:%python_provide python2-%{srcname}}

BuildRequires:	postgresql-devel python2-devel python3-devel

# For testsuite
BuildRequires:	postgresql-server

%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}

%description
PostgreSQL is an advanced Object-Relational database management system.
The PyGreSQL package provides a module for developers to use when writing
Python code for accessing a PostgreSQL database.


%package -n python3-%{srcname}
Summary:	%{sum}
%{?python_provide:%python_provide python3-%{srcname}}

%description -n python3-%{srcname}


%prep
%autosetup -n %{srcname}-%{version}

# PyGreSQL releases have execute bits on all files
find -type f -exec chmod 644 {} +


%build
%py2_build
%py3_build


%install
%py2_install
%py3_install


%clean


%files
%license docs/copyright.rst
%doc docs/*.rst
%{python2_sitearch}/*.so
%{python2_sitearch}/*.py
%{python2_sitearch}/*.pyc
%{python2_sitearch}/*.pyo
%{python2_sitearch}/*.egg-info


%files -n python3-%{srcname}
%license docs/copyright.rst
%doc docs/*.rst
%{python3_sitearch}/*.so
%{python3_sitearch}/*.py
%{python3_sitearch}/__pycache__/*.py{c,o}
%{python3_sitearch}/*.egg-info


%check
%if %runselftest == 0
exit 0
%endif
pgdatadir=datadir
pghost=/tmp
pgport=54321
pgdb=unittest

pg_start ()
{
	initdb "$pgdatadir" -U $(id -u -n) \
		--auth-local=peer --auth-host=ident
	pg_ctl -D "$pgdatadir" -l logfile start -o "-k $pghost -p $pgport" -w
}

pg_stop ()
{
	pg_ctl -D "$pgdatadir" stop
}

pg_createdb ()
{
	createdb -h $pghost -p $pgport "$@"
}

pg_start
pg_createdb "$pgdb"
trap pg_stop EXIT

cat > LOCAL_PyGreSQL.py <<EOF
dbname = '$pgdb'
dbhost = '$pghost'
dbport = $pgport
EOF

%{__python2} setup.py test
%{__python3} setup.py test


%changelog
* Mon Mar 21 2016 Pavel Raiskup <praiskup@redhat.com> - 5.0-2
- use %%python_provide macro according to Python packaging guidelines
- allow disabling the testsuite by 'rpmbuild --define "runselftest 0"'

* Mon Mar 21 2016 Pavel Raiskup <praiskup@redhat.com> - 5.0-1
- rebase to 5.0
- provide python2-PyGreSQL and add python3-PyGreSQL
- enable testsuite
- cleanup obsoleted spec statements

* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 4.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Tue Jan 26 2016 Pavel Raiskup <praiskup@redhat.com> - 4.2-1
- rebase (per rhbz#1301241)

* Tue Jun 16 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.1.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Fri Aug 15 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.1.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Fri Jun 06 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.1.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Wed Mar 12 2014 Jozef Mlich <jmlich@redhat.com> - 4.1.1-1
- Rebase to 4.1.1.
  See changelog http://www.pygresql.org/changelog.html
  Resolves: #1071940

* Fri Aug 02 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.0-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Wed Feb 13 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Sat Nov 17 2012 Tom Lane <tgl@redhat.com> 4.0-6
- Update tarball URL in specfile (no actual package change)

* Wed Jul 18 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Thu Jan 12 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Thu Jul  7 2011 Tom Lane <tgl@redhat.com> 4.0-3
- Add upstream patch for set_decimal bug
Resolves: #719093

* Mon Feb 07 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Wed Dec 29 2010 Tom Lane <tgl@redhat.com> 4.0-1
- Update to PyGreSQL 4.0
- Relabel license as PostgreSQL now that that's separately recognized by OSI.

* Wed Jul 21 2010 David Malcolm <dmalcolm@redhat.com> - 3.8.1-3
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild

* Tue Nov 24 2009 Tom Lane <tgl@redhat.com> 3.8.1-2
- Fix License tag and permissions on example scripts under tutorial/,
  per discussion in package review request.
Related: #452321

* Fri Jun 20 2008 Tom Lane <tgl@redhat.com> 3.8.1-1
- Created package by stripping down postgresql specfile and adjusting
  to meet current packaging guidelines for python modules.