%define modname pycurl

Name:           python-%{modname}
Version:        7.43.0.2
Release:        1%{?_dist_release}
Summary:        A Python interface to libcurl
Summary(ja):    libcurl の Python インタフェース

Group:          Development/Languages
License:        LGPLv2+
URL:            http://pycurl.sourceforge.net/
Source0:        http://pycurl.sourceforge.net/download/pycurl-%{version}.tar.gz
# fix programming mistakes detected by static analyzers
# upstream pull request: https://github.com/pycurl/pycurl/pull/550
Patch1:         0001-python-pycurl-7.43.0.2-static-analysis.patch

# drop link-time vs. run-time TLS backend check (#1446850)
Patch2:         0002-python-pycurl-7.43.0-tls-backend.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires:  python-devel
BuildRequires:  python-rpm-macros
BuildRequires:  curl-devel >= 7.19.0
BuildRequires:  openssl-devel
BuildRequires:  openldap-devel

# During its initialization, PycURL checks that the actual libcurl version
# is not lower than the one used when PycURL was built.
# Yes, that should be handled by library versioning (which would then get
# automatically reflected by rpm).
# For now, we have to reflect that dependency.
%define libcurl_sed '/^#define LIBCURL_VERSION "/!d;s/"[^"]*$//;s/.*"//;q'
%define curlver_h /usr/include/curl/curlver.h
%define libcurl_ver %(sed %{libcurl_sed} %{curlver_h} 2>/dev/null || echo 0)
Requires:	curl >= %{libcurl_ver}

Provides:       %{modname} = %{version}-%{release}

Vendor: Project Vine
Distribution: Vine Linux

%description
PycURL is a Python interface to libcurl. PycURL can be used to fetch
objects identified by a URL from a Python program, similar to the
urllib Python module. PycURL is mature, very fast, and supports a lot
of features.


%package -n python3-%{modname}
Summary:        A Python3 interface to libcurl
Summary(ja):    libcurl の Python3 インタフェース
BuildRequires:  python3-devel
BuildRequires:  python3-rpm-macros

%description -n python3-%{modname}
PycURL is a Python interface to libcurl. PycURL can be used to fetch
objects identified by a URL from a Python program, similar to the
urllib Python module. PycURL is mature, very fast, and supports a lot
of features.


%prep
%autosetup -n %{modname}-%{version} -p1

# remove binaries packaged by upstream
rm -f tests/fake-curl/libcurl/*.so

# remove a test-case that relies on sftp://web.sourceforge.net being available
rm -f tests/ssh_key_cb_test.py

# remove a test-case that fails in Koji
rm -f tests/seek_cb_test.py

# remove tests depending on the 'flaky' nose plug-in
grep '^import flaky' -r tests | cut -d: -f1 | xargs rm -fv

# drop options that are not supported by nose
sed -e 's/ --show-skipped//' \
    -e 's/ --with-flaky//' \
    -i tests/run.sh

%build
%py_build -- --with-openssl
%py3_build -- --with-openssl

%check
#export PYTHONPATH=$PWD/build/lib*
#%{__python} tests/test_internals.py -q

%install
rm -rf %{buildroot}
export PYCURL_SSL_LIBRARY=openssl
%py_install
%py3_install
rm -rf %{buildroot}%{_datadir}/doc/pycurl


%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%license COPYING-LGPL COPYING-MIT
%doc ChangeLog README.rst examples doc tests
%{python_sitearch}/*

%files -n python3-%{modname}
%defattr(-,root,root,-)
%license COPYING-LGPL COPYING-MIT
%doc ChangeLog README.rst examples doc tests
%{python3_sitearch}/*

%changelog
* Wed Apr 03 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 7.43.0.2-1
- new upstream release.
- added python3 support.

* Sun Jan 12 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 7.19.0-5
- rebuild with VineSeed environment

* Sun Feb 19 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 7.19.0-4
- rebuild with python-2.7.2

* Tue Feb 02 2010 Shu KONNO <owa@bg.wakwak.com> 7.19.0-3
- rebuild with python-2.6

* Sat Aug  8 2009 Shu KONNO <owa@bg.wakwak.com> - 7.19.0-2
- spec in utf-8
- added BR: openldap-devel

* Thu Aug  6 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 7.19.0-1
- initial build for VineSeed

* Sun Jul 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 7.19.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Fri Apr 17 2009 Stepan Kasal <skasal@redhat.com> - 7.19.0-3
- fix typo in the previous change

* Fri Apr 17 2009 Stepan Kasal <skasal@redhat.com> - 7.19.0-2
- add a require to reflect a dependency on libcurl version (#496308)

* Thu Mar  5 2009 Jeffrey C. Ollie <jeff@ocjtech.us> - 7.19.0-1
- Update to 7.19.0

* Thu Feb 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 7.18.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Sat Nov 29 2008 Ignacio Vazquez-Abrams <ivazqueznet+rpm@gmail.com> - 7.18.2-2
- Rebuild for Python 2.6

* Thu Jul  3 2008 Jeffrey C. Ollie <jeff@ocjtech.us> - 7.18.2-1
- Update to 7.18.2
- Thanks to Ville Skytt辰 re-enable the tests and fix a minor problem
  with the setup.py. (Bug # 45400)

* Thu Jun  5 2008 Jeffrey C. Ollie <jeff@ocjtech.us> - 7.18.1-1
- Update to 7.18.1
- Disable tests because it's not testing the built library, it's trying to
  test an installed library.

* Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 7.16.4-3
- Autorebuild for GCC 4.3

* Thu Jan  3 2008 Jeffrey C. Ollie <jeff@ocjtech.us> - 7.16.4-2
- BR openssl-devel

* Wed Aug 29 2007 Jeffrey C. Ollie <jeff@ocjtech.us> - 7.16.4-1
- Update to 7.16.4
- Update license tag.

* Sat Jun  9 2007 Jeffrey C. Ollie <jeff@ocjtech.us> - 7.16.2.1-1
- Update to released version.

* Thu Dec  7 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 7.16.0-0.1.20061207
- Update to a CVS snapshot since development has a newer version of curl than is in FC <= 6

* Thu Dec  7 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 7.15.5.1-4
- Add -DHAVE_CURL_OPENSSL to fix PPC build problem.

* Thu Dec  7 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 7.15.5.1-3
- Don't forget to Provide: pycurl!!!

* Thu Dec  7 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 7.15.5.1-2
- Remove INSTALL from the list of documentation
- Use python_sitearch for all of the files

* Thu Dec  7 2006 Jeffrey C. Ollie <jeff@ocjtech.us> - 7.15.5.1-1
- First version for Fedora Extras
