Split rpmbuild dependencies to separate _rpmb module
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 2 Oct 2009 15:31:32 +0000 (18:31 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 2 Oct 2009 15:31:32 +0000 (18:31 +0300)
- installers and the like dont need the pile of poo called librpmbuild for
  anything, avoid dragging it in needlessly
- import _rpmb into rpm namespace if available but dont complain if
  its not there
- arrange ts.parseSpec() compatibility on python side by dynamically
  importing _rpmb if possible

python/Makefile.am
python/rpm/__init__.py
python/rpm/transaction.py
python/rpmmodule.c
python/rpmts-py.c
python/spec-py.c
python/spec-py.h

index c11e675..2b91392 100644 (file)
@@ -8,12 +8,11 @@ AM_CPPFLAGS += -I$(top_srcdir)/python
 AM_CPPFLAGS += -I$(top_srcdir)/misc
 AM_CPPFLAGS += -I@WITH_PYTHON_INCLUDE@
 
-pkgpyexec_LTLIBRARIES = _rpmmodule.la
+pkgpyexec_LTLIBRARIES = _rpmmodule.la _rpmbmodule.la
 pkgpyexec_DATA = rpm/__init__.py rpm/transaction.py
 
 _rpmmodule_la_LDFLAGS = -module -avoid-version
 _rpmmodule_la_LIBADD = \
-       $(top_builddir)/build/librpmbuild.la \
        $(top_builddir)/lib/librpm.la \
        $(top_builddir)/rpmio/librpmio.la \
        @WITH_PYTHON_LIB@
@@ -28,6 +27,15 @@ _rpmmodule_la_SOURCES = rpmmodule.c rpmsystem-py.h \
        rpmmacro-py.c rpmmacro-py.h \
        rpmtd-py.c rpmtd-py.h \
        rpmte-py.c rpmte-py.h \
-       rpmts-py.c rpmts-py.h \
+       rpmts-py.c rpmts-py.h
+
+_rpmbmodule_la_LDFLAGS = -module -avoid-version
+_rpmbmodule_la_LIBADD = \
+       $(top_builddir)/build/librpmbuild.la \
+       $(top_builddir)/lib/librpm.la \
+       $(top_builddir)/rpmio/librpmio.la \
+       @WITH_PYTHON_LIB@
+
+_rpmbmodule_la_SOURCES = rpmbmodule.c rpmsystem-py.h \
        spec-py.c spec-py.h
 endif
index 4a0c9b6..9faee8e 100644 (file)
@@ -15,6 +15,12 @@ _RPMVSF_NOHEADER = _rpm._RPMVSF_NOHEADER
 _RPMVSF_NOPAYLOAD = _rpm._RPMVSF_NOPAYLOAD
 _RPMVSF_NOSIGNATURES = _rpm._RPMVSF_NOSIGNATURES
 
+# try to import build bits but dont require it
+try:
+    from _rpmb import *
+except ImportError:
+    pass
+
 # backwards compatibility + give the same class both ways
 ts = TransactionSet
 
index 0d24de8..7437413 100644 (file)
@@ -27,3 +27,6 @@ class TransactionSet(_rpm.ts):
     def setProbFilter(self, ignoreSet):
         return _wrapSetGet('_probFilter', ignoreSet)
 
+    def parseSpec(self, specfile):
+        import _rpmb
+        return _rpmb.spec(specfile)
index 3c021ff..98ea627 100644 (file)
@@ -15,7 +15,6 @@
 #include "rpmtd-py.h"
 #include "rpmte-py.h"
 #include "rpmts-py.h"
-#include "spec-py.h"
 
 #include "debug.h"
 
@@ -203,7 +202,6 @@ void init_rpm(void)
     if (PyType_Ready(&rpmtd_Type) < 0) return;
     if (PyType_Ready(&rpmte_Type) < 0) return;
     if (PyType_Ready(&rpmts_Type) < 0) return;
-    if (PyType_Ready(&spec_Type) < 0) return;
 
     m = Py_InitModule3("_rpm", rpmModuleMethods, rpm__doc__);
     if (m == NULL)
@@ -248,9 +246,6 @@ void init_rpm(void)
     Py_INCREF(&rpmts_Type);
     PyModule_AddObject(m, "ts", (PyObject *) &rpmts_Type);
 
-    Py_INCREF(&spec_Type);
-    PyModule_AddObject(m, "spec", (PyObject *) &spec_Type);
-
     addRpmTags(m);
 
 #define REGISTER_ENUM(val) PyModule_AddIntConstant(m, #val, val)
index b69324c..8a5904b 100644 (file)
@@ -13,7 +13,6 @@
 #include "rpmmi-py.h"
 #include "rpmps-py.h"
 #include "rpmte-py.h"
-#include "spec-py.h"
 
 #include "rpmts-py.h"
 
@@ -744,14 +743,6 @@ rpmts_iternext(rpmtsObject * s)
 }
 
 static PyObject *
-spec_Parse(rpmtsObject * s, PyObject * args, PyObject * kwds)
-{
-    DEPRECATED_METHOD("use 'spec = rpm.spec(<specfile>)' instead");
-    /* we could pass in the ts from here but hardly worth the trouble */
-    return PyObject_Call((PyObject *) &spec_Type, args, kwds);
-}
-
-static PyObject *
 rpmts_Match(rpmtsObject * s, PyObject * args, PyObject * kwds)
 {
     PyObject *Key = NULL;
@@ -844,9 +835,6 @@ static struct PyMethodDef rpmts_methods[] = {
        NULL },
  {"getKeys",   (PyCFunction) rpmts_GetKeys,    METH_NOARGS,
        NULL },
- {"parseSpec", (PyCFunction) spec_Parse,       METH_VARARGS|METH_KEYWORDS,
-"ts.parseSpec(\"/path/to/foo.spec\") -> spec\n\
-- Parse a spec file.\n" },
  {"dbMatch",   (PyCFunction) rpmts_Match,      METH_VARARGS|METH_KEYWORDS,
 "ts.dbMatch([TagN, [key, [len]]]) -> mi\n\
 - Create a match iterator for the default transaction rpmdb.\n" },
index c401f23..f9964f7 100644 (file)
@@ -168,7 +168,7 @@ static PyObject *spec_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
                  cookie, anyarch, force) == 0) {
        spec = rpmtsSpec(ts);
     } else {
-        PyErr_SetString(pyrpmError, "can't parse specfile\n");
+        PyErr_SetString(pyrpmbError, "can't parse specfile\n");
     }
     rpmtsFree(ts);
 
index 30c5cd9..b522029 100644 (file)
@@ -7,6 +7,8 @@ typedef struct specObject_s specObject;
 
 extern PyTypeObject spec_Type;
 
+extern PyObject *pyrpmbError;
+
 #define specObject_Check(v)    ((v)->ob_type == &spec_Type)
 
 rpmSpec specFromSpec(specObject * spec);