From 33293ab8c53a9b1427012c297f288972e11ea3bb Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 8 Jun 2009 17:47:46 +0200 Subject: Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) --- python/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python/makefile') diff --git a/python/makefile b/python/makefile index 3e6458f4..f4d559ce 100644 --- a/python/makefile +++ b/python/makefile @@ -12,7 +12,7 @@ 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 + indexfile.cc metaindex.cc hashstring.cc indexrecords.cc SOURCE := $(APT_PKG_SRC) include $(PYTHON_H) progress.h -- cgit v1.2.3 From a307f6c405d55895690e16d55de36549f5b05d8b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 9 Jun 2009 20:44:58 +0200 Subject: Add apt_pkg.Policy class (Closes: #382725) --- debian/changelog | 3 +- python/apt_pkgmodule.cc | 1 + python/apt_pkgmodule.h | 3 + python/makefile | 2 +- python/policy.cc | 189 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 python/policy.cc (limited to 'python/makefile') diff --git a/debian/changelog b/debian/changelog index 818bf630..3e85c5be 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,10 @@ python-apt (0.7.92) experimental; urgency=low * Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) + * Add apt_pkg.Policy class (Closes: #382725) * Allow types providing __new__() to be subclassed. - -- Julian Andres Klode Tue, 09 Jun 2009 18:09:53 +0200 + -- Julian Andres Klode Tue, 09 Jun 2009 20:39:39 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 95b72de4..3d76894d 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -606,6 +606,7 @@ extern "C" void initapt_pkg() ADDTYPE(Module,"SourceList",&PkgSourceListType); ADDTYPE(Module,"IndexRecords",&PyIndexRecords_Type); ADDTYPE(Module,"HashString",&PyHashString_Type); + ADDTYPE(Module,"Policy",&PyPolicy_Type); // Tag file constants PyModule_AddObject(Module,"REWRITE_PACKAGE_ORDER", CharCharToList(TFRewritePackageOrder)); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 043e29cc..21355072 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -114,4 +114,7 @@ extern PyTypeObject PyHashString_Type; // IndexRecord extern PyTypeObject PyIndexRecords_Type; +// Policy +extern PyTypeObject PyPolicy_Type; + #endif diff --git a/python/makefile b/python/makefile index f4d559ce..6799d749 100644 --- a/python/makefile +++ b/python/makefile @@ -12,7 +12,7 @@ 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 + indexfile.cc metaindex.cc hashstring.cc indexrecords.cc policy.cc SOURCE := $(APT_PKG_SRC) include $(PYTHON_H) progress.h diff --git a/python/policy.cc b/python/policy.cc new file mode 100644 index 00000000..89604e9a --- /dev/null +++ b/python/policy.cc @@ -0,0 +1,189 @@ +/* + * policy.cc - Wrapper around pkgPolicy + * + * 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 +#include "apt_pkgmodule.h" +#include "generic.h" +#include + +static PyObject *Policy_NEW(PyTypeObject *type,PyObject *Args, + PyObject *kwds) { + PyObject *cache; + char *kwlist[] = {"cache", NULL}; + if (PyArg_ParseTupleAndKeywords(Args, kwds, "O", kwlist, &cache) == 0) + return 0; + if (!PyObject_TypeCheck(cache, &PkgCacheType)) { + PyErr_SetString(PyExc_TypeError,"`cache` must be a apt_pkg.Cache()."); + return 0; + } + pkgPolicy *policy = new pkgPolicy(GetCpp(cache)); + return CppOwnedPyObject_NEW(cache,&PyPolicy_Type,policy); +} + +static char *Policy_GetPriority_doc = "get_priority(package: apt_pkg.Package)" + " -> int\n\n" + "Return the priority of the package."; + +PyObject *Policy_GetPriority(PyObject *self, PyObject *arg) { + pkgPolicy *policy = GetCpp(self); + if (PyObject_TypeCheck(arg, &PackageType)) { + pkgCache::PkgIterator pkg = GetCpp(arg); + return Py_BuildValue("i", policy->GetPriority(pkg)); + } else { + PyErr_SetString(PyExc_TypeError,"Argument must be of Package()."); + return 0; + } +} + +static char *Policy_GetCandidateVer_doc = "get_match(package: apt_pkg.Package)" + " -> apt_pkg.Version\n\n" + "Get the best package for the job."; + +PyObject *Policy_GetCandidateVer(PyObject *self, PyObject *arg) { + if (PyObject_TypeCheck(arg, &PackageType)) { + pkgPolicy *policy = GetCpp(self); + pkgCache::PkgIterator pkg = GetCpp(arg); + pkgCache::VerIterator ver = policy->GetCandidateVer(pkg); + return CppOwnedPyObject_NEW(arg,&VersionType, + ver); + } else { + PyErr_SetString(PyExc_TypeError,"Argument must be of Package()."); + return 0; + } +} + +static char *Policy_GetMatch_doc = "get_match(package: apt_pkg.Package) -> " + "apt_pkg.Version\n\n" + "Return a matching version for the given package."; + +static PyObject *Policy_GetMatch(PyObject *self, PyObject *arg) { + if (PyObject_TypeCheck(arg, &PackageType) == 0) { + PyErr_SetString(PyExc_TypeError,"Argument must be of Package()."); + return 0; + } + pkgPolicy *policy = GetCpp(self); + pkgCache::PkgIterator pkg = GetCpp(arg); + pkgCache::VerIterator ver = policy->GetMatch(pkg); + return CppOwnedPyObject_NEW(arg,&VersionType,ver); +} + +static char *Policy_ReadPinFile_doc = "read_pinfile(filename: str) -> bool\n\n" + "Read the pin file given by filename (e.g. '/etc/apt/preferences') and\n" + "add it to the policy."; + +static PyObject *Policy_ReadPinFile(PyObject *self, PyObject *arg) { + if (!PyString_Check(arg)) + return 0; + pkgPolicy *policy = GetCpp(self); + + return PyBool_FromLong(ReadPinFile(*policy, PyString_AsString(arg))); +} + +static char *Policy_CreatePin_doc = "create_pin(type: str, pkg: str, " + "data: str, priority: int)\n\n" + "Create a pin for the policy. The parameter 'type' refers to one of the\n" + "following strings: 'Version', 'Release', 'Origin'. The argument 'pkg'\n" + "is the name of the package, the parameter 'data' refers to the value\n" + "e.g. unstable for type='Release' and the other possible options. \n" + "The parameter 'priority' gives the priority of the pin."; + +static PyObject *Policy_CreatePin(PyObject *self, PyObject *args) { + pkgVersionMatch::MatchType match_type; + const char *type, *pkg, *data; + signed short priority; + if (PyArg_ParseTuple(args, "sssh", &type, &pkg, &data, &priority) == 0) + return 0; + pkgPolicy *policy = GetCpp(self); + if (type == "Version" || type == "version") + match_type = pkgVersionMatch::Version; + if (type == "Release" || type == "release") + match_type = pkgVersionMatch::Release; + if (type == "Origin" || type == "origin") + match_type = pkgVersionMatch::Origin; + else + match_type = pkgVersionMatch::None; + policy->CreatePin(match_type,pkg,data,priority); + HandleErrors(); + Py_RETURN_NONE; +} + +static PyMethodDef Policy_Methods[] = { + {"get_priority",(PyCFunction)Policy_GetPriority,METH_O, + Policy_GetPriority_doc}, + {"get_candidate_ver",(PyCFunction)Policy_GetCandidateVer,METH_O, + Policy_GetCandidateVer_doc}, + {"read_pinfile",(PyCFunction)Policy_ReadPinFile,METH_O, + Policy_ReadPinFile_doc}, + {"create_pin",Policy_CreatePin,METH_VARARGS,Policy_CreatePin_doc}, + {"get_match",(PyCFunction)Policy_GetMatch,METH_O, Policy_GetMatch_doc}, + {} +}; + +static char *Policy_doc = "Policy(cache)\n\n" + "Representation of the policy of the Cache object given by cache. This\n" + "provides a superset of policy-related functionality compared to the\n" + "DepCache class. The DepCache can be used for most purposes, but there\n" + "may be some cases where a special policy class is needed."; + +PyTypeObject PyPolicy_Type = { + PyObject_HEAD_INIT(&PyType_Type) +#if PY_MAJOR_VERSION < 3 + 0, // ob_size +#endif + "apt_pkg.Policy", // tp_name + sizeof(CppOwnedPyObject),// tp_basicsize + 0, // tp_itemsize + // Methods + CppOwnedDealloc, // tp_dealloc + 0, // tp_print + 0, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + 0, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), + Policy_doc, // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + Policy_Methods, // tp_methods + 0, // tp_members + 0, // tp_getset + 0, // tp_base + 0, // tp_dict + 0, // tp_descr_get + 0, // tp_descr_set + 0, // tp_dictoffset + 0, // tp_init + 0, // tp_alloc + Policy_NEW, // tp_new +}; -- cgit v1.2.3 From 5b489a994d009771d7f4d5beec45bbbb5468cd58 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 12 Jul 2009 19:07:55 +0200 Subject: python/hashes.cc: Introduce the Hashes class. The Hashes class is a function which calculates all supported hashes for one input. DebImg will use this for calculating the hashes of files. --- debian/changelog | 3 +- doc/source/apt_pkg.rst | 26 +++++++-- python/apt_pkgmodule.cc | 1 + python/apt_pkgmodule.h | 1 + python/hashes.cc | 136 ++++++++++++++++++++++++++++++++++++++++++++++++ python/makefile | 5 +- 6 files changed, 164 insertions(+), 8 deletions(-) create mode 100644 python/hashes.cc (limited to 'python/makefile') diff --git a/debian/changelog b/debian/changelog index 8bc3e320..1f43cc8c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -30,6 +30,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low + Closes: #468123 - there is no need anymore for binding CompType or CompTypeDeb, because we don't return integer values for CompType anymore. + * Introduce apt_pkg.Hashes class. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -45,7 +46,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, 07 Jul 2009 16:56:44 +0200 + -- Julian Andres Klode Sun, 12 Jul 2009 18:51:57 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/doc/source/apt_pkg.rst b/doc/source/apt_pkg.rst index 2af934a0..9a14266e 100644 --- a/doc/source/apt_pkg.rst +++ b/doc/source/apt_pkg.rst @@ -1139,15 +1139,31 @@ installation. the file using the parameter *destfile*. You can not combine both. +Hashes +------ +The apt_pkg module also provides several hash functions. If you develop +applications with python-apt it is often easier to use these functions instead +of the ones provides in Python's :mod:`hashlib` module. +.. class:: Hashes(object) + Calculate all supported hashes of the object. *object* may either be a + string, in which cases the hashes of the string are calculated, or a + :class:`file()` object or file descriptor, in which case the hashes of + its contents is calculated. The calculated hashes are then available via + attributes: + .. attribute:: md5 -Hash functions --------------- -The apt_pkg module also provides several hash functions. If you develop -applications with python-apt it is often easier to use these functions instead -of the ones provides in Python's :mod:`hashlib` module. + The MD5 hash of the data, as string. + + .. attribute:: sha1 + + The SHA1 hash of the data, as string. + + .. attribute:: sha256 + + The SHA256 hash of the data, as string. .. function:: md5sum(object) diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 3f4aae37..4c0fd5ed 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -618,6 +618,7 @@ extern "C" void initapt_pkg() ADDTYPE(Module,"IndexRecords",&PyIndexRecords_Type); ADDTYPE(Module,"HashString",&PyHashString_Type); ADDTYPE(Module,"Policy",&PyPolicy_Type); + ADDTYPE(Module,"Hashes",&PyHashes_Type); // Tag file constants PyModule_AddObject(Module,"REWRITE_PACKAGE_ORDER", CharCharToList(TFRewritePackageOrder)); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 21355072..1a2f1a1a 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -116,5 +116,6 @@ extern PyTypeObject PyIndexRecords_Type; // Policy extern PyTypeObject PyPolicy_Type; +extern PyTypeObject PyHashes_Type; #endif diff --git a/python/hashes.cc b/python/hashes.cc new file mode 100644 index 00000000..a1ace6fc --- /dev/null +++ b/python/hashes.cc @@ -0,0 +1,136 @@ +/* hashes.cc - Wrapper around apt-pkg's Hashes. + * + * 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 +#include "generic.h" +#include "apt_pkgmodule.h" +#include + +static PyObject *hashes_new(PyTypeObject *type,PyObject *args, + PyObject *kwds) +{ + return CppPyObject_NEW(type); +} + +static int hashes_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + PyObject *object = 0; + int Fd; + char *kwlist[] = {"object", NULL}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "|O:__init__", kwlist, + &object) == 0) + return -1; + if (object == 0) + return 0; + Hashes &hashes = GetCpp(self); + + if (PyBytes_Check(object) != 0) { + char *s; + Py_ssize_t len; + PyBytes_AsStringAndSize(object, &s, &len); + hashes.Add((const unsigned char*)s, len); + } + else if ((Fd = PyObject_AsFileDescriptor(object)) != -1) { + struct stat St; + if (fstat(Fd, &St) != 0 || hashes.AddFD(Fd, St.st_size) == false) { + PyErr_SetFromErrno(PyExc_SystemError); + return -1; + } + } + else { + PyErr_SetString(PyExc_TypeError, "__init__() only understand strings" + " and files"); + return -1; + } + return 0; +} + +static PyObject *hashes_get_md5(PyObject *self, void*) +{ + return CppPyString(GetCpp(self).MD5.Result().Value()); +} + +static PyObject *hashes_get_sha1(PyObject *self, void*) +{ + return CppPyString(GetCpp(self).SHA1.Result().Value()); +} + +static PyObject *hashes_get_sha256(PyObject *self, void*) +{ + return CppPyString(GetCpp(self).SHA256.Result().Value()); +} + +static PyGetSetDef hashes_getset[] = { + {"md5",hashes_get_md5,0,"The MD5Sum of the file as a string."}, + {"sha1",hashes_get_sha1,0,"The SHA1Sum of the file as a string."}, + {"sha256",hashes_get_sha256,0,"The SHA256Sum of the file as a string."}, + {} +}; + +static char *hashes_doc = + "Hashes([object: (bytes, file)])\n\n" + "Calculate hashes for the given object. It can be used to create all\n" + "supported hashes for a file.\n\n" + "The parameter *object* can be a bytes (3.X) / str (2.X) object, or an\n" + "object providing the fileno() method or an integer describing a file\n" + "descriptor."; + +PyTypeObject PyHashes_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "apt_pkg.Hashes", // tp_name + sizeof(CppPyObject), // tp_basicsize + 0, // tp_itemsize + // Methods + CppDealloc, // tp_dealloc + 0, // tp_print + 0, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + 0, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE, + hashes_doc, // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + 0, // tp_methods + 0, // tp_members + hashes_getset, // tp_getset + 0, // tp_base + 0, // tp_dict + 0, // tp_descr_get + 0, // tp_descr_set + 0, // tp_dictoffset + hashes_init, // tp_init + 0, // tp_alloc + hashes_new, // tp_new +}; diff --git a/python/makefile b/python/makefile index 6799d749..fff3a2e8 100644 --- a/python/makefile +++ b/python/makefile @@ -11,8 +11,9 @@ 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 + 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 -- 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 'python/makefile') 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