Gentoo Archives: gentoo-python

From: "Michał Górny" <mgorny@g.o>
To: gentoo-python@l.g.o
Subject: [gentoo-python] Wrapping scripts for multiple Python implementations: executable wrapper or symlinks?
Date: Sat, 29 Sep 2012 20:46:17
Message-Id: 20120929224625.0e2c5ba3@pomiocik.lan
1 Hello,
2
3 Right now we have two different ways of 'wrapping' Python scripts
4 'converted' for various Python implementations. One of them
5 is the wrapper script installed by python.eclass, the other symlinking
6 done by python-distutils-ng.eclass.
7
8 I would like to ask you which one do you consider better, and thus
9 which one should I use for python-r1/distutils-r1.
10
11 A quick summary of possibilities:
12
13 1/ executable wrapper:
14
15 A wrapper script (or executable) will be installed by a common
16 package in the system. The various Python scripts will be symlinked
17 to it, e.g.:
18
19 /usr/bin/flaggie -> python-wrapper
20
21 When run, the script will check the currently selected ABI (via
22 eselect-python) and run the script using it if possible. Otherwise,
23 it will try the best implementation available on the system
24 and supported by the package.
25
26 Advantages:
27 - respects eselect-python (when possible).
28
29 Disadvantages:
30 - more complex,
31 - slows down script startup.
32
33 2/ symlink:
34
35 When the package is installed, a symlink is created to the version
36 for the preferred Python implementation. If it is not supported,
37 the symlink points to the 'best' implementation supported.
38
39 /usr/bin/flaggie -> flaggie-python2_7
40
41 Advantages:
42 - simple,
43 - resolution handled directly.
44
45 Disadvantages:
46 - the preferred implementation can not be changed at runtime.
47
48 3/ partially-shebanged copy of the script:
49
50 One more copy of the script is installed, with a more general shebang
51 like:
52
53 #!/usr/bin/env python
54
55 or:
56
57 #!/usr/bin/env python2
58
59 Advantages:
60 - respects eselect-python.
61
62 Disadvantages:
63 - limited use (only simple version ranges),
64 - yet one more copy of the same script...
65
66 What do you think?
67
68 --
69 Best regards,
70 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies