You are not logged in.

#1 2014-10-21 19:31:54

Marcel-
Member
From: Utrecht, NL
Registered: 2006-12-03
Posts: 266

[SOLVED] Python dependencies

I'm creating a PKGBUILD for a bunch of scripts that ease the use of Evince with SyncTeX a bit (to elaborate: SyncTeX creates a file that stores positions in original (La)TeX files from a corresponding pdf file, so one can Ctrl-click in Evince and an editor is shown at the corresponding position in the source file, and vice versa). The current version is in this Gist.

Two of those scripts are written in Python (2), a language I'm nearly illiterate in. I want to set the correct dependencies, but I don't know which dependencies I need.

At the moment the following Python2 packages are installed:

$ pacman -Q|grep python2
python2 2.7.8-2
python2-babel 1.3-5
python2-cairo 1.10.0-2
python2-crypto 2.6.1-2
python2-dbus 1.2.0-4
python2-ecdsa 0.11-2
python2-gobject2 2.28.6-11
python2-jinja 2.7.3-1
python2-markupsafe 0.23-1
python2-notify 0.1.1-13
python2-numpy 1.9.0-1
python2-oauth 1.0.1-3
python2-paramiko 1.15.1-1
python2-pexpect 3.3-1
python2-pyqt4 4.11.2-1
python2-pysqlite 2.6.3-4
python2-pytz 2014.7-1
python2-requests 2.4.3-1
python2-setuptools 1:7.0-1
python2-simplejson 3.6.3-1
python2-sip 4.16.3-1

With these packages, both scripts seem to work.

I suppose I can just look at the `import` lines and see that at least dbus and gobject2 are needed, but where can I find 'subprocess', 'time', 're', 'glib', 'sys' (like Java: in the default package?) and 'os'? Or are there other ways to get the dependencies right (an introspection tool, for instance)?

Last edited by Marcel- (2014-10-23 18:33:46)

Offline

#2 2014-10-21 19:55:44

Marcel-
Member
From: Utrecht, NL
Registered: 2006-12-03
Posts: 266

Re: [SOLVED] Python dependencies

I think I'm a bit further now: I created a file pytest only containing:

#!/usr/bin/python2

import dbus, subprocess, time, re, dbus.mainloop.glib, gobject, glib, sys, os

I added this file in my PKGBUILD as such:

check() {
  cd "$srcdir"

  ./pytest
}

and ran makechrootpkg successively, each time adding dependencies that were needed to run this script. In the end I succeeded with

depends=('dbus-glib' 'python2-dbus' 'python2-gobject2')

Now my question is: is this enough?

Offline

#3 2014-10-22 08:39:15

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: [SOLVED] Python dependencies

Don't know much about python but [1] should be helpful as it lists all functions in the python 2.7 standard library.

sys for example is listed, so should not need a separate dependency.

[1] https://docs.python.org/2.7/library/index.html


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#4 2014-10-22 09:00:00

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Python dependencies

I use something like this to find the package for a python import:

pythondep() {
  test "$1" -gt 0 2>/dev/null && set -- "$2" "$1"
  pkgfile "$(python$2 -c "import $1; print($1.__file__)")"
}

pythondep dbus # for default python
pythondep 3 dbus # for python3
pythondep 2 dbus # for python2


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Online

#5 2014-10-23 17:13:48

Marcel-
Member
From: Utrecht, NL
Registered: 2006-12-03
Posts: 266

Re: [SOLVED] Python dependencies

Thanks Progandy, that's what I need, though it doesn't detect the dependency dbus-glib, which is clearly needed.

Offline

#6 2014-10-23 18:14:13

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Python dependencies

Marcel- wrote:

Thanks Progandy, that's what I need, though it doesn't detect the dependency dbus-glib, which is clearly needed.

dbus-glib is an optional dependency of python2-dbus, so it is not automatically in the dependency chain, you'll have to find it manually. Optional dependencies are a bit tricky to find.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Online

Board footer

Powered by FluxBB