[python-pycurl] add python3 subpackage (#985288)

Kamil Dudka kdudka at fedoraproject.org
Thu Aug 8 12:26:56 UTC 2013


commit c73ce635bcc2312c0822f67937301c2811ceb82e
Author: Kamil Dudka <kdudka at redhat.com>
Date:   Thu Aug 8 14:09:15 2013 +0200

    add python3 subpackage (#985288)

 ...n3-use-Py_TYPE-obj-instead-of-obj-ob_type.patch |  101 ++++++++++++++++++++
 python-pycurl.spec                                 |   39 +++++++-
 2 files changed, 138 insertions(+), 2 deletions(-)
---
diff --git a/0003-python3-use-Py_TYPE-obj-instead-of-obj-ob_type.patch b/0003-python3-use-Py_TYPE-obj-instead-of-obj-ob_type.patch
new file mode 100644
index 0000000..3a87b96
--- /dev/null
+++ b/0003-python3-use-Py_TYPE-obj-instead-of-obj-ob_type.patch
@@ -0,0 +1,101 @@
+From 1b2df1bd709c6fffc830bc3d5f5a06ebe2f7c8b5 Mon Sep 17 00:00:00 2001
+From: Kamil Dudka <kdudka at redhat.com>
+Date: Thu, 8 Aug 2013 13:56:50 +0200
+Subject: [PATCH] python3: use Py_TYPE(obj) instead of obj->ob_type
+
+---
+ src/pycurl.c |   22 +++++++++++-----------
+ 1 files changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/src/pycurl.c b/src/pycurl.c
+index 87dac7e..fcd8880 100644
+--- a/src/pycurl.c
++++ b/src/pycurl.c
+@@ -382,7 +382,7 @@ get_thread_state(const CurlObject *self)
+      */
+     if (self == NULL)
+         return NULL;
+-    assert(self->ob_type == p_Curl_Type);
++    assert(Py_TYPE(self) == p_Curl_Type);
+     if (self->state != NULL)
+     {
+         /* inside perform() */
+@@ -412,7 +412,7 @@ get_thread_state_multi(const CurlMultiObject *self)
+      */
+     if (self == NULL)
+         return NULL;
+-    assert(self->ob_type == p_CurlMulti_Type);
++    assert(Py_TYPE(self) == p_CurlMulti_Type);
+     if (self->state != NULL)
+     {
+         /* inside multi_perform() */
+@@ -455,7 +455,7 @@ static void
+ assert_share_state(const CurlShareObject *self)
+ {
+     assert(self != NULL);
+-    assert(self->ob_type == p_CurlShare_Type);
++    assert(Py_TYPE(self) == p_CurlShare_Type);
+ #ifdef WITH_THREAD
+     assert(self->lock != NULL);
+ #endif
+@@ -467,7 +467,7 @@ static void
+ assert_curl_state(const CurlObject *self)
+ {
+     assert(self != NULL);
+-    assert(self->ob_type == p_Curl_Type);
++    assert(Py_TYPE(self) == p_Curl_Type);
+ #ifdef WITH_THREAD
+     (void) get_thread_state(self);
+ #endif
+@@ -479,7 +479,7 @@ static void
+ assert_multi_state(const CurlMultiObject *self)
+ {
+     assert(self != NULL);
+-    assert(self->ob_type == p_CurlMulti_Type);
++    assert(Py_TYPE(self) == p_CurlMulti_Type);
+ #ifdef WITH_THREAD
+     if (self->state != NULL) {
+         assert(self->multi_handle != NULL);
+@@ -1061,7 +1061,7 @@ util_curl_close(CurlObject *self)
+     /* Zero handle and thread-state to disallow any operations to be run
+      * from now on */
+     assert(self != NULL);
+-    assert(self->ob_type == p_Curl_Type);
++    assert(Py_TYPE(self) == p_Curl_Type);
+     handle = self->handle;
+     self->handle = NULL;
+     if (handle == NULL) {
+@@ -2351,7 +2351,7 @@ do_curl_setopt(CurlObject *self, PyObject *args)
+                 return Py_None;
+             }
+         }
+-        if (obj->ob_type != p_CurlShare_Type) {
++        if (Py_TYPE(obj) != p_CurlShare_Type) {
+             PyErr_SetString(PyExc_TypeError, "invalid arguments to setopt");
+             return NULL;
+         }
+@@ -3093,7 +3093,7 @@ do_multi_info_read(CurlMultiObject *self, PyObject *args)
+             Py_DECREF(ok_list);
+             CURLERROR_MSG("Unable to fetch curl handle from curl object");
+         }
+-        assert(co->ob_type == p_Curl_Type);
++        assert(Py_TYPE(co) == p_Curl_Type);
+         if (msg->msg != CURLMSG_DONE) {
+             /* FIXME: what does this mean ??? */
+         }
+@@ -3684,9 +3684,9 @@ initpycurl(void)
+     p_Curl_Type = &Curl_Type;
+     p_CurlMulti_Type = &CurlMulti_Type;
+     p_CurlShare_Type = &CurlShare_Type;
+-    Curl_Type.ob_type = &PyType_Type;
+-    CurlMulti_Type.ob_type = &PyType_Type;
+-    CurlShare_Type.ob_type = &PyType_Type;
++    Py_TYPE(&Curl_Type) = &PyType_Type;
++    Py_TYPE(&CurlMulti_Type) = &PyType_Type;
++    Py_TYPE(&CurlShare_Type) = &PyType_Type;
+ 
+     /* Create the module and add the functions */
+     m = Py_InitModule3("pycurl", curl_methods, module_doc);
+-- 
+1.7.1
+
diff --git a/python-pycurl.spec b/python-pycurl.spec
index 8f16961..207950c 100644
--- a/python-pycurl.spec
+++ b/python-pycurl.spec
@@ -2,7 +2,7 @@
 
 Name:           python-pycurl
 Version:        7.19.0
-Release:        18.20130315git8d654296%{?dist}
+Release:        19.20130315git8d654296%{?dist}
 Summary:        A Python interface to libcurl
 
 Group:          Development/Languages
@@ -17,8 +17,12 @@ Patch0:         0000-pycurl-7.19.7-8d654296.patch
 Patch1:         0001-do_curl_getinfo-fix-misplaced-endif.patch
 Patch2:         0002-runwsgi.py-start-the-server-explicitly-at-127.0.0.1.patch
 
+# for Python3 compatibility
+Patch3:         0003-python3-use-Py_TYPE-obj-instead-of-obj-ob_type.patch
+
 Requires:       keyutils-libs
 BuildRequires:  python-devel
+BuildRequires:  python3-devel
 BuildRequires:  curl-devel >= 7.19.0
 BuildRequires:  openssl-devel
 BuildRequires:  python-bottle
@@ -44,6 +48,15 @@ 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-pycurl
+Summary:        A Python interface to libcurl for Python 3
+
+%description -n python3-pycurl
+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
 %setup0 -q -n pycurl-%{version}
 
@@ -56,6 +69,7 @@ find -type f | xargs sed -i 's/\$Id: [^$]*\$/$Id$/'
 # patches not yet upstream
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
 
 # remove a test specific to OpenSSL-powered libcurl
 rm -f tests/certinfo_test.py
@@ -63,22 +77,43 @@ rm -f tests/certinfo_test.py
 # temporarily disable intermittently failing test-case
 rm -f tests/multi_socket_select_test.py
 
+# copy the whole directory for the python3 build
+cp -a . %{py3dir}
+
 %build
-CFLAGS="$RPM_OPT_FLAGS -DHAVE_CURL_OPENSSL" %{__python} setup.py build
+export CFLAGS="$RPM_OPT_FLAGS -DHAVE_CURL_OPENSSL"
+%{__python} setup.py build
+pushd %{py3dir}
+%{__python3} setup.py build
+popd
 
 %check
 export PYTHONPATH=$RPM_BUILD_ROOT%{python_sitearch}
 make test PYTHON=%{__python}
+pushd %{py3dir}
+export PYTHONPATH=$RPM_BUILD_ROOT%{python3_sitearch}
+make test PYTHON=%{__python3}
+popd
 
 %install
 %{__python} setup.py install -O1 --skip-build --root %{buildroot}
+pushd %{py3dir}
+%{__python3} setup.py install -O1 --skip-build --root %{buildroot}
+popd
 rm -rf %{buildroot}%{_datadir}/doc/pycurl
 
 %files
 %doc COPYING COPYING2 ChangeLog README.rst TODO examples doc tests
 %{python_sitearch}/*
 
+%files -n python3-pycurl
+%doc COPYING COPYING2 ChangeLog README.rst TODO examples doc tests
+%{python3_sitearch}/*
+
 %changelog
+* Thu Aug 08 2013 Kamil Dudka <kdudka at redhat.com> - 7.19.0-19.20130315git8d654296
+- add python3 subpackage (#985288)
+
 * Thu Aug 08 2013 Kamil Dudka <kdudka at redhat.com> - 7.19.0-18.20130315git8d654296
 - sync with upstream 8d654296
 


More information about the scm-commits mailing list