[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: PEP 453 affects Debian packaging of Python packages



On 09/18/2013 11:41 PM, Piotr Ożarowski wrote:
>>   4) Python modules from dpkg are borderline useless for developers. We
>>      package modules so that apps can use them, not so that people can
>>      develop with them.
> 
> nobody forces Python/Ruby/... developers to use libraries prepared by
> us... and yet they want to force us to use their .eggs and overwrite our
> files.

Kind of funny to read this. Before doing a lot of Python packaging, I
was doing some PHP PEAR packaging. There as well, they forced the users
to use "pear install" instead of apt / dpkg. There as well, they were
writing stuff in their README about how to use PEAR. I suppose we have
lots of this kind of occurrence all over the place in Debian (Piotr, you
mentioned Ruby, it must be a good example, I guess (I don't know ruby at
all)).

In PHP, having the pear shell tool wasn't a problem, even if you don't
use it (and even if I would recommend against using it). Then Mathieu
Parent wrote pkg-php-tools, and I wrote "debpear" over it, which
automatically transforms a PEAR package into a Debian package. The same
way, I wrote debpypi, so that I don't waste my time writing again and
again the same stuff. Though my debpypi isn't good enough to be
released, I heard Piotr wrote the same kind of tool.

Shouldn't we go the same way, and encourage our users to use a kind of
wrapper around pip, so that they really get a Debian package installed
instead of a "pip install" thing which will mess everything? Piotr,
where is the tool you told me about? Could you share it? I've attached
my stupid script, just as a reference (though please don't tell me it's
not good enough, I know that already).

Cheers,

Thomas

#!/bin/sh

set -e
set -x

if [ "${1}" = "-u" ] && [ -n "${2}" ] ; then
	ORIG_URL="${2}"
	shift
	shift
fi

if [ -z "${1}" ] ; then
	echo "Usage: ${0} package-name"
	exit 1
fi

PKG_NAME=${1}
DEB_PKG_NAME=python-${PKG_NAME}


if [ ! -e ${PKG_NAME}.xml ] ; then
	echo "===> Downloading DOAP XML record"
	wget -nv "https://pypi.python.org/pypi?:action=doap&name=${PKG_NAME}"; -O ${PKG_NAME}.xml
fi

# Get info from the XML document using xpath.
VERSION_STRING=`xpath -e "//release/Version/revision/text()" ${PKG_NAME}.xml 2> /dev/null`
SHORT_DESC=`xpath -e "//shortdesc/text()" ${PKG_NAME}.xml 2> /dev/null`
LONG_DESC=`xpath -e "//description/text()" ${PKG_NAME}.xml 2> /dev/null`
UP_MAINT_NAME=`xpath -e "//maintainer/foaf:Person/foaf:name/text()" ${PKG_NAME}.xml 2> /dev/null`
HOMEPAGE=`xpath -e "//homepage/@rdf:resource" ${PKG_NAME}.xml 2> /dev/null | cut -d= -f2 | sed 's#"##g'`
FIRST_LETTER=`echo ${PKG_NAME} | awk '{print substr($0,0,1)}'`
if [ -e ${DEB_PKG_NAME}_${VERSION_STRING}.orig.tar.xz ] ; then
	ORIG=${DEB_PKG_NAME}_${VERSION_STRING}.orig.tar.xz
else
	ORIG=${DEB_PKG_NAME}_${VERSION_STRING}.orig.tar.gz
fi

if [ ! -e ${ORIG} ] ; then
	echo "===> Downloading ${ORIG} file"
	if [ -z "${ORIG_URL}" ] ; then
		ORIG_URL=https://pypi.python.org/packages/source/${FIRST_LETTER}/${PKG_NAME}/${PKG_NAME}-${VERSION_STRING}.tar.gz
	fi
	wget -nv "${ORIG_URL}" -O ${ORIG}
fi

echo "===> Extracting ${ORIG}"
tar -xf ${ORIG}
mv ${PKG_NAME}-${VERSION_STRING} ${DEB_PKG_NAME}-${VERSION_STRING}

echo "===> Creating debian folder for ${DEB_PKG_NAME}"
if [ ! -d ${DEB_PKG_NAME}-${VERSION_STRING}/debian/source ] ; then
	mkdir -p ${DEB_PKG_NAME}-${VERSION_STRING}/debian/source
fi
cd ${DEB_PKG_NAME}-${VERSION_STRING}

echo "Source: ${DEB_PKG_NAME}
Section: python
Priority: optional
Maintainer: PKG OpenStack <openstack-devel@lists.alioth.debian.org>
Uploaders: Julien Danjou <acid@debian.org>,
           Thomas Goirand <zigo@debian.org>,
           Mehdi Abaakouk <sileht@sileht.net>
Build-Depends: debhelper (>= 9), python-setuptools, python-all (>= 2.6.6-3~), openstack-pkg-tools
Standards-Version: 3.9.4
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=openstack/${DEB_PKG_NAME}.git
Vcs-Git: git://anonscm.debian.org/openstack/${DEB_PKG_NAME}.git
Homepage: ${HOMEPAGE}

Package: ${DEB_PKG_NAME}
Architecture: all
Pre-Depends: dpkg (>= 1.15.6~)
Depends: \${python:Depends}, \${misc:Depends}
Recommends: \${python:Recommends}
Description: ${SHORT_DESC}
 ${LONG_DESC}
" >debian/control
EDITOR=touch dch --create --package ${DEB_PKG_NAME} --distribution unstable --urgency low -v ${VERSION_STRING}-1
rm +1

echo "9" >debian/compat
echo "Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ${PKG_NAME}
Source: ${HOMEPAGE}

Files: debian/*
Copyright: (c) 2013, Thomas Goirand <zigo@debian.org>
License: Apache-2

Files: *
Copyright: (c) 2013, ${UP_MAINT_NAME}
License: Apache-2

License: Apache-2
 Licensed under the Apache License, Version 2.0 (the \"License\");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 .
    http://www.apache.org/licenses/LICENSE-2.0
 .
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an \"AS IS\" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 .
 On Debian-based systems the full text of the Apache version 2.0 license
 can be found in /usr/share/common-licenses/Apache-2.0.
" >debian/copyright

echo "[DEFAULT]
upstream-branch = master
debian-branch = debian/unstable
upstream-tag = %(version)s
compression = xz

[git-buildpackage]
export-dir = ../build-area/
" >debian/gbp.conf

echo "#!/usr/bin/make -f

UPSTREAM_GIT = git://github.com/<please-user>/${PKG_NAME}.git
include /usr/share/openstack-pkg-tools/pkgos.make

%:
	dh \$@ --buildsystem=python_distutils --with python2
" >debian/rules
chmod +x debian/rules

echo "version=3
http://pypi.python.org/packages/source/${FIRST_LETTER}/${PKG_NAME} ${PKG_NAME}-(.*).tar.gz
" >debian/watch

echo "3.0 (quilt)" >debian/source/format


Reply to: