From 6c3e74bdf3a8bd6aced0a2ddb38c1cc7b22ec655 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 13 Apr 2009 18:19:41 +0200 Subject: * doc/source/conf.py: Do not require python-debian anymore Try to get the release from the information in the environment variable DEBVER, which is exported in debian/rules. If it is not set, use python-debian to read the release from the changelog. --- debian/control | 1 - 1 file changed, 1 deletion(-) (limited to 'debian/control') diff --git a/debian/control b/debian/control index 4c7b542f..72476c58 100644 --- a/debian/control +++ b/debian/control @@ -12,7 +12,6 @@ Build-Depends: apt-utils, python-all-dbg, python-all-dev, python-central (>= 0.5), - python-debian, python-distutils-extra (>= 1.9.0), python-gtk2, python-sphinx (>= 0.5), -- cgit v1.2.3 From c876c5095673a2f1c0f2c0eef6eadef2ce200e19 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Apr 2009 16:19:12 +0200 Subject: * Introduce support for Python 3 (Closes: #523645) This is the first initial port to Python 3. The API is almost completely identical to the one found in Python 2, except that functions working with binary data require bytes (md5sum,sha1sum,sha256sum,Base64Encode). Using setup3.py to install the modules will not work, because the apt package still has to be converted to Python 3. For the package, we call 2to3-3.1 in debian/rules to do this automatically. --- apt/package.py | 6 +++- debian/changelog | 2 ++ debian/control | 2 ++ debian/rules | 26 +++++++++++++-- po/python-apt.pot | 10 +++--- python/acquire.cc | 6 ++++ python/apt_instmodule.cc | 35 ++++++++++++++++++- python/apt_pkgmodule.cc | 87 +++++++++++++++++++++++++++++++++++------------- python/cache.cc | 18 ++++++++++ python/cdrom.cc | 2 ++ python/configuration.cc | 6 ++++ python/depcache.cc | 6 ++++ python/generic.h | 25 ++++++++++++++ python/indexfile.cc | 2 ++ python/metaindex.cc | 2 ++ python/pkgmanager.cc | 2 ++ python/pkgrecords.cc | 2 ++ python/pkgsrcrecords.cc | 2 ++ python/sourcelist.cc | 2 ++ python/string.cc | 16 ++++++++- python/tag.cc | 4 +++ setup3.py | 77 ++++++++++++++++++++++++++++++++++++++++++ 22 files changed, 307 insertions(+), 33 deletions(-) create mode 100644 setup3.py (limited to 'debian/control') diff --git a/apt/package.py b/apt/package.py index 3ea1105d..f12f5559 100644 --- a/apt/package.py +++ b/apt/package.py @@ -272,8 +272,12 @@ class Version(object): """ self.summary # This does the lookup for us. desc = '' + + dsc = self.package._pcache._records.LongDesc try: - dsc = unicode(self.package._pcache._records.LongDesc, "utf-8") + if not isinstance(dsc, unicode): + # Only convert where needed (i.e. Python 2.X) + dsc = unicode(dsc, "utf-8") except UnicodeDecodeError, err: return _("Invalid unicode in description for '%s' (%s). " "Please report.") % (self.package.name, err) diff --git a/debian/changelog b/debian/changelog index 6cbdaac7..a9518d7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,7 @@ python-apt (0.7.11) UNRELEASED; urgency=low + * Introduce support for Python 3 (Closes: #523645) + * Support the 'in' operator (e.g. "k in d") in Configuration{,Ptr,Sub} objects (e.g. apt_pkg.Config) and in TagSections (apt_pkg.ParseSection()) * Replace support for file objects with a more generic support for any object diff --git a/debian/control b/debian/control index 72476c58..08ee329f 100644 --- a/debian/control +++ b/debian/control @@ -11,6 +11,8 @@ Build-Depends: apt-utils, libapt-pkg-dev (>= 0.7.10), python-all-dbg, python-all-dev, + python3.1-dev, + python3.1-dbg, python-central (>= 0.5), python-distutils-extra (>= 1.9.0), python-gtk2, diff --git a/debian/rules b/debian/rules index 6d709ecd..7de945f2 100755 --- a/debian/rules +++ b/debian/rules @@ -11,22 +11,44 @@ DEB_PYTHON_PACKAGES_EXCLUDE=python-apt-dbg include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk +PY3K = y PKG=python-apt DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') DEB_COMPRESS_EXCLUDE:=.html .js _static/* _sources/* _sources/*/* .inv DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS) export DEBVER + +ifeq ($(PY3K),y) +build/python-apt:: + python3.1 setup3.py build + +install/python-apt:: + python3.1 ./setup3.py install --root $(CURDIR)/debian/python-apt \ + --install-layout=deb --no-compile + + find $(CURDIR)/debian/python-apt/usr/lib/python3.1/dist-packages/ -name '*.py' \ + | xargs 2to3-3.1 | patch -p0 +endif + build/python-apt-dbg:: set -e; \ for i in $(cdbs_python_build_versions); do \ python$$i-dbg ./setup.py build; \ done + ifeq($(PY3K),y) + python3.1-dbg ./setup3.py build + endif install/python-apt-dbg:: for i in $(cdbs_python_build_versions); do \ - python$$i-dbg ./setup.py install --root $(CURDIR)/debian/python-apt-dbg; \ + python$$i-dbg ./setup.py install --root $(CURDIR)/debian/python-apt-dbg \ + --no-compile; \ done + ifeq($(PY3K),y) + python3.1-dbg ./setup3.py install --root $(CURDIR)/debian/python-apt-dbg \ + --install-layout=deb --no-compile + endif find debian/python-apt-dbg \ ! -type d ! -name '*_d.so' | xargs rm -f find debian/python-apt-dbg -depth -empty -exec rmdir {} \; @@ -39,4 +61,4 @@ binary-predeb/python-apt-dbg:: ln -s python-apt debian/python-apt-dbg/usr/share/doc/python-apt-dbg clean:: - rm -rf build/lib* build/temp* + rm -rf build/lib* build/temp* build diff --git a/po/python-apt.pot b/po/python-apt.pot index 9c23c579..d12ae967 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-04-12 19:07+0200\n" +"POT-Creation-Date: 2009-04-15 16:10+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -354,16 +354,16 @@ msgstr "" msgid "Complete" msgstr "" -#: ../apt/package.py:278 +#: ../apt/package.py:282 #, python-format msgid "Invalid unicode in description for '%s' (%s). Please report." msgstr "" -#: ../apt/package.py:745 ../apt/package.py:849 +#: ../apt/package.py:830 ../apt/package.py:934 msgid "The list of changes is not available" msgstr "" -#: ../apt/package.py:853 +#: ../apt/package.py:938 #, python-format msgid "" "The list of changes is not available yet.\n" @@ -372,7 +372,7 @@ msgid "" "until the changes become available or try again later." msgstr "" -#: ../apt/package.py:859 +#: ../apt/package.py:944 msgid "" "Failed to download the list of changes. \n" "Please check your Internet connection." diff --git a/python/acquire.cc b/python/acquire.cc index d39ee495..053753cd 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -72,7 +72,9 @@ static PyObject *AcquireItemRepr(PyObject *Self) PyTypeObject AcquireItemType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgAcquire::ItemIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -175,7 +177,9 @@ static PyGetSetDef PkgAcquireGetSet[] = { PyTypeObject PkgAcquireType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "Acquire", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -234,7 +238,9 @@ PyObject *GetAcquire(PyObject *Self,PyObject *Args) PyTypeObject PkgAcquireFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgAcquireFile", // tp_name sizeof(CppPyObject),// tp_basicsize 0, // tp_itemsize diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index a9d81be4..09e3937e 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -162,8 +162,41 @@ static PyMethodDef methods[] = {} }; +#if PY_MAJOR_VERSION >= 3 +struct module_state { + PyObject *error; +}; +#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) + +static int apt_inst_traverse(PyObject *m, visitproc visit, void *arg) { + Py_VISIT(GETSTATE(m)->error); + return 0; +} + +static int apt_inst_clear(PyObject *m) { + Py_CLEAR(GETSTATE(m)->error); + return 0; +} + +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "apt_inst", + NULL, + sizeof(struct module_state), + methods, + NULL, + apt_inst_traverse, + apt_inst_clear, + NULL +}; + +extern "C" PyObject * PyInit_apt_inst() +{ + return PyModule_Create(&moduledef); +} +#else extern "C" void initapt_inst() { Py_InitModule("apt_inst",methods); } - /*}}}*/ +#endif /*}}}*/ diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index fe6a739e..e71d8ee6 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -173,12 +173,12 @@ static PyObject *md5sum(PyObject *Self,PyObject *Args) return 0; // Digest of a string. - if (PyString_Check(Obj) != 0) + if (PyBytes_Check(Obj) != 0) { char *s; Py_ssize_t len; MD5Summation Sum; - PyString_AsStringAndSize(Obj, &s, &len); + PyBytes_AsStringAndSize(Obj, &s, &len); Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } @@ -213,12 +213,12 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args) return 0; // Digest of a string. - if (PyString_Check(Obj) != 0) + if (PyBytes_Check(Obj) != 0) { char *s; Py_ssize_t len; SHA1Summation Sum; - PyString_AsStringAndSize(Obj, &s, &len); + PyBytes_AsStringAndSize(Obj, &s, &len); Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } @@ -253,12 +253,12 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args) return 0; // Digest of a string. - if (PyString_Check(Obj) != 0) + if (PyBytes_Check(Obj) != 0) { char *s; Py_ssize_t len; SHA256Summation Sum; - PyString_AsStringAndSize(Obj, &s, &len); + PyBytes_AsStringAndSize(Obj, &s, &len); Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } @@ -470,30 +470,68 @@ static void AddInt(PyObject *Dict,const char *Itm,unsigned long I) Py_DECREF(Obj); } +#if PY_MAJOR_VERSION >= 3 +struct module_state { + PyObject *error; +}; + +#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) + +static int apt_inst_traverse(PyObject *m, visitproc visit, void *arg) { + Py_VISIT(GETSTATE(m)->error); + return 0; +} + +static int apt_inst_clear(PyObject *m) { + Py_CLEAR(GETSTATE(m)->error); + return 0; +} + +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "apt_inst", + NULL, + sizeof(struct module_state), + methods, + NULL, + apt_inst_traverse, + apt_inst_clear, + NULL +}; + +#define INIT_ERROR return 0 +extern "C" PyObject * PyInit_apt_pkg() +#else +#define INIT_ERROR return extern "C" void initapt_pkg() +#endif { // Finalize our types to add slots, etc. - if (PyType_Ready(&TagSecType) == -1) return; - if (PyType_Ready(&TagFileType) == -1) return; - if (PyType_Ready(&ConfigurationType) == -1) return; - if (PyType_Ready(&ConfigurationPtrType) == -1) return; - if (PyType_Ready(&ConfigurationSubType) == -1) return; - if (PyType_Ready(&PkgCdromType) == -1) return; - if (PyType_Ready(&PkgProblemResolverType) == -1) return; - if (PyType_Ready(&PkgActionGroupType) == -1) return; - if (PyType_Ready(&PkgSourceListType) == -1) return; - if (PyType_Ready(&PkgCacheType) == -1) return; - if (PyType_Ready(&DependencyType) == -1) return; - if (PyType_Ready(&PkgDepCacheType) == -1) return; - if (PyType_Ready(&PkgAcquireType) == -1) return; - if (PyType_Ready(&PackageIndexFileType) == -1) return; - if (PyType_Ready(&PkgManagerType) == -1) return; - if (PyType_Ready(&PkgSrcRecordsType) == -1) return; - if (PyType_Ready(&PkgRecordsType) == -1) return; + if (PyType_Ready(&TagSecType) == -1) INIT_ERROR; + if (PyType_Ready(&TagFileType) == -1) INIT_ERROR; + if (PyType_Ready(&ConfigurationType) == -1) INIT_ERROR; + if (PyType_Ready(&ConfigurationPtrType) == -1) INIT_ERROR; + if (PyType_Ready(&ConfigurationSubType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgCdromType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgProblemResolverType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgActionGroupType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgSourceListType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgCacheType) == -1) INIT_ERROR; + if (PyType_Ready(&DependencyType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgDepCacheType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgAcquireType) == -1) INIT_ERROR; + if (PyType_Ready(&PackageIndexFileType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgManagerType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgSrcRecordsType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgRecordsType) == -1) INIT_ERROR; // Initialize the module + #if PY_MAJOR_VERSION >= 3 + PyObject *Module = PyModule_Create(&moduledef); + #else PyObject *Module = Py_InitModule("apt_pkg",methods); + #endif PyObject *Dict = PyModule_GetDict(Module); // Global variable linked to the global configuration class @@ -549,6 +587,9 @@ extern "C" void initapt_pkg() AddInt(Dict,"InstStateReInstReq",pkgCache::State::ReInstReq); AddInt(Dict,"InstStateHold",pkgCache::State::Hold); AddInt(Dict,"InstStateHoldReInstReq",pkgCache::State::HoldReInstReq); + #if PY_MAJOR_VERSION >= 3 + return Module; + #endif } /*}}}*/ diff --git a/python/cache.cc b/python/cache.cc index 2d8b8db7..957681ba 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -239,7 +239,9 @@ static PyMappingMethods CacheMap = {0,CacheMapOp,0}; PyTypeObject PkgCacheType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -277,7 +279,9 @@ PyTypeObject PkgCacheType = PyTypeObject PkgCacheFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCacheFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -345,7 +349,9 @@ static PySequenceMethods PkgListSeq = PyTypeObject PkgListType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::PkgIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -435,7 +441,9 @@ static PyObject *PackageRepr(PyObject *Self) PyTypeObject PackageType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::Package", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -498,7 +506,9 @@ static PyObject *DescriptionRepr(PyObject *Self) PyTypeObject DescriptionType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::DescIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -684,7 +694,9 @@ static PyObject *VersionRepr(PyObject *Self) PyTypeObject VersionType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::VerIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -759,7 +771,9 @@ static PyObject *PackageFileRepr(PyObject *Self) PyTypeObject PackageFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::PkgFileIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -905,7 +919,9 @@ static PyGetSetDef DependencyGetSet[] = { PyTypeObject DependencyType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::DepIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -991,7 +1007,9 @@ static PySequenceMethods RDepListSeq = PyTypeObject RDepListType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::DepIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/cdrom.cc b/python/cdrom.cc index 0816d93e..b3a38438 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -67,7 +67,9 @@ static PyMethodDef PkgCdromMethods[] = PyTypeObject PkgCdromType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "Cdrom", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/configuration.cc b/python/configuration.cc index b4adf357..eaac48ec 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -481,7 +481,9 @@ static PyMappingMethods ConfigurationMap = {0,CnfMap,CnfMapSet}; PyTypeObject ConfigurationType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "Configuration", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -515,7 +517,9 @@ PyTypeObject ConfigurationType = PyTypeObject ConfigurationPtrType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "ConfigurationPtr", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -549,7 +553,9 @@ PyTypeObject ConfigurationPtrType = PyTypeObject ConfigurationSubType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "ConfigurationSub", // tp_name sizeof(SubConfiguration), // tp_basicsize 0, // tp_itemsize diff --git a/python/depcache.cc b/python/depcache.cc index ade3d4f5..1c9eeff7 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -594,7 +594,9 @@ static PyGetSetDef PkgDepCacheGetSet[] = { PyTypeObject PkgDepCacheType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgDepCache", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -773,7 +775,9 @@ static PyMethodDef PkgProblemResolverMethods[] = PyTypeObject PkgProblemResolverType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgProblemResolver", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -829,7 +833,9 @@ static PyMethodDef PkgActionGroupMethods[] = PyTypeObject PkgActionGroupType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgActionGroup", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/generic.h b/python/generic.h index ce79a54c..6e66d24c 100644 --- a/python/generic.h +++ b/python/generic.h @@ -35,6 +35,31 @@ typedef int Py_ssize_t; #endif +/* Define compatibility for Python 3. + * + * We will use the names PyString_* to refer to the default string type + * of the current Python version (PyString on 2.X, PyUnicode on 3.X). + * + * When we really need unicode strings, we will use PyUnicode_* directly, as + * long as it exists in Python 2 and Python 3. + * + * When we want bytes in Python 3, we use PyBytes*_ instead of PyString_* and + * define aliases from PyBytes_* to PyString_* for Python 2. + */ + +#if PY_MAJOR_VERSION >= 3 +#define PyString_Check PyUnicode_Check +#define PyString_FromString PyUnicode_FromString +#define PyString_FromStringAndSize PyUnicode_FromStringAndSize +#define PyString_AsString(op) PyBytes_AsString(PyUnicode_AsUTF8String(op)) +#define PyInt_Check PyLong_Check +#define PyInt_AsLong PyLong_AsLong +#else +#define PyBytes_Check PyString_Check +#define PyBytes_AsString PyString_AsString +#define PyBytes_AsStringAndSize PyString_AsStringAndSize +#endif + template struct CppPyObject : public PyObject { // We are only using CppPyObject and friends as dumb structs only, ie the diff --git a/python/indexfile.cc b/python/indexfile.cc index dc55634f..bb40cdd0 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -81,7 +81,9 @@ static PyGetSetDef PackageIndexFileGetSet[] = { PyTypeObject PackageIndexFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgIndexFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/metaindex.cc b/python/metaindex.cc index efbc38af..cbaeafbd 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -59,7 +59,9 @@ static PyObject *MetaIndexRepr(PyObject *Self) PyTypeObject MetaIndexType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "metaIndex", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 52f86228..8f56cddc 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -95,7 +95,9 @@ static PyGetSetDef PkgManagerGetSet[] = { PyTypeObject PkgManagerType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "PackageManager", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 577aaf1c..978de6b7 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -135,7 +135,9 @@ static PyGetSetDef PkgRecordsGetSet[] = { PyTypeObject PkgRecordsType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgRecords", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index c830f8d2..97667d7a 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -183,7 +183,9 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = { PyTypeObject PkgSrcRecordsType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgSrcRecords", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 9f8f8878..48b3b7c8 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -100,7 +100,9 @@ static PyGetSetDef PkgSourceListGetSet[] = { PyTypeObject PkgSourceListType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgSourceList", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/string.cc b/python/string.cc index 8168ea5b..b95ee3eb 100644 --- a/python/string.cc +++ b/python/string.cc @@ -38,7 +38,21 @@ PyObject *Python(PyObject *Self,PyObject *Args) \ } MkStr(StrDeQuote,DeQuoteString); -MkStr(StrBase64Encode,Base64Encode); + +/* + * Input bytes(Py3k)/str(Py2), output str. + */ +PyObject *StrBase64Encode(PyObject *Self,PyObject *Args) { + char *Str = 0; + #if PY_MAJOR_VERSION >= 3 + if (PyArg_ParseTuple(Args,"y",&Str) == 0) + #else + if (PyArg_ParseTuple(Args,"s",&Str) == 0) + #endif + return 0; + return CppPyString(Base64Encode(Str)); +} + MkStr(StrURItoFileName,URItoFileName); //MkFloat(StrSizeToStr,SizeToStr); diff --git a/python/tag.cc b/python/tag.cc index cdea3e03..18d08580 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -384,7 +384,9 @@ PyMappingMethods TagSecMapMeth = {TagSecLength,TagSecMap,0}; PyTypeObject TagSecType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "TagSection", // tp_name sizeof(TagSecData), // tp_basicsize 0, // tp_itemsize @@ -442,7 +444,9 @@ static PyGetSetDef TagFileGetSet[] = { PyTypeObject TagFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "TagFile", // tp_name sizeof(TagFileData), // tp_basicsize 0, // tp_itemsize diff --git a/setup3.py b/setup3.py new file mode 100644 index 00000000..a3cbdc8e --- /dev/null +++ b/setup3.py @@ -0,0 +1,77 @@ +#! /usr/bin/env python3 +# $Id: setup.py,v 1.2 2002/01/08 07:13:21 jgg Exp $ +import glob +import os +import shutil +import sys + +from distutils.core import setup, Extension +from distutils.sysconfig import parse_makefile +#from DistUtilsExtra.command import build_extra, build_i18n + + +# The apt_pkg module +files = ["python/"+source for source in parse_makefile("python/makefile")["APT_PKG_SRC"].split()] +apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) + +# The apt_inst module +files = ["python/"+source for source in parse_makefile("python/makefile")["APT_INST_SRC"].split()] +apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) + +# Replace the leading _ that is used in the templates for translation +templates = [] + +# build doc +if len(sys.argv) > 1 and sys.argv[1] == "build": + if not os.path.exists("build/data/templates/"): + os.makedirs("build/data/templates") + for template in glob.glob('data/templates/*.info.in'): + source = open(template, "r") + build = open(os.path.join("build", template[:-3]), "w") + lines = source.readlines() + for line in lines: + build.write(line.lstrip("_")) + source.close() + build.close() + + +if len(sys.argv) > 1 and sys.argv[1] == "clean" and '-a' in sys.argv: + for dirname in "build/doc", "doc/build", "build/data", "build/mo": + if os.path.exists(dirname): + print("Removing", dirname) + shutil.rmtree(dirname) + else: + print("Not removing", dirname, "because it does not exist") + +setup(name="python-apt", + description="Python bindings for APT", + version=os.environ.get('DEBVER'), + author="APT Development Team", + author_email="deity@lists.debian.org", + ext_modules=[apt_pkg, apt_inst], + packages=['apt', 'apt.progress', 'aptsources'], + data_files = [('share/python-apt/templates', + glob.glob('build/data/templates/*.info')), + ('share/python-apt/templates', + glob.glob('data/templates/*.mirrors'))], +# cmdclass = {"build": build_extra.build_extra, +# "build_i18n": build_i18n.build_i18n}, + license = 'GNU GPL', + platforms = 'posix') + +if len(sys.argv) > 1 and sys.argv[1] == "build": + try: + import sphinx + except ImportError: + print(('W: Sphinx not available - Not building' + 'documentation'), file=sys.stderr) + try: + import pygtk + except ImportError: + print(('W: Not building documentation because python-' + 'gtk2 is not available at the moment.'), file=sys.stderr) + sys.exit(0) + sphinx.main(["sphinx", "-b", "html", "-d", "build/doc/doctrees", + os.path.abspath("doc/source"), "build/doc/html"]) + sphinx.main(["sphinx", "-b", "text", "-d", "build/doc/doctrees", + os.path.abspath("doc/source"), "build/doc/text"]) -- cgit v1.2.3 From 337c885e7dd531858c35b256d974989bac6463df Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 16 Apr 2009 20:06:14 +0200 Subject: * apt/*.py: Initial rename work for Bug#481061 A new module, apt.deprecation, is introduced containing functions and classes which assist in the deprecation. The apt_pkg extension gets a new attribute, _COMPAT_0_7 which can be set by defining COMPAT_0_7 at compile time (-DCOMPAT_0_7). The names are changed, and compatibility functions are enabled if bool(apt_pkg._COMPAT_0_7) == True, i.e. if the package has been built with backward compatibility fixes. This commit changes the apt and aptsources packages, the apt_pkg and apt_inst extensions will be the next renames. --- apt/__init__.py | 15 ++++-- apt/cache.py | 108 +++++++++++++++++++++++++-------------- apt/cdrom.py | 6 ++- apt/debfile.py | 32 ++++++------ apt/deprecation.py | 76 ++++++++++++++++++++++++++++ apt/package.py | 126 +++++++++++++++++++++++++++++++--------------- apt/progress/gtk2.py | 6 +-- aptsources/sourceslist.py | 6 ++- debian/changelog | 6 +++ debian/control | 2 +- debian/rules | 3 ++ po/python-apt.pot | 10 ++-- python/apt_pkgmodule.cc | 6 +++ 13 files changed, 290 insertions(+), 112 deletions(-) create mode 100644 apt/deprecation.py (limited to 'debian/control') diff --git a/apt/__init__.py b/apt/__init__.py index ae2abbf2..734b3240 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -17,17 +17,21 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA # import the core of apt_pkg +"""High-Level Interface for working with apt.""" import apt_pkg -import sys -import os # import some fancy classes from apt.package import Package from apt.cache import Cache -from apt.progress import ( - OpProgress, FetchProgress, InstallProgress, CdromProgress) from apt.cdrom import Cdrom -from apt_pkg import SizeToStr, TimeToStr, VersionCompare + +if apt_pkg._COMPAT_0_7: + from apt.progress import (OpProgress, FetchProgress, InstallProgress, + CdromProgress) + + +if apt_pkg._COMPAT_0_7: + from apt_pkg import SizeToStr, TimeToStr, VersionCompare # init the package system apt_pkg.init() @@ -36,3 +40,4 @@ apt_pkg.init() #import warnings #warnings.warn("apt API not stable yet", FutureWarning) #del warnings +__all__ = ['Cache', 'Cdrom', 'Package'] diff --git a/apt/cache.py b/apt/cache.py index d13010af..928322d2 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -24,6 +24,7 @@ import weakref import apt_pkg from apt import Package +from apt.deprecation import AttributeDeprecatedBy, function_deprecated_by import apt.progress @@ -63,7 +64,7 @@ class Cache(object): rootdir + "/var/lib/dpkg/status") self.open(progress) - def _runCallbacks(self, name): + def _run_callbacks(self, name): """ internal helper to run a callback """ if name in self._callbacks: for callback in self._callbacks[name]: @@ -75,7 +76,7 @@ class Cache(object): """ if progress is None: progress = apt.progress.OpProgress() - self._runCallbacks("cache_pre_open") + self._run_callbacks("cache_pre_open") self._cache = apt_pkg.GetCache(progress) self._depcache = apt_pkg.GetDepCache(self._cache) self._records = apt_pkg.GetPkgRecords(self._cache) @@ -98,7 +99,7 @@ class Cache(object): i += 1 progress.done() - self._runCallbacks("cache_post_open") + self._run_callbacks("cache_post_open") def __getitem__(self, key): """ look like a dictionary (get key) """ @@ -128,12 +129,12 @@ class Cache(object): def keys(self): return list(self._set) - def getChanges(self): + def get_changes(self): """ Get the marked changes """ changes = [] for p in self: - if p.markedUpgrade or p.markedInstall or p.markedDelete or \ - p.markedDowngrade or p.markedReinstall: + if p.marked_upgrade or p.marked_install or p.marked_delete or \ + p.marked_downgrade or p.marked_reinstall: changes.append(p) return changes @@ -141,12 +142,12 @@ class Cache(object): """ Upgrade the all package, DistUpgrade will also install new dependencies """ - self.cachePreChange() + self.cache_pre_change() self._depcache.Upgrade(distUpgrade) - self.cachePostChange() + self.cache_post_change() @property - def requiredDownload(self): + def required_download(self): """Get the size of the packages that are required to download.""" pm = apt_pkg.GetPackageManager(self._depcache) fetcher = apt_pkg.GetAcquire() @@ -154,12 +155,12 @@ class Cache(object): return fetcher.FetchNeeded @property - def additionalRequiredSpace(self): + def required_space(self): """Get the size of the additional required space on the fs.""" return self._depcache.UsrSize @property - def reqReinstallPkgs(self): + def req_reinstall_pkgs(self): """Return the packages not downloadable packages in reqreinst state.""" reqreinst = set() for pkg in self: @@ -169,7 +170,7 @@ class Cache(object): reqreinst.add(pkg.name) return reqreinst - def _runFetcher(self, fetcher): + def _run_fetcher(self, fetcher): # do the actual fetching res = fetcher.Run() @@ -194,7 +195,7 @@ class Cache(object): raise FetchFailedException(errMsg) return res - def _fetchArchives(self, fetcher, pm): + def _fetch_archives(self, fetcher, pm): """ fetch the needed archives """ # get lock @@ -209,16 +210,16 @@ class Cache(object): return False # now run the fetcher, throw exception if something fails to be # fetched - return self._runFetcher(fetcher) + return self._run_fetcher(fetcher) finally: os.close(lock) - def isVirtualPackage(self, pkgname): + def is_virtual_package(self, pkgname): """Return whether the package is a virtual package.""" pkg = self._cache[pkgname] return bool(pkg.ProvidesList and not pkg.VersionList) - def getProvidingPackages(self, virtual): + def get_providing_packages(self, virtual): """ Return a list of packages which provide the virtual package of the specified name @@ -254,10 +255,16 @@ class Cache(object): finally: os.close(lock) - def installArchives(self, pm, installProgress): - installProgress.startUpdate() + def install_archives(self, pm, installProgress): + try: + installProgress.start_update() + except AttributeError: + installProgress.startUpdate() res = installProgress.run(pm) - installProgress.finishUpdate() + try: + installProgress.finish_update() + except AttributeError: + installProgress.finishUpdate() return res def commit(self, fetchProgress=None, installProgress=None): @@ -278,10 +285,10 @@ class Cache(object): fetcher = apt_pkg.GetAcquire(fetchProgress) while True: # fetch archives first - res = self._fetchArchives(fetcher, pm) + res = self._fetch_archives(fetcher, pm) # then install - res = self.installArchives(pm, installProgress) + res = self.install_archives(pm, installProgress) if res == pm.ResultCompleted: break if res == pm.ResultFailed: @@ -296,14 +303,14 @@ class Cache(object): # cache changes - def cachePostChange(self): + def cache_post_change(self): " called internally if the cache has changed, emit a signal then " - self._runCallbacks("cache_post_change") + self._run_callbacks("cache_post_change") - def cachePreChange(self): + def cache_pre_change(self): """ called internally if the cache is about to change, emit a signal then """ - self._runCallbacks("cache_pre_change") + self._run_callbacks("cache_pre_change") def connect(self, name, callback): """ connect to a signal, currently only used for @@ -312,6 +319,20 @@ class Cache(object): self._callbacks[name] = [] self._callbacks[name].append(callback) + if apt_pkg._COMPAT_0_7: + _runCallbacks = function_deprecated_by(_run_callbacks) + getChanges = function_deprecated_by(get_changes) + requiredDownload = AttributeDeprecatedBy('required_download') + additionalRequiredSpace = AttributeDeprecatedBy('required_space') + reqReinstallPkgs = AttributeDeprecatedBy('req_reinstall_pkgs') + _runFetcher = function_deprecated_by(_run_fetcher) + _fetchArchives = function_deprecated_by(_fetch_archives) + isVirtualPackage = function_deprecated_by(is_virtual_package) + getProvidingPackages = function_deprecated_by(get_providing_packages) + installArchives = function_deprecated_by(install_archives) + cachePostChange = function_deprecated_by(cache_post_change) + cachePreChange = function_deprecated_by(cache_pre_change) + # ----------------------------- experimental interface @@ -330,7 +351,7 @@ class MarkedChangesFilter(Filter): """ Filter that returns all marked changes """ def apply(self, pkg): - if pkg.markedInstall or pkg.markedDelete or pkg.markedUpgrade: + if pkg.marked_install or pkg.marked_delete or pkg.marked_upgrade: return True else: return False @@ -347,8 +368,8 @@ class FilteredCache(object): self.cache = Cache(progress) else: self.cache = cache - self.cache.connect("cache_post_change", self.filterCachePostChange) - self.cache.connect("cache_post_open", self.filterCachePostChange) + self.cache.connect("cache_post_change", self.filter_cache_post_change) + self.cache.connect("cache_post_open", self.filter_cache_post_change) self._filtered = {} self._filters = [] @@ -371,7 +392,7 @@ class FilteredCache(object): def __contains__(self, key): return (key in self._filtered) - def _reapplyFilter(self): + def _reapply_filter(self): " internal helper to refilter " self._filtered = {} for pkg in self.cache: @@ -380,18 +401,19 @@ class FilteredCache(object): self._filtered[pkg.name] = 1 break - def setFilter(self, filter): + def set_filter(self, filter): """Set the current active filter.""" self._filters = [] self._filters.append(filter) #self._reapplyFilter() # force a cache-change event that will result in a refiltering - self.cache.cachePostChange() + self.cache.cache_post_change() - def filterCachePostChange(self): + def filter_cache_post_change(self): """Called internally if the cache changes, emit a signal then.""" #print "filterCachePostChange()" - self._reapplyFilter() + self._reapply_filter() + # def connect(self, name, callback): # self.cache.connect(name, callback) @@ -401,6 +423,12 @@ class FilteredCache(object): #print "getattr: %s " % key return getattr(self.cache, key) + if apt_pkg._COMPAT_0_7: + _reapplyFilter = function_deprecated_by(_reapply_filter) + setFilter = function_deprecated_by(set_filter) + filterCachePostChange = function_deprecated_by(\ + filter_cache_post_change) + def cache_pre_changed(): print "cache pre changed" @@ -410,8 +438,8 @@ def cache_post_changed(): print "cache post changed" -# internal test code -if __name__ == "__main__": +def _test(): + """Internal test code.""" print "Cache self test" apt_pkg.init() c = Cache(apt.progress.OpTextProgress()) @@ -426,7 +454,7 @@ if __name__ == "__main__": x= c[pkg].name c.upgrade() - changes = c.getChanges() + changes = c.get_changes() print len(changes) for p in changes: #print p.name @@ -440,7 +468,7 @@ if __name__ == "__main__": apt_pkg.Config.Set("Dir::Cache::Archives", "/tmp/pytest") pm = apt_pkg.GetPackageManager(c._depcache) fetcher = apt_pkg.GetAcquire(apt.progress.TextFetchProgress()) - c._fetchArchives(fetcher, pm) + c._fetch_archives(fetcher, pm) #sys.exit(1) print "Testing filtered cache (argument is old cache)" @@ -448,7 +476,7 @@ if __name__ == "__main__": f.cache.connect("cache_pre_change", cache_pre_changed) f.cache.connect("cache_post_change", cache_post_changed) f.cache.upgrade() - f.setFilter(MarkedChangesFilter()) + f.set_filter(MarkedChangesFilter()) print len(f) for pkg in f.keys(): #print c[pkg].name @@ -461,10 +489,12 @@ if __name__ == "__main__": f.cache.connect("cache_pre_change", cache_pre_changed) f.cache.connect("cache_post_change", cache_post_changed) f.cache.upgrade() - f.setFilter(MarkedChangesFilter()) + f.set_filter(MarkedChangesFilter()) print len(f) for pkg in f.keys(): #print c[pkg].name x = f[pkg].name print len(f) +if __name__ == '__main__': + _test() diff --git a/apt/cdrom.py b/apt/cdrom.py index b52762ad..907ac622 100644 --- a/apt/cdrom.py +++ b/apt/cdrom.py @@ -24,6 +24,7 @@ import glob import apt_pkg from apt.progress import CdromProgress +from apt.deprecation import AttributeDeprecatedBy class Cdrom(object): @@ -69,7 +70,7 @@ class Cdrom(object): return ident @property - def inSourcesList(self): + def in_sources_list(self): """Check if the cdrom is already in the current sources.list.""" cd_id = self.ident() if cd_id is None: @@ -84,3 +85,6 @@ class Cdrom(object): if not line.lstrip().startswith("#") and cd_id in line: return True return False + + if apt_pkg._COMPAT_0_7: + inSourcesList = AttributeDeprecatedBy('in_sources_list') diff --git a/apt/debfile.py b/apt/debfile.py index 8d4f534c..c60fc92d 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -97,11 +97,11 @@ class DebPackage(object): # check for virtual pkgs if not depname in self._cache: - if self._cache.isVirtualPackage(depname): + if self._cache.is_virtual_package(depname): self._dbg(3, "_isOrGroupSatisfied(): %s is virtual dep" % depname) - for pkg in self._cache.getProvidingPackages(depname): - if pkg.isInstalled: + for pkg in self._cache.get_providing_packages(depname): + if pkg.is_installed: return True continue @@ -117,9 +117,9 @@ class DebPackage(object): # if we don't have it in the cache, it may be virtual if not depname in self._cache: - if not self._cache.isVirtualPackage(depname): + if not self._cache.is_virtual_package(depname): continue - providers = self._cache.getProvidingPackages(depname) + providers = self._cache.get_providing_packages(depname) # if a package just has a single virtual provider, we # just pick that (just like apt) if len(providers) != 1: @@ -158,9 +158,9 @@ class DebPackage(object): (pkgname, ver, oper)) pkg = self._cache[pkgname] - if pkg.isInstalled: + if pkg.is_installed: pkgver = pkg.installed.version - elif pkg.markedInstall: + elif pkg.marked_install: pkgver = pkg.candidate.version else: return False @@ -191,8 +191,8 @@ class DebPackage(object): if not depname in self._cache: # FIXME: we have to check for virtual replaces here as # well (to pass tests/gdebi-test8.deb) - if self._cache.isVirtualPackage(depname): - for pkg in self._cache.getProvidingPackages(depname): + if self._cache.is_virtual_package(depname): + for pkg in self._cache.get_providing_packages(depname): self._dbg(3, "conflicts virtual check: %s" % pkg.name) # P/C/R on virtal pkg, e.g. ftpd if self.pkgname == pkg.name: @@ -253,9 +253,9 @@ class DebPackage(object): """ self._dbg(3, "replacesPkg() %s %s %s" % (pkgname, oper, ver)) pkg = self._cache[pkgname] - if pkg.isInstalled: + if pkg.is_installed: pkgver = pkg.installed.version - elif pkg.markedInstall: + elif pkg.marked_install: pkgver = pkg.candidate.version else: pkgver = None @@ -371,7 +371,7 @@ class DebPackage(object): # now try it out in the cache for pkg in self._need_pkgs: try: - self._cache[pkg].markInstall(fromUser=False) + self._cache[pkg].mark_install(fromUser=False) except SystemError, e: self._failure_string = _("Cannot install '%s'" % pkg) self._cache.clear() @@ -396,7 +396,7 @@ class DebPackage(object): remove = [] unauthenticated = [] for pkg in self._cache: - if pkg.markedInstall or pkg.markedUpgrade: + if pkg.marked_install or pkg.marked_upgrade: install.append(pkg.name) # check authentication, one authenticated origin is enough # libapt will skip non-authenticated origins then @@ -405,7 +405,7 @@ class DebPackage(object): authenticated |= origin.trusted if not authenticated: unauthenticated.append(pkg.name) - if pkg.markedDelete: + if pkg.marked_delete: remove.append(pkg.name) return (install, remove, unauthenticated) @@ -492,7 +492,7 @@ class DscSrcPackage(DebPackage): for pkgname in self._installed_conflicts: if self._cache[pkgname]._pkg.Essential: raise Exception(_("An essential package would be removed")) - self._cache[pkgname].markDelete() + self._cache[pkgname].mark_delete() # FIXME: a additional run of the checkConflicts() # after _satisfyDepends() should probably be done return self._satisfy_depends(self.depends) @@ -507,7 +507,7 @@ def _test(): vp = "www-browser" #print "%s virtual: %s" % (vp, cache.isVirtualPackage(vp)) - providers = cache.getProvidingPackages(vp) + providers = cache.get_providing_packages(vp) print "Providers for %s :" % vp for pkg in providers: print " %s" % pkg.name diff --git a/apt/deprecation.py b/apt/deprecation.py new file mode 100644 index 00000000..a14d49e6 --- /dev/null +++ b/apt/deprecation.py @@ -0,0 +1,76 @@ +# deprecation.py - Module providing classes and functions for deprecation. +# +# Copyright (c) 2009 Julian Andres Klode +# Copyright (c) 2009 Ben Finney +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +"""Classes and functions for deprecating features. + +This is used for internal purposes only and not part of the official API. Do +not use it for anything outside the apt package. +""" +import re +import operator +import warnings + +__all__ = [] + + +class AttributeDeprecatedBy(object): + """Property acting as a proxy for a new attribute. + + When accessed, the property issues a DeprecationWarning and (on get) calls + attrgetter() for the attribute 'attribute' on the current object or (on + set) uses setattr to set the value of the wrapped attribute. + """ + + def __init__(self, attribute): + """Initialize the property.""" + self.attribute = attribute + self.__doc__ = 'Deprecated, please use \'%s\' instead' % attribute + self.getter = operator.attrgetter(attribute) + + def __get__(self, obj, type=None): + """Issue a DeprecationWarning and return the requested value.""" + if obj is None: + return getattr(type, self.attribute, self) + warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) + return self.getter(obj or type) + + def __set__(self, obj, value): + """Issue a DeprecationWarning and set the requested value.""" + warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) + setattr(obj, self.attribute, value) + + +def function_deprecated_by(func, convert_names=True): + """Return a function that warns it is deprecated by another function. + + Returns a new function that warns it is deprecated by function 'func', + then acts as a pass-through wrapper for 'func'. + + This function also converts all keyword argument names from mixedCase to + lowercase_with_underscores, but only if 'convert_names' is True (default). + """ + warning = 'Deprecated, please use \'%s\' instead' % func.func_name + + def deprecated_function(*args, **kwds): + warnings.warn(warning, DeprecationWarning, stacklevel=2) + if convert_names: + for key in kwds.keys(): + kwds[re.sub('([A-Z])', '_\\1', key).lower()] = kwds.pop(key) + return func(*args, **kwds) + return deprecated_function diff --git a/apt/package.py b/apt/package.py index db5696ae..70997383 100644 --- a/apt/package.py +++ b/apt/package.py @@ -31,6 +31,7 @@ import warnings import apt_pkg import apt.progress +from apt.deprecation import function_deprecated_by, AttributeDeprecatedBy __all__ = ('BaseDependency', 'Dependency', 'Origin', 'Package', 'Record', 'Version') @@ -56,21 +57,24 @@ class BaseDependency(object): """A single dependency. Attributes defined here: - name - The name of the dependency - relation - The relation (>>,>=,==,<<,<=,) - version - The version depended on - preDepend - Boolean value whether this is a pre-dependency. + name - The name of the dependency + relation - The relation (>>,>=,==,<<,<=,) + version - The version depended on + pre_depend - Boolean value whether this is a pre-dependency. """ def __init__(self, name, rel, ver, pre): self.name = name self.relation = rel self.version = ver - self.preDepend = pre + self.pre_depend = pre def __repr__(self): return ('' - % (self.name, self.relation, self.version, self.preDepend)) + % (self.name, self.relation, self.version, self.pre_depend)) + + if apt_pkg._COMPAT_0_7: + preDepend = AttributeDeprecatedBy('pre_depend') class Dependency(object): @@ -103,7 +107,7 @@ class DeprecatedProperty(property): warnings.warn("Accessed deprecated property %s.%s, please see the " "Version class for alternatives." % ((obj.__class__.__name__ or type.__name__), - self.fget.func_name), DeprecationWarning, 2) + self.fget.__name__), DeprecationWarning, 2) return property.__get__(self, obj, type) @@ -528,9 +532,9 @@ class Package(object): def __set_candidate(self, version): """Set the candidate version of the package.""" - self._pcache.cachePreChange() + self._pcache.cache_pre_change() self._pcache._depcache.SetCandidateVer(self._pkg, version._cand) - self._pcache.cachePostChange() + self._pcache.cache_post_change() candidate = property(candidate, __set_candidate) @@ -703,55 +707,56 @@ class Package(object): # depcache states @property - def markedInstall(self): + def marked_install(self): """Return ``True`` if the package is marked for install.""" return self._pcache._depcache.MarkedInstall(self._pkg) @property - def markedUpgrade(self): + def marked_upgrade(self): """Return ``True`` if the package is marked for upgrade.""" return self._pcache._depcache.MarkedUpgrade(self._pkg) @property - def markedDelete(self): + def marked_delete(self): """Return ``True`` if the package is marked for delete.""" return self._pcache._depcache.MarkedDelete(self._pkg) @property - def markedKeep(self): + def marked_keep(self): """Return ``True`` if the package is marked for keep.""" return self._pcache._depcache.MarkedKeep(self._pkg) @property - def markedDowngrade(self): + def marked_downgrade(self): """ Package is marked for downgrade """ return self._pcache._depcache.MarkedDowngrade(self._pkg) @property - def markedReinstall(self): + def marked_reinstall(self): """Return ``True`` if the package is marked for reinstall.""" return self._pcache._depcache.MarkedReinstall(self._pkg) @property - def isInstalled(self): + def is_installed(self): """Return ``True`` if the package is installed.""" return (self._pkg.CurrentVer is not None) @property - def isUpgradable(self): + def is_upgradable(self): """Return ``True`` if the package is upgradable.""" - return (self.isInstalled and + return (self.is_installed and self._pcache._depcache.IsUpgradable(self._pkg)) @property - def isAutoRemovable(self): + def is_auto_removable(self): """Return ``True`` if the package is no longer required. If the package has been installed automatically as a dependency of another package, and if no packages depend on it anymore, the package is no longer required. """ - return self.isInstalled and self._pcache._depcache.IsGarbage(self._pkg) + return self.is_installed and \ + self._pcache._depcache.IsGarbage(self._pkg) # sizes @@ -789,7 +794,7 @@ class Package(object): return getattr(self.installed, 'installed_size', 0) @property - def installedFiles(self): + def installed_files(self): """Return a list of files installed by the package. Return a list of unicode names of the files which have @@ -805,7 +810,7 @@ class Package(object): except EnvironmentError: return [] - def getChangelog(self, uri=None, cancel_lock=None): + def get_changelog(self, uri=None, cancel_lock=None): """ Download the changelog of the package and return it as unicode string. @@ -928,7 +933,7 @@ class Package(object): if match: # strip epoch from installed version # and from changelog too - installed = self.installedVersion + installed = getattr(self.installed, 'version', None) if installed and ":" in installed: installed = installed.split(":", 1)[1] changelog_ver = match.group(1) @@ -976,13 +981,13 @@ class Package(object): # depcache actions - def markKeep(self): + def mark_keep(self): """Mark a package for keep.""" - self._pcache.cachePreChange() + self._pcache.cache_pre_change() self._pcache._depcache.MarkKeep(self._pkg) - self._pcache.cachePostChange() + self._pcache.cache_post_change() - def markDelete(self, autoFix=True, purge=False): + def mark_delete(self, autoFix=True, purge=False): """Mark a package for install. If *autoFix* is ``True``, the resolver will be run, trying to fix @@ -991,7 +996,7 @@ class Package(object): If *purge* is ``True``, remove the configuration files of the package as well. The default is to keep the configuration. """ - self._pcache.cachePreChange() + self._pcache.cache_pre_change() self._pcache._depcache.MarkDelete(self._pkg, purge) # try to fix broken stuffsta if autoFix and self._pcache._depcache.BrokenCount > 0: @@ -1001,9 +1006,9 @@ class Package(object): Fix.Remove(self._pkg) Fix.InstallProtect() Fix.Resolve() - self._pcache.cachePostChange() + self._pcache.cache_post_change() - def markInstall(self, autoFix=True, autoInst=True, fromUser=True): + def mark_install(self, autoFix=True, autoInst=True, fromUser=True): """Mark a package for install. If *autoFix* is ``True``, the resolver will be run, trying to fix @@ -1017,7 +1022,7 @@ class Package(object): want to be able to automatically remove the package at a later stage when no other package depends on it. """ - self._pcache.cachePreChange() + self._pcache.cache_pre_change() self._pcache._depcache.MarkInstall(self._pkg, autoInst, fromUser) # try to fix broken stuff if autoFix and self._pcache._depcache.BrokenCount > 0: @@ -1025,12 +1030,12 @@ class Package(object): fixer.Clear(self._pkg) fixer.Protect(self._pkg) fixer.Resolve(True) - self._pcache.cachePostChange() + self._pcache.cache_post_change() - def markUpgrade(self): + def mark_upgrade(self): """Mark a package for upgrade.""" - if self.isUpgradable: - self.markInstall() + if self.is_upgradable: + self.mark_install() else: # FIXME: we may want to throw a exception here sys.stderr.write(("MarkUpgrade() called on a non-upgrable pkg: " @@ -1048,11 +1053,50 @@ class Package(object): self._pcache._depcache.Commit(fprogress, iprogress) + if not apt_pkg._COMPAT_0_7: + del installedVersion + del candidateVersion + del candidateDependencies + del installedDependencies + del architecture + del candidateDownloadable + del installedDownloadable + del sourcePackageName + del homepage + del priority + del installedPriority + del summary + del description + del rawDescription + del candidateRecord + del installedRecord + del packageSize + del installedPackageSize + del candidateInstalledSize + del installedSize + del candidateOrigin + else: + markedInstalled = AttributeDeprecatedBy('marked_installed') + markedUpgrade = AttributeDeprecatedBy('marked_upgrade') + markedDelete = AttributeDeprecatedBy('marked_delete') + markedKeep = AttributeDeprecatedBy('marked_keep') + markedDowngrade = AttributeDeprecatedBy('marked_downgrade') + markedReinstall = AttributeDeprecatedBy('marked_reinstall') + isInstalled = AttributeDeprecatedBy('is_installed') + isUpgradable = AttributeDeprecatedBy('is_upgradable') + isAutoRemovable = AttributeDeprecatedBy('is_auto_removable') + installedFiles = AttributeDeprecatedBy('installed_files') + getChangelog = function_deprecated_by(get_changelog) + markDelete = function_deprecated_by(mark_delete) + markInstall = function_deprecated_by(mark_install) + markKeep = function_deprecated_by(mark_keep) + markUpgrade = function_deprecated_by(mark_upgrade) + + def _test(): """Self-test.""" print "Self-test for the Package modul" import random - import apt apt_pkg.init() progress = apt.progress.OpTextProgress() cache = apt.Cache(progress) @@ -1075,19 +1119,19 @@ def _test(): print "Dependencies: %s" % pkg.installed.dependencies for dep in pkg.candidate.dependencies: print ",".join("%s (%s) (%s) (%s)" % (o.name, o.version, o.relation, - o.preDepend) for o in dep.or_dependencies) + o.pre_depend) for o in dep.or_dependencies) print "arch: %s" % pkg.candidate.architecture print "homepage: %s" % pkg.candidate.homepage print "rec: ", pkg.candidate.record - print cache["2vcard"].getChangelog() + print cache["2vcard"].get_changelog() for i in True, False: print "Running install on random upgradable pkgs with AutoFix: %s " % i for pkg in cache: - if pkg.isUpgradable: + if pkg.is_upgradable: if random.randint(0, 1) == 1: - pkg.markInstall(i) + pkg.mark_install(i) print "Broken: %s " % cache._depcache.BrokenCount print "InstCount: %s " % cache._depcache.InstCount @@ -1099,7 +1143,7 @@ def _test(): for name in cache.keys(): if random.randint(0, 1) == 1: try: - cache[name].markDelete(i) + cache[name].mark_delete(i) except SystemError: print "Error trying to remove: %s " % name print "Broken: %s " % cache._depcache.BrokenCount diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py index f872e34f..36d459bc 100644 --- a/apt/progress/gtk2.py +++ b/apt/progress/gtk2.py @@ -422,10 +422,10 @@ def _test(): win.show() cache = apt.cache.Cache(apt_progress.open) pkg = cache["xterm"] - if pkg.isInstalled: - pkg.markDelete() + if pkg.is_installed: + pkg.mark_delete() else: - pkg.markInstall() + pkg.mark_install() apt_progress.show_terminal(True) try: cache.commit(apt_progress.fetch, apt_progress.install) diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index 1dfd870f..fdc0f029 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -33,6 +33,7 @@ import time import apt_pkg from aptsources.distinfo import DistInfo +from apt.deprecation import function_deprecated_by # some global helpers @@ -309,7 +310,7 @@ class SourcesList(object): """ remove the specified entry from the sources.list """ self.list.remove(source_entry) - def restoreBackup(self, backup_ext): + def restore_backup(self, backup_ext): " restore sources.list files based on the backup extension " file = apt_pkg.Config.FindFile("Dir::Etc::sourcelist") if os.path.exists(file+backup_ext) and \ @@ -321,6 +322,9 @@ class SourcesList(object): if os.path.exists(file+backup_ext): shutil.copy(file+backup_ext, file) + if apt_pkg._COMPAT_0_7: + restoreBackup = function_deprecated_by(restore_backup) + def backup(self, backup_ext=None): """ make a backup of the current source files, if no backup extension is given, the current date/time is used (and returned) """ diff --git a/debian/changelog b/debian/changelog index b2f2b965..e344c145 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +python-apt (0.7.91) UNRELEASED; urgency=low + + * Rename all methods,functions,attributes to conform to PEP 8 (Closes: #481061) + + -- Julian Andres Klode Thu, 16 Apr 2009 18:54:29 +0200 + python-apt (0.7.90) experimental; urgency=low * Introduce support for Python 3 (Closes: #523645) diff --git a/debian/control b/debian/control index 08ee329f..374a177c 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.1 -XS-Python-Version: all +XS-Python-Version: >= 2.5 Build-Depends: apt-utils, cdbs, debhelper (>= 5.0.37.1), diff --git a/debian/rules b/debian/rules index 9d0219e2..5fc6e13b 100755 --- a/debian/rules +++ b/debian/rules @@ -16,6 +16,9 @@ PKG=python-apt DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') DEB_COMPRESS_EXCLUDE:=.html .js _static/* _sources/* _sources/*/* .inv DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS) + +# Define COMPAT_0_7 to get all the deprecated interfaces. +export CFLAGS+=-DCOMPAT_0_7 export DEBVER diff --git a/po/python-apt.pot b/po/python-apt.pot index d12ae967..3fcd395a 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-04-15 16:10+0200\n" +"POT-Creation-Date: 2009-04-16 19:54+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -354,16 +354,16 @@ msgstr "" msgid "Complete" msgstr "" -#: ../apt/package.py:282 +#: ../apt/package.py:286 #, python-format msgid "Invalid unicode in description for '%s' (%s). Please report." msgstr "" -#: ../apt/package.py:830 ../apt/package.py:934 +#: ../apt/package.py:846 ../apt/package.py:950 msgid "The list of changes is not available" msgstr "" -#: ../apt/package.py:938 +#: ../apt/package.py:954 #, python-format msgid "" "The list of changes is not available yet.\n" @@ -372,7 +372,7 @@ msgid "" "until the changes become available or try again later." msgstr "" -#: ../apt/package.py:944 +#: ../apt/package.py:960 msgid "" "Failed to download the list of changes. \n" "Please check your Internet connection." diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 3beec747..a056b0bc 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -589,6 +589,12 @@ extern "C" void initapt_pkg() AddInt(Dict,"InstStateReInstReq",pkgCache::State::ReInstReq); AddInt(Dict,"InstStateHold",pkgCache::State::Hold); AddInt(Dict,"InstStateHoldReInstReq",pkgCache::State::HoldReInstReq); + + #ifdef COMPAT_0_7 + AddInt(Dict,"_COMPAT_0_7",1); + #else + AddInt(Dict,"_COMPAT_0_7",0); + #endif #if PY_MAJOR_VERSION >= 3 return Module; #endif -- cgit v1.2.3 From aa5b58b56b7e332d15e6ac9f3dfeffa60c2749a6 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 24 Apr 2009 18:43:52 +0200 Subject: * debian/control: Do not require python >= 2.5, mistake in previous commit. --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debian/control') diff --git a/debian/control b/debian/control index 374a177c..08ee329f 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.1 -XS-Python-Version: >= 2.5 +XS-Python-Version: all Build-Depends: apt-utils, cdbs, debhelper (>= 5.0.37.1), -- cgit v1.2.3 From 4ced65ec744e29019e7890eb6f505387940e74d5 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 5 Jun 2009 19:36:59 +0200 Subject: debian/control: Only recommend libjs-jquery (Closes: #527543). --- debian/changelog | 3 ++- debian/control | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index f2e03811..6150632c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,12 +7,13 @@ python-apt (0.7.91) UNRELEASED; urgency=low * utils/migrate-0.8.py: Helper to check Python code for deprecated functions, attributes,etc. Has to be run from the python-apt source tree, but can be used for all Python code using python-apt. + * debian/control: Only recommend libjs-jquery (Closes: #527543). [ Stefano Zacchiroli ] * debian/python-apt.doc-base: register the documentation with the doc-base system (Closes: #525134) - -- Julian Andres Klode Fri, 17 Apr 2009 17:48:27 +0200 + -- Julian Andres Klode Fri, 05 Jun 2009 19:36:45 +0200 python-apt (0.7.90) experimental; urgency=low diff --git a/debian/control b/debian/control index 08ee329f..25c58f15 100644 --- a/debian/control +++ b/debian/control @@ -23,9 +23,8 @@ Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes Package: python-apt Architecture: any -Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, lsb-release, - libjs-jquery -Recommends: iso-codes +Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, lsb-release +Recommends: iso-codes, libjs-jquery Breaks: debdelta (<< 0.28~) Provides: ${python:Provides} Suggests: python-apt-dbg, python-gtk2, python-vte -- cgit v1.2.3 From f01f323bf739c8deee17722f5fc6aaf480d7bc13 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 22 Jun 2009 16:17:23 +0200 Subject: debian/control: Update Standards-Version to 3.8.2 --- debian/changelog | 1 + debian/control | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 60ace1f8..843c6b3b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Drop apt_pkg.Cache.open() and apt_pkg.Cache.close(), they cause segfaults and memory leaks. Simply create a new cache instead. * Merge 0.7.10.4 from unstable + * debian/control: Update Standards-Version to 3.8.2 [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/debian/control b/debian/control index 25c58f15..fc48f192 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: python Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode -Standards-Version: 3.8.1 +Standards-Version: 3.8.2 XS-Python-Version: all Build-Depends: apt-utils, cdbs, -- cgit v1.2.3 From ca5913fc53580b29034d56dd7942c5cdf5207afe Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 7 Jul 2009 16:57:05 +0200 Subject: debian/control: Build-Depend on libapt-pkg-dev (>= 0.7.22~). --- debian/changelog | 3 ++- debian/control | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 3209f7ee..2b3f0ac1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * debian/control: Update Standards-Version to 3.8.2 * Make AcquireFile a subclass of AcquireItem * Make ConfigurationPtr,ConfigurationSub subclasses of Configuration. + * debian/control: Build-Depend on libapt-pkg-dev (>= 0.7.22~). [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -36,7 +37,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Mon, 22 Jun 2009 15:49:03 +0200 + -- Julian Andres Klode Tue, 07 Jul 2009 16:56:44 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/debian/control b/debian/control index fc48f192..10b9bc31 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ XS-Python-Version: all Build-Depends: apt-utils, cdbs, debhelper (>= 5.0.37.1), - libapt-pkg-dev (>= 0.7.10), + libapt-pkg-dev (>= 0.7.22~), python-all-dbg, python-all-dev, python3.1-dev, -- cgit v1.2.3 From 360477dcc304b8a18c467e59435d8c766bbb76bb Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Jul 2009 14:14:44 +0200 Subject: python/python-apt.h: Introduce the C++ API The C++ API provides support for creating Python objects from C++ objects given by pointer or reference (depending on the implementation of the Python object) and for retrieving the underlying C++ object from the Python object and for checking the type of the Python object. --- debian/changelog | 1 + debian/control | 11 ++ debian/python-apt-dev.examples | 1 + debian/python-apt-dev.install | 2 + doc/client-example.cc | 46 ++++++++ python/apt_pkgmodule.cc | 38 ++++++ python/apt_pkgmodule.h | 4 +- python/hashstring.cc | 5 - python/python-apt.h | 259 +++++++++++++++++++++++++++++++++++++++++ 9 files changed, 360 insertions(+), 7 deletions(-) create mode 100644 debian/python-apt-dev.examples create mode 100644 debian/python-apt-dev.install create mode 100644 doc/client-example.cc create mode 100644 python/python-apt.h (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 4ae6e574..415ebdd2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low [ Julian Andres Klode ] * Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) * Add apt_pkg.Policy class (Closes: #382725) + * Provide a C++ API in the package python-apt-dev (Closes: #334923) * Allow types providing __new__() to be subclassed. * Bugfix: Delete pointers correctly, fixing memory leaks. (LP: #370149) * apt/package.py: Return VersionList objects in Package.versions, which diff --git a/debian/control b/debian/control index 10b9bc31..a16ae10e 100644 --- a/debian/control +++ b/debian/control @@ -54,3 +54,14 @@ Description: Python interface to libapt-pkg (debug extension) variety of functions. . This package contains the extension built for the Python debug interpreter. + +Package: python-apt-dev +Architecture: all +Depends: python-apt (>= ${source:Version}), libapt-pkg-dev (>= 0.7.10) +Description: Python interface to libapt-pkg (development files) + The apt_pkg Python interface will provide full access to the internal + libapt-pkg structures allowing Python programs to easily perform a + variety of functions. + . + This package contains the header files needed to use python-apt objects from + C++ applications. diff --git a/debian/python-apt-dev.examples b/debian/python-apt-dev.examples new file mode 100644 index 00000000..39f7bf97 --- /dev/null +++ b/debian/python-apt-dev.examples @@ -0,0 +1 @@ +doc/client-example.cc diff --git a/debian/python-apt-dev.install b/debian/python-apt-dev.install new file mode 100644 index 00000000..2a1405fd --- /dev/null +++ b/debian/python-apt-dev.install @@ -0,0 +1,2 @@ +python/python-apt.h usr/include/python-apt/ +python/generic.h usr/include/python-apt/ diff --git a/doc/client-example.cc b/doc/client-example.cc new file mode 100644 index 00000000..7fa6672f --- /dev/null +++ b/doc/client-example.cc @@ -0,0 +1,46 @@ +/* + * client-example.cc - A simple example for using the python-apt C++ API. + * + * Copyright 2009 Julian Andres Klode + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include + +int main(int argc, char *argv[]) { + Py_Initialize(); + if (import_apt_pkg() < 0) + return 1; + + // Initialize a module. + PyObject *Module = Py_InitModule("client", NULL); + + // Create a HashString, which will be added to the module. + HashString *hash = new HashString("0966a120bb936bdc6fdeac445707aa6b"); + // Create a Python object for the hashstring and add it to the module + PyModule_AddObject(Module, "hash", PyHashString_FromCpp(hash)); + + // Another example: Add the HashString type to the module. + Py_INCREF(&PyHashString_Type); + PyModule_AddObject(Module, "HashString", (PyObject*)(&PyHashString_Type)); + + // Run IPython, adding the client module to the namespace. + PySys_SetArgv(argc, argv); + PyRun_SimpleString("from IPython.Shell import start\n"); + PyRun_SimpleString("import client\n"); + PyRun_SimpleString("start(user_ns=dict(client=client)).mainloop()\n"); + Py_Finalize(); +} diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index e4fd0dfc..bc2f4258 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -498,6 +498,38 @@ static PyMethodDef methods[] = {} }; +static struct _PyAptPkgAPIStruct API = { + &PyAcquire_Type, // acquire_type + &PyAcquireFile_Type, // acquirefile_type + &PyAcquireItem_Type, // acquireitem_type + &PyActionGroup_Type, // actiongroup_type + &PyCache_Type, // cache_type + &PyCacheFile_Type, // cachefile_type + &PyCdrom_Type, // cdrom_type + &PyConfiguration_Type, // configuration_type + &PyDepCache_Type, // depcache_type + &PyDependency_Type, // dependency_type + &PyDependencyList_Type, // dependencylist_type + &PyDescription_Type, // description_type + &PyHashes_Type, // hashes_type + &PyHashString_Type, // hashstring_type + &PyIndexRecords_Type, // indexrecords_type + &PyMetaIndex_Type, // metaindex_type + &PyPackage_Type, // package_type + &PyPackageFile_Type, // packagefile_type + &PyPackageIndexFile_Type, // packageindexfile_type + &PyPackageList_Type, // packagelist_type + &PyPackageManager_Type, // packagemanager_type + &PyPackageRecords_Type, // packagerecords_type + &PyPolicy_Type, // policy_type + &PyProblemResolver_Type, // problemresolver_type + &PySourceList_Type, // sourcelist_type + &PySourceRecords_Type, // sourcerecords_type + &PyTagFile_Type, // tagfile_type + &PyTagSection_Type, // tagsection_type + &PyVersion_Type, // version_type +}; + #define ADDTYPE(mod,name,type) { \ if (PyType_Ready(type) == -1) INIT_ERROR; \ @@ -596,6 +628,12 @@ extern "C" void initapt_pkg() PyModule_AddObject(Module,"REWRITE_SOURCE_ORDER", CharCharToList(TFRewriteSourceOrder)); +#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 + PyObject *PyCapsule = PyCapsule_New(&API, "apt_pkg._C_API", NULL); +#else + PyObject *PyCapsule = PyCObject_FromVoidPtr(&API, NULL); +#endif + PyModule_AddObject(Module, "_C_API", PyCapsule); // Version.. PyModule_AddStringConstant(Module,"VERSION",(char *)pkgVersion); PyModule_AddStringConstant(Module,"LIB_VERSION",(char *)pkgLibVersion); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index f77c5e73..97be5d5c 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -104,7 +104,6 @@ extern PyTypeObject PyPackageIndexFile_Type; extern PyTypeObject PyMetaIndex_Type; // HashString -PyObject *PyHashString_FromCpp(HashString *obj); extern PyTypeObject PyHashString_Type; // IndexRecord @@ -113,5 +112,6 @@ extern PyTypeObject PyIndexRecords_Type; // Policy extern PyTypeObject PyPolicy_Type; extern PyTypeObject PyHashes_Type; - +#include "python-apt.h" #endif + diff --git a/python/hashstring.cc b/python/hashstring.cc index d303049a..b76dc127 100644 --- a/python/hashstring.cc +++ b/python/hashstring.cc @@ -39,11 +39,6 @@ static PyObject *HashString_NEW(PyTypeObject *type,PyObject *Args, return PyObj; } -PyObject *PyHashString_FromCpp(HashString *obj) -{ - return CppPyObject_NEW(&PyHashString_Type, obj); -} - static PyObject *HashString_Repr(PyObject *self) { HashString *hash = GetCpp(self); diff --git a/python/python-apt.h b/python/python-apt.h new file mode 100644 index 00000000..557f5a3b --- /dev/null +++ b/python/python-apt.h @@ -0,0 +1,259 @@ +/* + * python-apt.h - Header file for the public interface. + * + * Copyright 2009 Julian Andres Klode + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef PYTHON_APT_H +#define PYTHON_APT_H +#include +#include +#include "generic.h" + +struct _PyAptPkgAPIStruct { + PyTypeObject *acquire_type; + PyTypeObject *acquirefile_type; + PyTypeObject *acquireitem_type; + PyTypeObject *actiongroup_type; + PyTypeObject *cache_type; + PyTypeObject *cachefile_type; + PyTypeObject *cdrom_type; + PyTypeObject *configuration_type; + PyTypeObject *depcache_type; + PyTypeObject *dependency_type; + PyTypeObject *dependencylist_type; + PyTypeObject *description_type; + PyTypeObject *hashes_type; + PyTypeObject *hashstring_type; + PyTypeObject *indexrecords_type; + PyTypeObject *metaindex_type; + PyTypeObject *package_type; + PyTypeObject *packagefile_type; + PyTypeObject *packageindexfile_type; + PyTypeObject *packagelist_type; + PyTypeObject *packagemanager_type; + PyTypeObject *packagerecords_type; + PyTypeObject *policy_type; + PyTypeObject *problemresolver_type; + PyTypeObject *sourcelist_type; + PyTypeObject *sourcerecords_type; + PyTypeObject *tagfile_type; + PyTypeObject *tagsection_type; + PyTypeObject *version_type; +}; + +# ifndef APT_PKGMODULE_H +# define PyAcquire_Type *(_PyAptPkg_API->acquire_type) +# define PyAcquireFile_Type *(_PyAptPkg_API->acquirefile_type) +# define PyAcquireItem_Type *(_PyAptPkg_API->acquireitem_type) +# define PyActionGroup_Type *(_PyAptPkg_API->actiongroup_type) +# define PyCache_Type *(_PyAptPkg_API->cache_type) +# define PyCacheFile_Type *(_PyAptPkg_API->cachefile_type) +# define PyCdrom_Type *(_PyAptPkg_API->cdrom_type) +# define PyConfiguration_Type *(_PyAptPkg_API->configuration_type) +# define PyDepCache_Type *(_PyAptPkg_API->depcache_type) +# define PyDependency_Type *(_PyAptPkg_API->dependency_type) +# define PyDependencyList_Type *(_PyAptPkg_API->dependencylist_type) +# define PyDescription_Type *(_PyAptPkg_API->description_type) +# define PyHashes_Type *(_PyAptPkg_API->hashes_type) +# define PyHashString_Type *(_PyAptPkg_API->hashstring_type) +# define PyIndexRecords_Type *(_PyAptPkg_API->indexrecords_type) +# define PyMetaIndex_Type *(_PyAptPkg_API->metaindex_type) +# define PyPackage_Type *(_PyAptPkg_API->package_type) +# define PyPackageFile_Type *(_PyAptPkg_API->packagefile_type) +# define PyPackageIndexFile_Type *(_PyAptPkg_API->packageindexfile_type) +# define PyPackageList_Type *(_PyAptPkg_API->packagelist_type) +# define PyPackageManager_Type *(_PyAptPkg_API->packagemanager_type) +# define PyPackageRecords_Type *(_PyAptPkg_API->packagerecords_type) +# define PyPolicy_Type *(_PyAptPkg_API->policy_type) +# define PyProblemResolver_Type *(_PyAptPkg_API->problemresolver_type) +# define PySourceList_Type *(_PyAptPkg_API->sourcelist_type) +# define PySourceRecords_Type *(_PyAptPkg_API->sourcerecords_type) +# define PyTagFile_Type *(_PyAptPkg_API->tagfile_type) +# define PyTagSection_Type *(_PyAptPkg_API->tagsection_type) +# define PyVersion_Type *(_PyAptPkg_API->version_type) + +// Creating + +static struct _PyAptPkgAPIStruct *_PyAptPkg_API; + +static int import_apt_pkg(void) { +# if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 + _PyAptPkg_API = (_PyAptPkgAPIStruct *)PyCapsule_Import("apt_pkg._C_API", 0); + return (_PyAptPkg_API != NULL) ? 0 : -1; +# else + + PyObject *module = PyImport_ImportModule("apt_pkg"); + + if (module == NULL) { + return -1; + } + if (module != NULL) { + PyObject *c_api_object = PyObject_GetAttrString(module, "_C_API"); + if (c_api_object == NULL) + return -1; + if (PyCObject_Check(c_api_object)) + _PyAptPkg_API = (struct _PyAptPkgAPIStruct *)PyCObject_AsVoidPtr(c_api_object); + Py_DECREF(c_api_object); + } + return 0; +# endif // PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 +} +# endif // APT_PKGMODULE_H + +// Checking macros. +# define PyAcquire_Check(op) PyObject_TypeCheck(op, &PyAcquire_Type) +# define PyAcquireFile_Check(op) PyObject_TypeCheck(op, &PyAcquireFile_Type) +# define PyAcquireItem_Check(op) PyObject_TypeCheck(op, &PyAcquireItem_Type) +# define PyActionGroup_Check(op) PyObject_TypeCheck(op, &PyActionGroup_Type) +# define PyCache_Check(op) PyObject_TypeCheck(op, &PyCache_Type) +# define PyCacheFile_Check(op) PyObject_TypeCheck(op, &PyCacheFile_Type) +# define PyCdrom_Check(op) PyObject_TypeCheck(op, &PyCdrom_Type) +# define PyConfiguration_Check(op) PyObject_TypeCheck(op, &PyConfiguration_Type) +# define PyDepCache_Check(op) PyObject_TypeCheck(op, &PyDepCache_Type) +# define PyDependency_Check(op) PyObject_TypeCheck(op, &PyDependency_Type) +# define PyDependencyList_Check(op) PyObject_TypeCheck(op, &PyDependencyList_Type) +# define PyDescription_Check(op) PyObject_TypeCheck(op, &PyDescription_Type) +# define PyHashes_Check(op) PyObject_TypeCheck(op, &PyHashes_Type) +# define PyHashString_Check(op) PyObject_TypeCheck(op, &PyHashString_Type) +# define PyIndexRecords_Check(op) PyObject_TypeCheck(op, &PyIndexRecords_Type) +# define PyMetaIndex_Check(op) PyObject_TypeCheck(op, &PyMetaIndex_Type) +# define PyPackage_Check(op) PyObject_TypeCheck(op, &PyPackage_Type) +# define PyPackageFile_Check(op) PyObject_TypeCheck(op, &PyPackageFile_Type) +# define PyPackageIndexFile_Check(op) PyObject_TypeCheck(op, &PyPackageIndexFile_Type) +# define PyPackageList_Check(op) PyObject_TypeCheck(op, &PyPackageList_Type) +# define PyPackageManager_Check(op) PyObject_TypeCheck(op, &PyPackageManager_Type) +# define PyPackageRecords_Check(op) PyObject_TypeCheck(op, &PyPackageRecords_Type) +# define PyPolicy_Check(op) PyObject_TypeCheck(op, &PyPolicy_Type) +# define PyProblemResolver_Check(op) PyObject_TypeCheck(op, &PyProblemResolver_Type) +# define PySourceList_Check(op) PyObject_TypeCheck(op, &PySourceList_Type) +# define PySourceRecords_Check(op) PyObject_TypeCheck(op, &PySourceRecords_Type) +# define PyTagFile_Check(op) PyObject_TypeCheck(op, &PyTagFile_Type) +# define PyTagSection_Check(op) PyObject_TypeCheck(op, &PyTagSection_Type) +# define PyVersion_Check(op) PyObject_TypeCheck(op, &PyVersion_Type) +// Exact check macros. +# define PyAcquire_CheckExact(op) (Py_TYPE(op) == &PyAcquire_Type) +# define PyAcquireFile_CheckExact(op) (Py_TYPE(op) == &PyAcquireFile_Type) +# define PyAcquireItem_CheckExact(op) (Py_TYPE(op) == &PyAcquireItem_Type) +# define PyActionGroup_CheckExact(op) (Py_TYPE(op) == &PyActionGroup_Type) +# define PyCache_CheckExact(op) (Py_TYPE(op) == &PyCache_Type) +# define PyCacheFile_CheckExact(op) (Py_TYPE(op) == &PyCacheFile_Type) +# define PyCdrom_CheckExact(op) (Py_TYPE(op) == &PyCdrom_Type) +# define PyConfiguration_CheckExact(op) (Py_TYPE(op) == &PyConfiguration_Type) +# define PyDepCache_CheckExact(op) (Py_TYPE(op) == &PyDepCache_Type) +# define PyDependency_CheckExact(op) (Py_TYPE(op) == &PyDependency_Type) +# define PyDependencyList_CheckExact(op) (Py_TYPE(op) == &PyDependencyList_Type) +# define PyDescription_CheckExact(op) (Py_TYPE(op) == &PyDescription_Type) +# define PyHashes_CheckExact(op) (Py_TYPE(op) == &PyHashes_Type) +# define PyHashString_CheckExact(op) (Py_TYPE(op) == &PyHashString_Type) +# define PyIndexRecords_CheckExact(op) (Py_TYPE(op) == &PyIndexRecords_Type) +# define PyMetaIndex_CheckExact(op) (Py_TYPE(op) == &PyMetaIndex_Type) +# define PyPackage_CheckExact(op) (Py_TYPE(op) == &PyPackage_Type) +# define PyPackageFile_CheckExact(op) (Py_TYPE(op) == &PyPackageFile_Type) +# define PyPackageIndexFile_CheckExact(op) (Py_TYPE(op) == &PyPackageIndexFile_Type) +# define PyPackageList_CheckExact(op) (Py_TYPE(op) == &PyPackageList_Type) +# define PyPackageManager_CheckExact(op) (Py_TYPE(op) == &PyPackageManager_Type) +# define PyPackageRecords_CheckExact(op) (Py_TYPE(op) == &PyPackageRecords_Type) +# define PyPolicy_CheckExact(op) (Py_TYPE(op) == &PyPolicy_Type) +# define PyProblemResolver_CheckExact(op) (Py_TYPE(op) == &PyProblemResolver_Type) +# define PySourceList_CheckExact(op) (Py_TYPE(op) == &PySourceList_Type) +# define PySourceRecords_CheckExact(op) (Py_TYPE(op) == &PySourceRecords_Type) +# define PyTagFile_CheckExact(op) (Py_TYPE(op) == &PyTagFile_Type) +# define PyTagSection_CheckExact(op) (Py_TYPE(op) == &PyTagSection_Type) +# define PyVersion_CheckExact(op) (Py_TYPE(op) == &PyVersion_Type) + +// Get the underlying C++ reference or pointer from the Python object. +# define PyAcquire_ToCpp GetCpp +# define PyAcquireFile_ToCpp GetCpp +# define PyAcquireItem_ToCpp GetCpp +# define PyActionGroup_ToCpp GetCpp +# define PyCache_ToCpp GetCpp +# define PyCacheFile_ToCpp GetCpp +# define PyCdrom_ToCpp GetCpp +# define PyConfiguration_ToCpp GetCpp +# define PyDepCache_ToCpp GetCpp +# define PyDependency_ToCpp GetCpp +//# define PyDependencyList_ToCpp GetCpp // NOT EXPORTED +# define PyDescription_ToCpp GetCpp +# define PyHashes_ToCpp GetCpp +# define PyHashString_ToCpp GetCpp +# define PyIndexRecords_ToCpp GetCpp +# define PyMetaIndex_ToCpp GetCpp +# define PyPackage_ToCpp GetCpp +# define PyPackageFile_ToCpp GetCpp +# define PyPackageIndexFile_ToCpp GetCpp +//# define PyPackageList_ToCpp GetCpp // NOT EXPORTED. +# define PyPackageManager_ToCpp GetCpp +//# define PyPackageRecords_ToCpp GetCpp // NOT EXPORTED +# define PyPolicy_ToCpp GetCpp +# define PyProblemResolver_ToCpp GetCpp +# define PySourceList_ToCpp GetCpp +//# define PySourceRecords_ToCpp GetCpp // NOT EXPORTED +# define PyTagFile_ToCpp GetCpp +# define PyTagSection_ToCpp GetCpp +# define PyVersion_ToCpp GetCpp + +// Python object creation, using two inline template functions and one variadic +// macro per type. +template +inline PyObject *FromCpp(PyTypeObject *pytype, Cpp obj, bool Delete=false) +{ + CppPyObject *Obj = CppPyObject_NEW(pytype, obj); + Obj->NoDelete = (!Delete); + return Obj; +} + +template +inline PyObject *FromCppOwned(PyTypeObject *pytype, Cpp const &obj, + bool Delete=false, PyObject *Owner=NULL) +{ + CppOwnedPyObject *Obj = CppOwnedPyObject_NEW(Owner, pytype, obj); + Obj->NoDelete = (!Delete); + return Obj; +} + +# define PyAcquire_FromCpp(...) FromCpp(&PyAcquire_Type, ##__VA_ARGS__) +# define PyAcquireFile_FromCpp(...) FromCppOwned(&PyAcquireFile_Type, ##__VA_ARGS__) +# define PyAcquireItem_FromCpp(...) FromCppOwned(&PyAcquireItemType,##__VA_ARGS__) +# define PyActionGroup_FromCpp(...) FromCppOwned(&PyActionGroup_Type,##__VA_ARGS__) +# define PyCache_FromCpp(...) FromCppOwned(&PyCache_Type,##__VA_ARGS__) +# define PyCacheFile_FromCpp(...) FromCpp(&PyCacheFile_Type,##__VA_ARGS__) +# define PyCdrom_FromCpp(...) FromCpp(&PyCdromType,##__VA_ARGS__) +# define PyConfiguration_FromCpp(...) FromCppOwned(&PyConfiguration_Type, ##__VA_ARGS__) +# define PyDepCache_FromCpp(...) FromCppOwned(&PyDepCache_Type,##__VA_ARGS__) +# define PyDependency_FromCpp(...) FromCppOwned(&PyDependency_Type,##__VA_ARGS__) +//# define PyDependencyList_FromCpp(...) FromCppOwned(&PyDependencyList_Type,##__VA_ARGS__) +# define PyDescription_FromCpp(...) FromCppOwned(&PyDescription_Type,##__VA_ARGS__) +# define PyHashes_FromCpp(...) FromCpp(&PyHashes_Type,##__VA_ARGS__) +# define PyHashString_FromCpp(...) FromCpp(&PyHashString_Type,##__VA_ARGS__) +# define PyIndexRecords_FromCpp(...) FromCpp(&PyIndexRecords_Type,##__VA_ARGS__) +# define PyMetaIndex_FromCpp(...) FromCppOwned(&PyMetaIndex_Type,##__VA_ARGS__) +# define PyPackage_FromCpp(...) FromCppOwned(&PyPackage_Type,##__VA_ARGS__) +# define PyPackageIndexFile_FromCpp(...) FromCppOwned(&PyPackageIndexFile_Type,##__VA_ARGS__) +# define PyPackageFile_FromCpp(...) FromCppOwned(&PyPackageFile_Type,##__VA_ARGS__) +//# define PyPackageList_FromCpp(...) FromCppOwned(&PyPackageList_Type,##__VA_ARGS__) +# define PyPackageManager_FromCpp(...) FromCpp(&PyPackageManagerType,##__VA_ARGS__) +//# define PyPackageRecords_FromCpp(...) FromCppOwned(&PyPackageRecords_Type,##__VA_ARGS__) +# define PyPolicy_FromCpp(...) FromCppOwned(&PyPolicy_Type,##__VA_ARGS__) +# define PyProblemResolver_FromCpp(...) FromCppOwned(&PyProblemResolver_Type,##__VA_ARGS__) +# define PySourceList_FromCpp(...) FromCpp(&PySourceList_Type,##__VA_ARGS__) +//# define PySourceRecords_FromCpp(...) FromCpp(&PySourceRecords_Type,##__VA_ARGS__) +//# define PyTagFile_FromCpp(...) FromCppOwned(&PyTagFile_Type,##__VA_ARGS__) +# define PyTagSection_FromCpp(...) FromCppOwned(&PyTagSection_Type,##__VA_ARGS__) +# define PyVersion_FromCpp(...) FromCppOwned(&PyVersion_Type,##__VA_ARGS__) +#endif -- cgit v1.2.3 From acf567325e793ab37292c21e6b4c0713d92ee9a1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Jul 2009 14:32:40 +0200 Subject: Upgrade to debhelper 7 and remove debian/tmp in python-apt.install, to work around a bug in debhelper. --- debian/changelog | 2 ++ debian/compat | 2 +- debian/control | 2 +- debian/python-apt.install | 6 +++--- 4 files changed, 7 insertions(+), 5 deletions(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 415ebdd2..8c1b0e67 100644 --- a/debian/changelog +++ b/debian/changelog @@ -35,6 +35,8 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Make AcquireItem objects raise ValueError instead of segfaulting when the Acquire() object is shut down or the main object (e.g. AcquireFile) is deallocated. * Unify all Configuration,ConfigurationPtr,ConfigurationSub into one type. + * Upgrade to debhelper 7 and remove debian/tmp in python-apt.install, to + work around a bug in debhelper. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/debian/compat b/debian/compat index 7ed6ff82..7f8f011e 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -5 +7 diff --git a/debian/control b/debian/control index a16ae10e..78c55126 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.8.2 XS-Python-Version: all Build-Depends: apt-utils, cdbs, - debhelper (>= 5.0.37.1), + debhelper (>= 7), libapt-pkg-dev (>= 0.7.22~), python-all-dbg, python-all-dev, diff --git a/debian/python-apt.install b/debian/python-apt.install index 4910e8ed..efd54743 100644 --- a/debian/python-apt.install +++ b/debian/python-apt.install @@ -1,3 +1,3 @@ -debian/tmp/usr/lib/python* -debian/tmp/usr/share/locale -debian/tmp/usr/share/python-apt +usr/lib/python* +usr/share/locale +usr/share/python-apt -- cgit v1.2.3 From 270a8f2e01e6f961e7501f3cefb64d2bf8f70069 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Jul 2009 14:58:35 +0200 Subject: Build-Depend on python-all-dev (>= 2.5.4-3), so we build for Python 2.6 --- debian/changelog | 3 ++- debian/control | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 8c1b0e67..70157470 100644 --- a/debian/changelog +++ b/debian/changelog @@ -37,6 +37,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Unify all Configuration,ConfigurationPtr,ConfigurationSub into one type. * Upgrade to debhelper 7 and remove debian/tmp in python-apt.install, to work around a bug in debhelper. + * Build-Depend on python-all-dev (>= 2.5.4-3), so we build for Python 2.6 [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -52,7 +53,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Tue, 14 Jul 2009 20:42:03 +0200 + -- Julian Andres Klode Wed, 15 Jul 2009 14:56:24 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/debian/control b/debian/control index 78c55126..897ef3de 100644 --- a/debian/control +++ b/debian/control @@ -9,8 +9,8 @@ Build-Depends: apt-utils, cdbs, debhelper (>= 7), libapt-pkg-dev (>= 0.7.22~), - python-all-dbg, - python-all-dev, + python-all-dbg (>= 2.5.4-3), + python-all-dev (>= 2.5.4-3), python3.1-dev, python3.1-dbg, python-central (>= 0.5), -- cgit v1.2.3 From 57ce95170dc181c26633036f7c2adfd1c83192bf Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Jul 2009 15:21:38 +0200 Subject: debian/rules: Add --install-layout=deb, debian/control: XS-Python-Version >= 2.5 --- debian/control | 2 +- debian/rules | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'debian/control') diff --git a/debian/control b/debian/control index 897ef3de..9e0fe3ea 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.2 -XS-Python-Version: all +XS-Python-Version: >= 2.5 Build-Depends: apt-utils, cdbs, debhelper (>= 7), diff --git a/debian/rules b/debian/rules index 7a6ff690..f9b08384 100755 --- a/debian/rules +++ b/debian/rules @@ -17,10 +17,11 @@ PY3K_VERSIONS := $(shell find /usr/bin/python3.? | sed s/.*python//) PKG=python-apt DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') DEB_COMPRESS_EXCLUDE:=.html .js _static/* _sources/* _sources/*/* .inv +DEB_PYTHON_INSTALL_ARGS_ALL=--no-compile --install-layout=deb DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS) # Define COMPAT_0_7 to get all the deprecated interfaces. -export CFLAGS+=-DCOMPAT_0_7 +export CFLAGS+=-DCOMPAT_0_7 -Wno-write-strings export DEBVER build/python-apt:: -- cgit v1.2.3 From 7581c5fb8a8d8e1e0a79c343cbd23725475f846c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Jul 2009 17:02:34 +0200 Subject: Simplify the whole building, build all Python versions with setup.py --- debian/changelog | 1 + debian/control | 4 +-- debian/python-apt.doc-base | 3 -- debian/python-apt.docs | 3 +- debian/rules | 35 +++------------------ po/python-apt.pot | 2 +- python/makefile | 27 ---------------- setup.py | 73 ++++++++++++++++++++----------------------- setup3.py | 77 ---------------------------------------------- 9 files changed, 43 insertions(+), 182 deletions(-) delete mode 100644 python/makefile mode change 100755 => 100644 setup.py delete mode 100644 setup3.py (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 70157470..5e3ec667 100644 --- a/debian/changelog +++ b/debian/changelog @@ -38,6 +38,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Upgrade to debhelper 7 and remove debian/tmp in python-apt.install, to work around a bug in debhelper. * Build-Depend on python-all-dev (>= 2.5.4-3), so we build for Python 2.6 + * Simplify the whole building, build all Python versions with setup.py [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/debian/control b/debian/control index 9e0fe3ea..36a4d8d8 100644 --- a/debian/control +++ b/debian/control @@ -8,13 +8,13 @@ XS-Python-Version: >= 2.5 Build-Depends: apt-utils, cdbs, debhelper (>= 7), - libapt-pkg-dev (>= 0.7.22~), + libapt-pkg-dev (>= 0.7.12~), python-all-dbg (>= 2.5.4-3), python-all-dev (>= 2.5.4-3), python3.1-dev, python3.1-dbg, python-central (>= 0.5), - python-distutils-extra (>= 1.9.0), + python-distutils-extra (>= 2.0), python-gtk2, python-sphinx (>= 0.5), python-vte diff --git a/debian/python-apt.doc-base b/debian/python-apt.doc-base index d25926b7..e9b2040c 100644 --- a/debian/python-apt.doc-base +++ b/debian/python-apt.doc-base @@ -6,6 +6,3 @@ Section: Programming/Python Format: HTML Index: /usr/share/doc/python-apt/html/index.html Files: /usr/share/doc/python-apt/html/* - -Format: Text -Files: /usr/share/doc/python-apt/text/* diff --git a/debian/python-apt.docs b/debian/python-apt.docs index 6ba083f5..29219341 100644 --- a/debian/python-apt.docs +++ b/debian/python-apt.docs @@ -1,5 +1,4 @@ README apt/README.apt data/templates/README.templates -build/doc/html/ -build/doc/text/ +build/sphinx/html/ diff --git a/debian/rules b/debian/rules index f9b08384..967da911 100755 --- a/debian/rules +++ b/debian/rules @@ -11,56 +11,29 @@ DEB_PYTHON_PACKAGES_EXCLUDE=python-apt-dbg include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk -PY3K_VERSIONS := $(shell find /usr/bin/python3.? | sed s/.*python//) -2TO3_VERSION := $(lastword $(PY3K_VERSIONS)) +# Add python3 versions to the list of python versions +cdbs_python_build_versions += $(shell find /usr/bin/python3.? | sed s/.*python//) + -PKG=python-apt DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') DEB_COMPRESS_EXCLUDE:=.html .js _static/* _sources/* _sources/*/* .inv DEB_PYTHON_INSTALL_ARGS_ALL=--no-compile --install-layout=deb -DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS) # Define COMPAT_0_7 to get all the deprecated interfaces. export CFLAGS+=-DCOMPAT_0_7 -Wno-write-strings export DEBVER -build/python-apt:: - set -e; for i in $(PY3K_VERSIONS); do \ - python$$i setup3.py build; \ - done - -install/python-apt:: - set -e; for i in $(PY3K_VERSIONS); do \ - python$$i ./setup3.py install --root $(CURDIR)/debian/python-apt \ - --install-layout=deb --no-compile; \ - done - -ifneq ($(PY3K_VERSIONS),) - find $(CURDIR)/debian/python-apt/usr/lib/python3*/dist-packages/ -name '*.py' \ - | xargs 2to3-$(2TO3_VERSION)| patch -p0 -endif - build/python-apt-dbg:: set -e; \ for i in $(cdbs_python_build_versions); do \ python$$i-dbg ./setup.py build; \ done - set -e; for i in $(PY3K_VERSIONS); do \ - python$$i-dbg setup3.py build; \ - done - install/python-apt-dbg:: for i in $(cdbs_python_build_versions); do \ python$$i-dbg ./setup.py install --root $(CURDIR)/debian/python-apt-dbg \ - --no-compile; \ + $(DEB_PYTHON_INSTALL_ARGS_ALL); \ done - - set -e; for i in $(PY3K_VERSIONS); do \ - python$$i-dbg ./setup3.py install --root $(CURDIR)/debian/python-apt-dbg \ - --install-layout=deb --no-compile; \ - done - find debian/python-apt-dbg \ ! -type d ! -name '*_d.so' | xargs rm -f find debian/python-apt-dbg -depth -empty -exec rmdir {} \; diff --git a/po/python-apt.pot b/po/python-apt.pot index 3f4fbb6b..3becb5e1 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 15:17+0200\n" +"POT-Creation-Date: 2009-07-15 16:51+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/makefile b/python/makefile deleted file mode 100644 index fff3a2e8..00000000 --- a/python/makefile +++ /dev/null @@ -1,27 +0,0 @@ -# -*- make -*- -BASE=.. -SUBDIR=python - -# Bring in the default rules -include ../buildlib/defaults.mak - -# The apt_pkg module -MODULE=apt_pkg -SLIBS = -lapt-pkg -LIB_MAKES = apt-pkg/makefile -APT_PKG_SRC = apt_pkgmodule.cc configuration.cc generic.cc tag.cc string.cc \ - cache.cc pkgrecords.cc pkgsrcrecords.cc sourcelist.cc \ - depcache.cc progress.cc cdrom.cc acquire.cc pkgmanager.cc \ - indexfile.cc metaindex.cc hashstring.cc indexrecords.cc \ - policy.cc hashes.cc -SOURCE := $(APT_PKG_SRC) -include $(PYTHON_H) progress.h - -# The apt_int module.. -MODULE=apt_inst -SLIBS = -lapt-inst -lapt-pkg -LIB_MAKES = apt-inst/makefile -APT_INST_SRC = apt_instmodule.cc tar.cc generic.cc -SOURCE := $(APT_INST_SRC) -include $(PYTHON_H) - diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 index 85f4c889..77853a4e --- a/setup.py +++ b/setup.py @@ -1,50 +1,59 @@ -#! /usr/bin/env python +#!/usr/bin/python +# Builds on python2.X and python3 # $Id: setup.py,v 1.2 2002/01/08 07:13:21 jgg Exp $ import glob import os -import shutil import sys from distutils.core import setup, Extension -from distutils.sysconfig import parse_makefile -from DistUtilsExtra.command import build_extra, build_i18n +cmdclass = {} +try: + from DistUtilsExtra.command import build_extra, build_i18n + from DistUtilsExtra.auto import clean_build_tree + cmdclass['build'] = build_extra.build_extra + cmdclass['build_i18n'] = build_i18n.build_i18n + cmdclass['clean'] = clean_build_tree + build_extra.build_extra.sub_commands.append(("build_sphinx", + lambda x: 'build_sphinx' in cmdclass)) +except ImportError: + print('W: [python%s] DistUtilsExtra import error.' % sys.version[:3]) -# The apt_pkg module -files = map(lambda source: "python/"+source, - sorted(parse_makefile("python/makefile")["APT_PKG_SRC"].split())) +try: + from sphinx.setup_command import BuildDoc + cmdclass['build_sphinx'] = BuildDoc +except ImportError: + print('W: [python%s] Sphinx import error.' % sys.version[:3]) + +if sys.version_info[0] == 3: + from distutils.command.build_py import build_py_2to3 + cmdclass['build_py'] = build_py_2to3 + +# The apt_pkg module. +files = ['apt_pkgmodule.cc', 'acquire.cc', 'cache.cc', 'cdrom.cc', + 'configuration.c', 'depcache.cc', 'generic.cc', 'hashes.cc', + 'hashstring.cc', 'indexfile.cc', 'indexrecords.cc', 'metaindex.cc', + 'pkgmanager.cc', 'pkgrecords.cc', 'pkgsrcrecords.cc', 'policy.cc', + 'progress.cc', 'sourcelist.cc', 'string.cc', 'tag.cc'] +files = ['python/' + fname for fname in files] apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) # The apt_inst module -files = map(lambda source: "python/"+source, - sorted(parse_makefile("python/makefile")["APT_INST_SRC"].split())) +files = ["python/apt_instmodule.cc", "python/generic.cc", "python/tar.cc"] apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) # Replace the leading _ that is used in the templates for translation -templates = [] - -# build doc if len(sys.argv) > 1 and sys.argv[1] == "build": if not os.path.exists("build/data/templates/"): os.makedirs("build/data/templates") for template in glob.glob('data/templates/*.info.in'): source = open(template, "r") - build = open(os.path.join("build", template[:-3]), "w") - lines = source.readlines() - for line in lines: + build = open("build/" + template[:-3], "w") + for line in source: build.write(line.lstrip("_")) source.close() build.close() - -if len(sys.argv) > 1 and sys.argv[1] == "clean" and '-a' in sys.argv: - for dirname in "build/doc", "doc/build", "build/data", "build/mo": - if os.path.exists(dirname): - print "Removing", dirname - shutil.rmtree(dirname) - else: - print "Not removing", dirname, "because it does not exist" - setup(name="python-apt", description="Python bindings for APT", version=os.environ.get('DEBVER'), @@ -56,20 +65,6 @@ setup(name="python-apt", glob.glob('build/data/templates/*.info')), ('share/python-apt/templates', glob.glob('data/templates/*.mirrors'))], - cmdclass = {"build": build_extra.build_extra, - "build_i18n": build_i18n.build_i18n}, + cmdclass = cmdclass, license = 'GNU GPL', platforms = 'posix') - -if len(sys.argv) > 1 and sys.argv[1] == "build": - import sphinx - try: - import pygtk - except ImportError: - print >> sys.stderr, ('W: Not building documentation because python-' - 'gtk2 is not available at the moment.') - sys.exit(0) - sphinx.main(["sphinx", "-b", "html", "-d", "build/doc/doctrees", - os.path.abspath("doc/source"), "build/doc/html"]) - sphinx.main(["sphinx", "-b", "text", "-d", "build/doc/doctrees", - os.path.abspath("doc/source"), "build/doc/text"]) diff --git a/setup3.py b/setup3.py deleted file mode 100644 index a3cbdc8e..00000000 --- a/setup3.py +++ /dev/null @@ -1,77 +0,0 @@ -#! /usr/bin/env python3 -# $Id: setup.py,v 1.2 2002/01/08 07:13:21 jgg Exp $ -import glob -import os -import shutil -import sys - -from distutils.core import setup, Extension -from distutils.sysconfig import parse_makefile -#from DistUtilsExtra.command import build_extra, build_i18n - - -# The apt_pkg module -files = ["python/"+source for source in parse_makefile("python/makefile")["APT_PKG_SRC"].split()] -apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) - -# The apt_inst module -files = ["python/"+source for source in parse_makefile("python/makefile")["APT_INST_SRC"].split()] -apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) - -# Replace the leading _ that is used in the templates for translation -templates = [] - -# build doc -if len(sys.argv) > 1 and sys.argv[1] == "build": - if not os.path.exists("build/data/templates/"): - os.makedirs("build/data/templates") - for template in glob.glob('data/templates/*.info.in'): - source = open(template, "r") - build = open(os.path.join("build", template[:-3]), "w") - lines = source.readlines() - for line in lines: - build.write(line.lstrip("_")) - source.close() - build.close() - - -if len(sys.argv) > 1 and sys.argv[1] == "clean" and '-a' in sys.argv: - for dirname in "build/doc", "doc/build", "build/data", "build/mo": - if os.path.exists(dirname): - print("Removing", dirname) - shutil.rmtree(dirname) - else: - print("Not removing", dirname, "because it does not exist") - -setup(name="python-apt", - description="Python bindings for APT", - version=os.environ.get('DEBVER'), - author="APT Development Team", - author_email="deity@lists.debian.org", - ext_modules=[apt_pkg, apt_inst], - packages=['apt', 'apt.progress', 'aptsources'], - data_files = [('share/python-apt/templates', - glob.glob('build/data/templates/*.info')), - ('share/python-apt/templates', - glob.glob('data/templates/*.mirrors'))], -# cmdclass = {"build": build_extra.build_extra, -# "build_i18n": build_i18n.build_i18n}, - license = 'GNU GPL', - platforms = 'posix') - -if len(sys.argv) > 1 and sys.argv[1] == "build": - try: - import sphinx - except ImportError: - print(('W: Sphinx not available - Not building' - 'documentation'), file=sys.stderr) - try: - import pygtk - except ImportError: - print(('W: Not building documentation because python-' - 'gtk2 is not available at the moment.'), file=sys.stderr) - sys.exit(0) - sphinx.main(["sphinx", "-b", "html", "-d", "build/doc/doctrees", - os.path.abspath("doc/source"), "build/doc/html"]) - sphinx.main(["sphinx", "-b", "text", "-d", "build/doc/doctrees", - os.path.abspath("doc/source"), "build/doc/text"]) -- cgit v1.2.3 From 4112520954a16ebbfdf7511670e68668e5a07173 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 30 Jul 2009 20:38:03 +0200 Subject: debian/control: Add 3.1 to XS-Python-Version. --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debian/control') diff --git a/debian/control b/debian/control index 7c3bfaac..9a8d16a2 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.2 -XS-Python-Version: >= 2.5 +XS-Python-Version: >= 2.5, 3.1 Build-Depends: apt-utils, debhelper (>= 7.3.5), libapt-pkg-dev (>= 0.7.22~), -- cgit v1.2.3 From ebe1f37a65cae8303bf86da13f3f2107cd73d1fe Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 30 Jul 2009 20:59:49 +0200 Subject: debian/control: Explicitly specify the versions to build for. --- debian/control | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'debian/control') diff --git a/debian/control b/debian/control index 9a8d16a2..69bca37a 100644 --- a/debian/control +++ b/debian/control @@ -4,12 +4,14 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.2 -XS-Python-Version: >= 2.5, 3.1 +XS-Python-Version: 2.5, 2.6, 3.1 Build-Depends: apt-utils, debhelper (>= 7.3.5), libapt-pkg-dev (>= 0.7.22~), - python-all-dbg (>= 2.5.4-3), - python-all-dev (>= 2.5.4-3), + python2.5-dbg, + python2.5-dev, + python2.6-dev, + python2.6-dbg, python3.1-dev, python3.1-dbg, python-central (>= 0.5), -- cgit v1.2.3 From 08674e660118758f32d220a26b4a525459317293 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 2 Aug 2009 18:23:28 +0200 Subject: Only recommend lsb-release instead of depending on it. Default to Debian unstable if lsb_release is not available. --- aptsources/distinfo.py | 13 +++++++++---- aptsources/distro.py | 25 +++++++++++++++++++------ debian/changelog | 4 +++- debian/control | 4 ++-- 4 files changed, 33 insertions(+), 13 deletions(-) (limited to 'debian/control') diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index 2e5fd7bc..0614bd1c 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -21,9 +21,11 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +import errno import os import gettext from os import getenv +from subprocess import Popen, PIPE import ConfigParser import re @@ -160,10 +162,13 @@ class DistInfo: #match_mirror_line = re.compile(r".+") if not dist: - pipe = os.popen("lsb_release -i -s") - dist = pipe.read().strip() - pipe.close() - del pipe + try: + dist = Popen(["lsb_release", "-i", "-s"], + stdout=PIPE).communicate()[0].strip() + except OSError, exc: + if exc.errno != errno.ENOENT: + print 'WARNING: lsb_release failed, using defaults:', exc + dist = "Debian" self.dist = dist diff --git a/aptsources/distro.py b/aptsources/distro.py index 5398d4a3..2cbad9fb 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -437,6 +437,20 @@ class UbuntuDistribution(Distribution): Distribution.get_mirrors( self, mirror_template="http://%s.archive.ubuntu.com/ubuntu/") +def _lsb_release(): + """Call lsb_release --all and return a mapping.""" + from subprocess import Popen, PIPE + import errno + result = {'Codename': 'sid', 'Distributor ID': 'Debian', + 'Description': 'Debian GNU/Linux unstable (sid)', + 'Release': 'unstable'} + try: + out = Popen(['lsb_release', '--all'], stdout=PIPE).communicate()[0] + result.update(l.split(":\t") for l in out.split("\n") if ':\t' in l) + except OSError, exc: + if exc.errno != errno.ENOENT: + print 'WARNING: lsb_release failed, using defaults:', exc + return result def get_distro(id=None, codename=None, description=None, release=None): """ @@ -448,12 +462,11 @@ def get_distro(id=None, codename=None, description=None, release=None): """ # make testing easier if not (id and codename and description and release): - lsb_info = [] - for lsb_option in ["-i", "-c", "-d", "-r"]: - pipe = os.popen("lsb_release %s -s" % lsb_option) - lsb_info.append(pipe.read().strip()) - del pipe - (id, codename, description, release) = lsb_info + result = _lsb_release() + id = result['Distributor ID'] + codename = result['Codename'] + description = result['Description'] + release = result['Release'] if id == "Ubuntu": return UbuntuDistribution(id, codename, description, release) elif id == "Debian": diff --git a/debian/changelog b/debian/changelog index 928493ad..5f1f2967 100644 --- a/debian/changelog +++ b/debian/changelog @@ -32,8 +32,10 @@ python-apt (0.7.92) UNRELEASED; urgency=low - Merge Configuration,ConfigurationPtr,ConfigurationSub into one type. - Simplify the whole build process by using a single setup.py. - The documentation has been restructured and enhanced with tutorials. + - Only recommend lsb-release instead of depending on it. Default to + Debian unstable if lsb_release is not available. - -- Julian Andres Klode Wed, 15 Jul 2009 14:56:24 +0200 + -- Julian Andres Klode Sun, 02 Aug 2009 16:35:42 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/debian/control b/debian/control index 69bca37a..6b96a6be 100644 --- a/debian/control +++ b/debian/control @@ -24,8 +24,8 @@ Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes Package: python-apt Architecture: any -Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, lsb-release -Recommends: iso-codes, libjs-jquery +Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} +Recommends: lsb-release, iso-codes, libjs-jquery Breaks: debdelta (<< 0.28~) Provides: ${python:Provides} Suggests: python-apt-dbg, python-gtk2, python-vte -- cgit v1.2.3 From 28f42c1060c652e6f650ba4e046e3f8ab021d91b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 15 Jan 2010 15:25:10 +0100 Subject: * Build for all supported Python versions. - Disable 2.6 and 3.1 builds previously available in experimental. --- debian/changelog | 4 +++- debian/control | 10 +++------- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 532a7de7..450492c4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ python-apt (0.7.93) UNRELEASED; urgency=low * Merge debian-sid and debian-experimental. * Add a tutorial on how to do things which are possible with apt-get, like apt-get --print-uris update (cf. #551164). + * Build for all supported Python versions. + - Disable 2.6 and 3.1 builds previously available in experimental. [ Colin Watson ] * apt/progress/__init__.py: @@ -25,7 +27,7 @@ python-apt (0.7.93) UNRELEASED; urgency=low * doc/source/apt_pkg/{cache.rst, index.rst}: - update documentation as well - -- Julian Andres Klode Wed, 16 Sep 2009 19:26:17 +0200 + -- Julian Andres Klode Fri, 15 Jan 2010 15:24:16 +0100 python-apt (0.7.92) experimental; urgency=low diff --git a/debian/control b/debian/control index c5508e9b..afece43c 100644 --- a/debian/control +++ b/debian/control @@ -4,16 +4,12 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.3 -XS-Python-Version: 2.5, 2.6, 3.1 +XS-Python-Version: all Build-Depends: apt-utils, debhelper (>= 7.3.5), libapt-pkg-dev (>= 0.7.22~), - python2.5-dbg, - python2.5-dev, - python2.6-dev, - python2.6-dbg, - python3.1-dev, - python3.1-dbg, + python-all-dbg, + python-all-dev, python-central (>= 0.5), python-distutils-extra (>= 2.0), python-gtk2 [!kfreebsd-amd64 !kfreebsd-i386], -- cgit v1.2.3 From 5b348d4e1c0377eb1086cdaf05b20b860a1467eb Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 15 Jan 2010 15:43:53 +0100 Subject: Build for all supported Python versions newer than 2.5. --- debian/changelog | 2 +- debian/control | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index acd9c3ca..e455d2ed 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,7 +4,7 @@ python-apt (0.7.93) UNRELEASED; urgency=low * Merge debian-sid and debian-experimental. * Add a tutorial on how to do things which are possible with apt-get, like apt-get --print-uris update (cf. #551164). - * Build for all supported Python versions. + * Build for all supported Python versions newer than 2.5. - Disable 2.6 and 3.1 builds previously available in experimental. * Merge lp:~forest-bond/python-apt/cache-is-virtual-package-catch-key-error - Return False in Cache.is_virtual_package if the package does not exist. diff --git a/debian/control b/debian/control index afece43c..3554942a 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.3 -XS-Python-Version: all +XS-Python-Version: >= 2.5 Build-Depends: apt-utils, debhelper (>= 7.3.5), libapt-pkg-dev (>= 0.7.22~), -- cgit v1.2.3 From 34b01eb60ec315bc542d0cad7239091219a8388c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 15 Jan 2010 19:09:10 +0100 Subject: Rewrite apt.progress.gtk2 documentation by hand and drop python-gtk2 build-time dependency. --- debian/changelog | 2 + debian/control | 4 +- doc/source/library/apt.progress.gtk2.rst | 128 +++++++++++++++++++++++++++---- 3 files changed, 118 insertions(+), 16 deletions(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 35a949db..c2b8d7e6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ python-apt (0.7.93) UNRELEASED; urgency=low * Merge lp:~forest-bond/python-apt/cache-is-virtual-package-catch-key-error - Return False in Cache.is_virtual_package if the package does not exist. * Make all class-level constants have uppercase names. + * Rewrite apt.progress.gtk2 documentation by hand and drop python-gtk2 + build-time dependency. [ Colin Watson ] * apt/progress/__init__.py: diff --git a/debian/control b/debian/control index 3554942a..294deb1a 100644 --- a/debian/control +++ b/debian/control @@ -12,9 +12,7 @@ Build-Depends: apt-utils, python-all-dev, python-central (>= 0.5), python-distutils-extra (>= 2.0), - python-gtk2 [!kfreebsd-amd64 !kfreebsd-i386], - python-sphinx (>= 0.5), - python-vte [!kfreebsd-amd64 !kfreebsd-i386] + python-sphinx (>= 0.5) Vcs-Bzr: http://bzr.debian.org/apt/python-apt/debian-sid Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes diff --git a/doc/source/library/apt.progress.gtk2.rst b/doc/source/library/apt.progress.gtk2.rst index b16c903c..6c00e731 100644 --- a/doc/source/library/apt.progress.gtk2.rst +++ b/doc/source/library/apt.progress.gtk2.rst @@ -1,27 +1,129 @@ :mod:`apt.progress.gtk2` --- Progress reporting for GTK+ interfaces =================================================================== -.. automodule:: apt.progress.gtk2 +.. module:: apt.progress.gtk2 + +The :mod:`apt.progress.gtk2` module provides classes with GObject signals and +a class with a GTK+ widget for progress handling. GObject progress classes ------------------------- +.. class:: GInstallProgress + + An implementation of :class:`apt.progress.base.InstallProgress` supporting + GObject signals. The class emits the following signals: + + .. describe:: status-changed(status: str, percent: int) + + Emitted when the status of an operation changed. + + .. describe:: status-started() + + Emitted when the installation started. + + .. describe:: status-finished() + + Emitted when the installation finished. + + .. describe:: status-timeout() + + Emitted when a timeout happens + + .. describe:: status-error() + + Emitted in case of an error. + + .. describe:: status-conffile() + + Emitted when a conffile update is happening. + + +.. class:: GFetchProgress + + An implementation of :class:`apt.progress.old.FetchProgress` supporting + GObject signals. The class emits the following signals: + + .. describe:: status-changed(description: str, percent: int) + + Emitted when the status of the fetcher changed, e.g. when the + percentage increased. + + .. describe:: status-started() + + Emitted when the fetcher starts to fetch. + + .. describe:: status-finished() + + Emitted when the fetcher finished. + + +.. class:: GDpkgInstallProgress + + An implementation of :class:`apt.progress.base.InstallProgress` supporting + GObject signals. This is the same as :class:`GInstallProgress` and is thus + completely deprecated. + +.. class:: GOpProgress + + An implementation of :class:`apt.progress.old.FetchProgress` supporting + GObject signals. The class emits the following signals: + + .. describe:: status-changed(operation: str, percent: int) + + Emitted when the status of an operation changed. + + .. describe:: status-started() + + Emitted when it starts - Not implemented yet. + + .. describe:: status-finished() + + Emitted when all operations have finished. + +GTK+ Widget +----------- +.. class:: GtkAptProgress + + Graphical progress for installation/fetch/operations, providing + a progress bar, a terminal and a status bar for showing the progress + of package manipulation tasks. + + .. method:: cancel_download() + + Cancel a currently running download. + + .. method:: clear() + + Reset all status information. + + .. attribute:: dpkg_install + + Return the install progress handler for dpkg. + + .. attribute:: fetch + + Return the fetch progress handler. + + .. method:: hide_terminal() -.. autoclass:: GDpkgInstallProgress - :members: + Hide the expander with the terminal widget. -.. autoclass:: GFetchProgress - :members: + .. attribute:: install + + Return the install progress handler. -.. autoclass:: GInstallProgress - :members: + .. attribute:: open -.. autoclass:: GOpProgress - :members: + Return the cache opening progress handler. + + .. method:: show() + + Show the Box -GTK+ Class ----------- -.. autoclass:: GtkAptProgress - :members: + .. method:: show_terminal(expanded=False) + + Show an expander with a terminal widget which provides a way to + interact with dpkg. Example -- cgit v1.2.3 From 008a45f23d6999269f10978c3cb3ac11240451f9 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 17 Jan 2010 12:54:16 +0100 Subject: * Build for Python 2.5, 2.6 and 3.1; 2.6 and 3.1 hit unstable on Jan 16. - Use DH_PYCENTRAL=nomove for now because include-links seems broken --- debian/changelog | 4 ++-- debian/control | 10 +++++++--- debian/rules | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index c2b8d7e6..ba6dbd40 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,8 +4,8 @@ python-apt (0.7.93) UNRELEASED; urgency=low * Merge debian-sid and debian-experimental. * Add a tutorial on how to do things which are possible with apt-get, like apt-get --print-uris update (cf. #551164). - * Build for all supported Python versions newer than 2.5. - - Disable 2.6 and 3.1 builds previously available in experimental. + * Build for Python 2.5, 2.6 and 3.1; 2.6 and 3.1 hit unstable on Jan 16. + - Use DH_PYCENTRAL=nomove for now because include-links seems broken * Merge lp:~forest-bond/python-apt/cache-is-virtual-package-catch-key-error - Return False in Cache.is_virtual_package if the package does not exist. * Make all class-level constants have uppercase names. diff --git a/debian/control b/debian/control index 294deb1a..81fc00ee 100644 --- a/debian/control +++ b/debian/control @@ -4,12 +4,16 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.3 -XS-Python-Version: >= 2.5 +XS-Python-Version: 2.5, 2.6, 3.1 Build-Depends: apt-utils, debhelper (>= 7.3.5), libapt-pkg-dev (>= 0.7.22~), - python-all-dbg, - python-all-dev, + python2.5-dbg, + python2.5-dev, + python2.6-dev, + python2.6-dbg, + python3.1-dev, + python3.1-dbg, python-central (>= 0.5), python-distutils-extra (>= 2.0), python-sphinx (>= 0.5) diff --git a/debian/rules b/debian/rules index 6c9f6fb6..1a45a710 100755 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,6 @@ #!/usr/bin/make -f -export DH_PYCENTRAL=include-links +# Should be include-links, but that somehow fails. +export DH_PYCENTRAL=nomove export DEBVER=$(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p') export CFLAGS=-Wno-write-strings -DCOMPAT_0_7 -- cgit v1.2.3 From 07442ba7f9449a1a3d1cce0faba8af3954f5e220 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 2 Feb 2010 17:40:04 +0100 Subject: * debian/control: - Make python-apt-dev depend on ${misc:Depends} and recommend python-dev. --- debian/changelog | 2 ++ debian/control | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 368b45c6..7bcc80bf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,8 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low - select.error objects do not have an errno attribute (Closes: #568005) * doc/client-example.cc: Update against the new API. * Fix typo seperated => separated in multiple files (reported by lintian). + * debian/control: + - Make python-apt-dev depend on ${misc:Depends} and recommend python-dev. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/debian/control b/debian/control index 81fc00ee..5ed54dbd 100644 --- a/debian/control +++ b/debian/control @@ -47,6 +47,7 @@ Architecture: any Section: debug Depends: python-dbg, python-apt (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +XB-Python-Version: ${python:Versions} Description: Python interface to libapt-pkg (debug extension) The apt_pkg Python interface will provide full access to the internal libapt-pkg structures allowing Python programs to easily perform a @@ -56,7 +57,9 @@ Description: Python interface to libapt-pkg (debug extension) Package: python-apt-dev Architecture: all -Depends: python-apt (>= ${source:Version}), libapt-pkg-dev (>= 0.7.10) +Depends: python-apt (>= ${source:Version}), libapt-pkg-dev (>= 0.7.10), + ${misc:Depends} +Recommends: python-dev Description: Python interface to libapt-pkg (development files) The apt_pkg Python interface will provide full access to the internal libapt-pkg structures allowing Python programs to easily perform a -- cgit v1.2.3 From 38141fc5f6918c5ae7ac7fd0061ee051c580b255 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 2 Feb 2010 18:01:17 +0100 Subject: debian/control: Set Standards-Version to 3.8.4. --- debian/changelog | 1 + debian/control | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 867b9dab..bba66321 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,6 +28,7 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low * Fix typos of separated in multiple files (reported by lintian). * debian/control: - Make python-apt-dev depend on ${misc:Depends} and recommend python-dev. + - Set Standards-Version to 3.8.4. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/debian/control b/debian/control index 5ed54dbd..0c43f91e 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: python Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode -Standards-Version: 3.8.3 +Standards-Version: 3.8.4 XS-Python-Version: 2.5, 2.6, 3.1 Build-Depends: apt-utils, debhelper (>= 7.3.5), -- cgit v1.2.3 From 1dcd5eb6190ed6a3552cb2d491bc0272f60e613a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 3 Mar 2010 16:44:10 +0100 Subject: * Merge with Ubuntu: - util/get_ubuntu_mirrors_from_lp.py: + rewritten to use +archivemirrors-rss and feedburner - pre-build.sh: update ubuntu mirrors on bzr-buildpackage (and also do this for Debian mirrors) - add break for packagekit-backend-apt (<= 0.4.8-0ubuntu4) --- .bzr-builddeb/default.conf | 3 ++ debian/changelog | 6 ++++ debian/control | 2 +- pre-build.sh | 11 ++++++ utils/get_ubuntu_mirrors_from_lp.py | 72 ++++++++----------------------------- 5 files changed, 35 insertions(+), 59 deletions(-) create mode 100755 pre-build.sh (limited to 'debian/control') diff --git a/.bzr-builddeb/default.conf b/.bzr-builddeb/default.conf index 3a08d607..c39d2e3d 100644 --- a/.bzr-builddeb/default.conf +++ b/.bzr-builddeb/default.conf @@ -1,2 +1,5 @@ [BUILDDEB] native = True + +[HOOKS] +pre-build = ./pre-build.sh diff --git a/debian/changelog b/debian/changelog index 79b3d810..0aab0c2a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,12 @@ python-apt (0.7.93.4) unstable; urgency=low * apt/progress/old.py: - Let the new method call the old one; e.g. status_update() now calls self.statusUpdate(). This improves compatibility for sub classes. + * Merge with Ubuntu: + - util/get_ubuntu_mirrors_from_lp.py: + + rewritten to use +archivemirrors-rss and feedburner + - pre-build.sh: update ubuntu mirrors on bzr-buildpackage (and also do this + for Debian mirrors) + - add break for packagekit-backend-apt (<= 0.4.8-0ubuntu4) -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 diff --git a/debian/control b/debian/control index 0c43f91e..4db6c164 100644 --- a/debian/control +++ b/debian/control @@ -24,7 +24,7 @@ Package: python-apt Architecture: any Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} Recommends: lsb-release, iso-codes, libjs-jquery -Breaks: debdelta (<< 0.28~) +Breaks: debdelta (<< 0.28~), packagekit-backend-apt (<= 0.4.8-0ubuntu4) Provides: ${python:Provides} Suggests: python-apt-dbg, python-gtk2, python-vte XB-Python-Version: ${python:Versions} diff --git a/pre-build.sh b/pre-build.sh new file mode 100755 index 00000000..6d019603 --- /dev/null +++ b/pre-build.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +echo "updating Ubuntu mirror list from launchpad" +if [ -n "$https_proxy" ]; then + echo "disabling https_proxy as Python's urllib doesn't support it; see #94130" + unset https_proxy +fi +utils/get_ubuntu_mirrors_from_lp.py > data/templates/Ubuntu.mirrors + +echo "updating Debian mirror list" +( cd utils; ./get_debian_mirrors.py; ) diff --git a/utils/get_ubuntu_mirrors_from_lp.py b/utils/get_ubuntu_mirrors_from_lp.py index b912f28d..3c183b6d 100755 --- a/utils/get_ubuntu_mirrors_from_lp.py +++ b/utils/get_ubuntu_mirrors_from_lp.py @@ -24,68 +24,24 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -import urllib2 -import re +import feedparser import sys -# the list of official Ubuntu servers -mirrors = [] -# path to the local mirror list -list_path = "../data/templates/Ubuntu.mirrors" - - -try: - f = open("/usr/share/iso-codes/iso_3166.tab", "r") - lines = f.readlines() - f.close() -except: - print "Could not read country information" - sys.exit(1) +d = feedparser.parse("https://launchpad.net/ubuntu/+archivemirrors-rss") +#d = feedparser.parse(open("+archivemirrors-rss")) countries = {} -for line in lines: - parts = line.split("\t") - countries[parts[1].strip()] = parts[0].lower() - -req = urllib2.Request("https://launchpad.net/ubuntu/+archivemirrors") -print "Downloading mirrors list from Launchpad..." -try: - uri=urllib2.urlopen(req) - content = uri.read() - uri.close() -except: - print "Failed to download or extract the mirrors list!" - sys.exit(1) - -content = content.replace("\n", "") - -content_splits = re.split(r'.+?', - content)[0]) -lines=[] - - -def find(split): - country = re.search(r"(.+?)", split) - if not country: - return - if country.group(1) in countries: - lines.append("#LOC:%s" % countries[country.group(1)].upper()) - else: - lines.append("#LOC:%s" % country.group(1)) - # FIXME: currently the protocols are hardcoded: ftp http - urls = re.findall(r')' - '(((http)|(ftp)).+?)">', - split) - map(lambda u: lines.append(u[0]), urls) +for entry in d.entries: + countrycode = entry.mirror_countrycode + if not countrycode in countries: + countries[countrycode] = set() + for link in entry.links: + countries[countrycode].add(link.href) -map(find, content_splits) -print "Writing local mirrors list: %s" % list_path -list = open(list_path, "w") -for line in lines: - list.write("%s\n" % line) -list.close() -print "Done." +keys = countries.keys() +keys.sort() +for country in keys: + print "#LOC:%s" % country + print "\n".join(countries[country]) -- cgit v1.2.3 From 72e6ef284a460c497eec3964b0eeddbdf24a4b5a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 10 Mar 2010 15:58:50 +0100 Subject: Move documentation into python-apt-doc (Closes: #572617) --- debian/changelog | 1 + debian/control | 16 ++++++++++++++-- debian/python-apt-doc.doc-base | 8 ++++++++ debian/python-apt-doc.docs | 1 + debian/python-apt.doc-base | 8 -------- debian/python-apt.docs | 1 - debian/rules | 2 +- 7 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 debian/python-apt-doc.doc-base create mode 100644 debian/python-apt-doc.docs delete mode 100644 debian/python-apt.doc-base (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 5c6e6895..b0e6657b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ python-apt (0.7.93.4) unstable; urgency=low + * Move documentation into python-apt-doc (Closes: #572617) * python/acquire-item.cc: - Add AcquireItem.partialsize member. * python/apt_pkgmodule.cc: diff --git a/debian/control b/debian/control index 4db6c164..8e7605e6 100644 --- a/debian/control +++ b/debian/control @@ -23,10 +23,10 @@ Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes Package: python-apt Architecture: any Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} -Recommends: lsb-release, iso-codes, libjs-jquery +Recommends: lsb-release, iso-codes Breaks: debdelta (<< 0.28~), packagekit-backend-apt (<= 0.4.8-0ubuntu4) Provides: ${python:Provides} -Suggests: python-apt-dbg, python-gtk2, python-vte +Suggests: python-apt-dbg, python-gtk2, python-vte, python-apt-doc XB-Python-Version: ${python:Versions} Description: Python interface to libapt-pkg The apt_pkg Python interface will provide full access to the internal @@ -41,6 +41,18 @@ Description: Python interface to libapt-pkg The included 'aptsources' Python interface provides an abstraction of the sources.list configuration on the repository and the distro level. +Package: python-apt-doc +Architecture: all +Section: doc +Depends: libjs-jquery, ${misc:Depends} +Enhances: python-apt +Description: Python interface to libapt-pkg (API documentation) + The apt_pkg Python interface will provide full access to the internal + libapt-pkg structures allowing Python programs to easily perform a + variety of functions. + . + This package contains the API documentation of python-apt. + Package: python-apt-dbg Priority: extra Architecture: any diff --git a/debian/python-apt-doc.doc-base b/debian/python-apt-doc.doc-base new file mode 100644 index 00000000..4f3c4d31 --- /dev/null +++ b/debian/python-apt-doc.doc-base @@ -0,0 +1,8 @@ +Document: python-apt-api-reference +Title: Python APT: API reference manual +Abstract: API reference manual for Python bindings to libapt-pkg +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/python-apt-doc/html/index.html +Files: /usr/share/doc/python-apt-doc/html/* diff --git a/debian/python-apt-doc.docs b/debian/python-apt-doc.docs new file mode 100644 index 00000000..f85adafd --- /dev/null +++ b/debian/python-apt-doc.docs @@ -0,0 +1 @@ +build/sphinx/html/ diff --git a/debian/python-apt.doc-base b/debian/python-apt.doc-base deleted file mode 100644 index e9b2040c..00000000 --- a/debian/python-apt.doc-base +++ /dev/null @@ -1,8 +0,0 @@ -Document: python-apt-api-reference -Title: Python APT: API reference manual -Abstract: API reference manual for Python bindings to libapt-pkg -Section: Programming/Python - -Format: HTML -Index: /usr/share/doc/python-apt/html/index.html -Files: /usr/share/doc/python-apt/html/* diff --git a/debian/python-apt.docs b/debian/python-apt.docs index 1bfc7c1c..a53a1ccc 100644 --- a/debian/python-apt.docs +++ b/debian/python-apt.docs @@ -3,4 +3,3 @@ AUTHORS TODO apt/README.apt data/templates/README.templates -build/sphinx/html/ diff --git a/debian/rules b/debian/rules index 24d0952e..3711080c 100755 --- a/debian/rules +++ b/debian/rules @@ -10,7 +10,7 @@ export CFLAGS=-Wno-write-strings -DCOMPAT_0_7 override_dh_installdocs: dh_installdocs ln -sf ../../../../javascript/jquery/jquery.js \ - debian/python-apt/usr/share/doc/python-apt/html/_static/jquery.js + debian/python-apt-doc/usr/share/doc/python-apt-doc/html/_static/jquery.js rm -rf debian/python-apt-dbg/usr/share/doc/python-apt-dbg ln -s python-apt debian/python-apt-dbg/usr/share/doc/python-apt-dbg -- cgit v1.2.3 From 0cfc2fb37e43dd71f21347e0d490ab89ecbdeaf0 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 10 Mar 2010 16:19:27 +0100 Subject: python-apt-doc replaces files in older python-apt --- debian/control | 1 + 1 file changed, 1 insertion(+) (limited to 'debian/control') diff --git a/debian/control b/debian/control index 8e7605e6..af7aa055 100644 --- a/debian/control +++ b/debian/control @@ -46,6 +46,7 @@ Architecture: all Section: doc Depends: libjs-jquery, ${misc:Depends} Enhances: python-apt +Replaces: python-apt (<< 0.7.94) Description: Python interface to libapt-pkg (API documentation) The apt_pkg Python interface will provide full access to the internal libapt-pkg structures allowing Python programs to easily perform a -- cgit v1.2.3 From 886cf9ab3e38a930f676d97d1e673be8d2ea7883 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Mar 2010 12:41:41 +0100 Subject: recommend python2.6. --- debian/changelog | 2 +- debian/control | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 276e5cc3..6970a7cc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,7 @@ python-apt (0.7.94.1) UNRELEASED; urgency=low * Pass --exclude=migrate-0.8.py to dh_pycentral; in order to not depend - on python2.6. + on python2.6; but recommend python2.6. * Use dh_link instead of ln for python-apt-doc (Closes: #573523). * Pass --link-doc=python-apt to dh_installdocs. * Install examples to python-apt-doc instead of python-apt. diff --git a/debian/control b/debian/control index af7aa055..3785e5d5 100644 --- a/debian/control +++ b/debian/control @@ -23,7 +23,7 @@ Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes Package: python-apt Architecture: any Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} -Recommends: lsb-release, iso-codes +Recommends: lsb-release, iso-codes, python2.6 Breaks: debdelta (<< 0.28~), packagekit-backend-apt (<= 0.4.8-0ubuntu4) Provides: ${python:Provides} Suggests: python-apt-dbg, python-gtk2, python-vte, python-apt-doc -- cgit v1.2.3 From 95112f12cea6ec54aaa8b5e372ee158a300f8967 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 20 Mar 2010 23:06:09 +0100 Subject: debian/control: Change priority to standard, keep -doc and -dev on optional. --- debian/changelog | 2 ++ debian/control | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'debian/control') diff --git a/debian/changelog b/debian/changelog index 84938005..b7617f90 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low * python/generic.cc: - Fix a memory leak when using old attribute names. + * debian/control: + - Change priority to standard, keep -doc and -dev on optional. -- Julian Andres Klode Mon, 15 Mar 2010 17:04:49 +0100 diff --git a/debian/control b/debian/control index 3785e5d5..a3decb78 100644 --- a/debian/control +++ b/debian/control @@ -1,6 +1,6 @@ Source: python-apt Section: python -Priority: optional +Priority: standard Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.4 @@ -42,6 +42,7 @@ Description: Python interface to libapt-pkg the sources.list configuration on the repository and the distro level. Package: python-apt-doc +Priority: optional Architecture: all Section: doc Depends: libjs-jquery, ${misc:Depends} @@ -69,6 +70,7 @@ Description: Python interface to libapt-pkg (debug extension) This package contains the extension built for the Python debug interpreter. Package: python-apt-dev +Priority: optional Architecture: all Depends: python-apt (>= ${source:Version}), libapt-pkg-dev (>= 0.7.10), ${misc:Depends} -- cgit v1.2.3