[PyPAM] Update PyPAM to 0.5.0-20
Miroslav Suchý
msuchy at fedoraproject.org
Wed Jun 25 08:04:26 UTC 2014
commit 080e64c00da0a810e46b706aee2940b3b3523bc5
Author: Miroslav Suchý <msuchy at redhat.com>
Date: Wed Jun 25 10:04:26 2014 +0200
Update PyPAM to 0.5.0-20
.gitignore | 6 ++
PyPAM-python3-support.patch | 198 +++++++++++++++++++++++++++++++++++++++++++
PyPAM.spec | 62 +++++++++++++-
sources | 6 ++
4 files changed, 268 insertions(+), 4 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 913abc2..f8436d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,7 @@
PyPAM-0.5.0.tar.gz
+/PyPAM-dlopen.patch
+/PyPAM-0.5.0-dealloc.patch
+/PyPAM-0.5.0-nofree.patch
+/PyPAM-0.5.0-memory-errors.patch
+/PyPAM-0.5.0-return-value.patch
+/PyPAM-python3-support.patch
diff --git a/PyPAM-python3-support.patch b/PyPAM-python3-support.patch
new file mode 100644
index 0000000..2aec60e
--- /dev/null
+++ b/PyPAM-python3-support.patch
@@ -0,0 +1,198 @@
+--- PAMmodule.c.python3 2014-06-24 11:29:10.958299393 +0200
++++ PAMmodule.c 2014-06-24 15:20:02.728118493 +0200
+@@ -15,6 +15,14 @@
+ #include <stdio.h>
+ #include <dlfcn.h>
+
++#if PY_MAJOR_VERSION >= 3
++#define IS_PY3K
++#else
++// include bytesobject.h to map PyBytes_* to PyString_*
++#include <bytesobject.h>
++#endif
++
++
+ static PyObject *PyPAM_Error;
+
+ typedef struct {
+@@ -28,7 +36,11 @@
+ void *dlh1, *dlh2;
+ } PyPAMObject;
+
++#ifdef IS_PY3K
++static PyTypeObject PyPAMObject_Type;
++#else
+ staticforward PyTypeObject PyPAMObject_Type;
++#endif
+
+ static void PyPAM_Err(PyPAMObject *self, int result)
+ {
+@@ -139,7 +151,6 @@
+ return NULL;
+ }
+
+- PyPAMObject_Type.ob_type = &PyType_Type;
+ p = (PyPAMObject *) PyObject_NEW(PyPAMObject, &PyPAMObject_Type);
+
+ if (p == NULL)
+@@ -562,35 +573,44 @@
+ PyObject_Del(self);
+ }
+
+-static PyObject * PyPAM_getattr(PyPAMObject *self, char *name)
+-{
+- return Py_FindMethod(PyPAMObject_Methods, (PyObject *) self, name);
+-}
+-
+ static PyObject * PyPAM_repr(PyPAMObject *self)
+ {
+ char buf[1024];
+
+ snprintf(buf, 1024, "<pam object, service=\"%s\", user=\"%s\", conv=%p, pamh=%p>",
+ self->service, self->user, self->conv, self->pamh);
+- return PyString_FromString(buf);
++ return PyBytes_FromString(buf);
+ }
+
+ static PyTypeObject PyPAMObject_Type = {
+- PyObject_HEAD_INIT(0) /* Must fill in type value later */
+- 0,
+- "pam",
+- sizeof(PyPAMObject),
+- 0,
+- (destructor)PyPAM_dealloc, /*tp_dealloc*/
+- 0, /*tp_print*/
+- (getattrfunc)PyPAM_getattr, /*tp_getattr*/
+- 0, /*tp_setattr*/
+- 0, /*tp_compare*/
+- (reprfunc)PyPAM_repr, /*tp_repr*/
+- 0, /*tp_as_number*/
+- 0, /*tp_as_sequence*/
+- 0, /*tp_as_mapping*/
++ PyVarObject_HEAD_INIT(NULL, 0) /* Must fill in type value later */
++ "pam", /* tp_name */
++ sizeof(PyPAMObject), /* tp_basicsize */
++ 0, /* tp_itemsize */
++ (destructor)PyPAM_dealloc, /* tp_dealloc */
++ 0, /* tp_print */
++ 0, /* tp_getattr */
++ 0, /* tp_setattr */
++ 0, /* tp_compare */
++ (reprfunc)PyPAM_repr, /* tp_repr */
++ 0, /* tp_as_number */
++ 0, /* tp_as_sequence */
++ 0, /* tp_as_mapping */
++ 0, /* tp_hash */
++ 0, /* tp_call */
++ 0, /* tp_str */
++ PyObject_GenericGetAttr, /* tp_getattro */
++ 0, /* tp_setattro */
++ 0, /* tp_as_buffer */
++ Py_TPFLAGS_DEFAULT, /* tp_flags */
++ "PyPAM", /* tp_doc */
++ 0, /* tp_traverse */
++ 0, /* tp_clear */
++ 0, /* tp_richcompare */
++ 0, /* tp_weaklistoffset */
++ 0, /* tp_iter */
++ 0, /* tp_iternext */
++ PyPAMObject_Methods, /* tp_methods */
+ };
+
+ static PyMethodDef PyPAM_Methods[] = {
+@@ -607,7 +627,12 @@
+ */
+ static void insint(PyObject *d, char *name, int value)
+ {
+- PyObject* v = PyInt_FromLong((long) value);
++ PyObject* v;
++#ifdef IS_PY3K
++ v = PyLong_FromLong((long) value);
++#else
++ v = PyInt_FromLong((long) value);
++#endif
+
+ if (!v || PyDict_SetItemString(d, name, v))
+ PyErr_Clear();
+@@ -615,19 +640,42 @@
+ Py_XDECREF(v);
+ }
+
++#ifdef IS_PY3K
++static struct PyModuleDef pamdef = {
++ PyModuleDef_HEAD_INIT,
++ "PAM",
++ NULL,
++ -1,
++ PyPAM_Methods,
++ NULL,
++ NULL,
++ NULL,
++ NULL
++};
++
++#define INITERROR return NULL
++PyObject *PyInit_PAM(void)
++
++#else
++#define INITERROR return
+ void initPAM(void)
++#endif
+ {
+ PyObject *m, *d;
+
++#ifdef IS_PY3K
++ m = PyModule_Create(&pamdef);
++#else
+ m = Py_InitModule("PAM", PyPAM_Methods);
++#endif
+ d = PyModule_GetDict(m);
+
+ PyPAM_Error = PyErr_NewException("PAM.error", NULL, NULL);
+ if (PyPAM_Error == NULL)
+- return;
++ INITERROR;
+ PyDict_SetItemString(d, "error", PyPAM_Error);
+
+- PyPAMObject_Type.ob_type = &PyType_Type;
++ Py_TYPE(&PyPAMObject_Type) = &PyType_Type;
+ PyPAMObject_Type.tp_doc = PyPAMObject_doc;
+ Py_INCREF(&PyPAMObject_Type);
+
+@@ -692,4 +740,7 @@
+ insint(d, "PAM_BINARY_PROMPT", PAM_BINARY_PROMPT);
+ #endif
+
++#ifdef IS_PY3K
++ return m;
++#endif
+ }
+--- setup.py.python3 2014-06-24 15:58:07.792172439 +0200
++++ setup.py 2014-06-24 15:58:13.714909021 +0200
+@@ -12,7 +12,7 @@
+ license='LGPL',
+ ext_modules=[
+ Extension(
+- 'PAMmodule',
++ 'PAM',
+ ['PAMmodule.c'],
+ libraries=['pam', 'pam_misc'],
+ extra_compile_args = ['-std=c99'],
+--- tests/PamTest.py.python3 2014-06-24 16:54:28.902998249 +0200
++++ tests/PamTest.py 2014-06-24 17:07:11.392094775 +0200
+@@ -41,13 +41,13 @@
+ def test_userdata_default(self):
+ """The default value for userdata is None."""
+
+- self.failUnless(self.pam.get_userdata() is None)
++ self.assertTrue(self.pam.get_userdata() is None)
+
+ def test_userdata(self):
+ """The userdata getter and setter will store and return any data."""
+
+ self.pam.set_userdata(1)
+- self.failUnless(self.pam.get_userdata() == 1)
++ self.assertTrue(self.pam.get_userdata() == 1)
+
+ def test_start(self):
+ """pam.start() works as expected."""
diff --git a/PyPAM.spec b/PyPAM.spec
index 1edec8c..6b0beaa 100644
--- a/PyPAM.spec
+++ b/PyPAM.spec
@@ -3,10 +3,14 @@
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif
+%if 0%{?fedora}
+%global with_python3 1
+%endif
+
Summary: PAM bindings for Python
Name: PyPAM
Version: 0.5.0
-Release: 19%{?dist}
+Release: 20%{?dist}
# Note that the upstream site is dead.
Source0: http://www.pangalactic.org/PyPAM/%{name}-%{version}.tar.gz
Url: http://www.pangalactic.org/PyPAM
@@ -15,17 +19,28 @@ Patch1: PyPAM-0.5.0-dealloc.patch
Patch2: PyPAM-0.5.0-nofree.patch
Patch3: PyPAM-0.5.0-memory-errors.patch
Patch4: PyPAM-0.5.0-return-value.patch
+Patch5: PyPAM-python3-support.patch
License: LGPLv2
Group: Development/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: python2-devel pam-devel
Requires: python
-%filter_provides_in %{python_sitearch}/PAMmodule.so$
+%filter_provides_in %{python_sitearch}/PAM.so$
+%filter_provides_in %{python3_sitearch}/PAM*.so$
%filter_setup
%description
PAM (Pluggable Authentication Module) bindings for Python.
+%if 0%{?with_python3}
+%package -n python3-PyPAM
+Summary: PAM bindings for Python 3
+BuildRequires: python3-devel
+
+%description -n python3-PyPAM
+PAM (Pluggable Authentication Module) bindings for Python 3.
+%endif
+
%prep
%setup -q
%patch0 -p1 -b .dlopen
@@ -33,15 +48,34 @@ PAM (Pluggable Authentication Module) bindings for Python.
%patch2 -p1 -b .nofree
%patch3 -p1 -b .memory
%patch4 -p1 -b .retval
+%patch5 -p0 -b .python3
# remove prebuild rpm and others binaries
rm -rf build dist
+%if 0%{with_python3}
+rm -rf %{py3dir}
+cp -a . %{py3dir}
+%endif
+
%build
CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" %{__python} setup.py build
+%if 0%{with_python3}
+pushd %{py3dir}
+CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" %{__python3} setup.py build
+popd
+%endif
+
%install
rm -rf $RPM_BUILD_ROOT
%{__python} setup.py install --root=$RPM_BUILD_ROOT
+
+%if 0%{?with_python3}
+pushd %{py3dir}
+%{__python3} setup.py install --root=$RPM_BUILD_ROOT
+popd
+%endif
+
# Make sure we don't include binary files in the docs
chmod 644 examples/pamtest.py
rm -f examples/pamexample
@@ -49,14 +83,34 @@ rm -f examples/pamexample
%clean
rm -rf $RPM_BUILD_ROOT
+%check
+PYTHONPATH=build/lib.linux-`uname -m`-%{python_version}/ %{__python} tests/PamTest.py
+
+%if 0%{with_python3}
+pushd %{py3dir}
+PYTHONPATH=build/lib.linux-`uname -m`-%{python3_version}/ %{__python3} tests/PamTest.py
+popd
+%endif
+
%files
%defattr(-, root, root, -)
-%{python_sitearch}/PAMmodule.so
+%{python_sitearch}/PAM.so
%{python_sitearch}/*.egg-info
%doc AUTHORS NEWS README ChangeLog COPYING INSTALL
-%doc examples
+%doc examples
+
+%if 0%{?with_python3}
+%files -n python3-PyPAM
+%{python3_sitearch}/PAM*.so
+%{python3_sitearch}/*.egg-info
+%doc AUTHORS NEWS README ChangeLog COPYING INSTALL
+%doc examples
+%endif
%changelog
+* Tue Jun 24 2014 Bohuslav Kabrda <bkabrda at redhat.com> - 0.5.0-20
+- Add Python 3 support.
+
* Fri Jun 06 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.5.0-19
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
diff --git a/sources b/sources
index afb68ef..9469649 100644
--- a/sources
+++ b/sources
@@ -1 +1,7 @@
f1e7c2c56421dda28a75ace59a3c8871 PyPAM-0.5.0.tar.gz
+130871140cd1329541cacf4161c23654 PyPAM-dlopen.patch
+1c893c85d63378bb05d8cd07bffc97e7 PyPAM-0.5.0-dealloc.patch
+0663d74895ca602bf184e1898a34116d PyPAM-0.5.0-nofree.patch
+9ee809416aa3ab00655043f01cd3522f PyPAM-0.5.0-memory-errors.patch
+6a7ea0a074f5b51598da4ee3bbbb95ee PyPAM-0.5.0-return-value.patch
+12770569aa89f5af492b2b4a28af331e PyPAM-python3-support.patch
More information about the scm-commits
mailing list