Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: Gentoo Developer Mailing List <gentoo-dev@l.g.o>
Cc: python@g.o
Subject: [gentoo-dev] [RFC] python-r1 + distutils-r1, v2 (+ comparison)
Date: Mon, 08 Oct 2012 15:16:42
Message-Id: 20121008171605.76e67328@pomiocik.lan
1 Hello,
2
3 This is the second and hopefully last version of python-r1 +
4 distutils-r1 eclasses before committing. I would also like to shortly
5 point out the goals and the differences between various python eclasses
6 in Gentoo.
7
8 Both are attached. For those who prefer hosted form:
9 https://bitbucket.org/mgorny/gx86-working-tree/src/5a2d39e69d6d/gx86/eclass/python-r1.eclass
10 https://bitbucket.org/mgorny/gx86-working-tree/src/5a2d39e69d6d/gx86/eclass/distutils-r1.eclass
11
12 Changes from the previous version:
13 - support for DOCS and HTML_DOCS (alike EAPI 4);
14 - minimal support for passing arguments to setup.py (through
15 distutils-r1_python_compile & distutils-r1_python_install);
16 - EPYTHON values adjusted to match python.eclass;
17 - scripts are -${EPYTHON} suffixed -- i.e. foo-python2.7,
18 foo-pypy-c1.8;
19 - a wrapper script[1] is used to choose the correct script instead of
20 constant symlink. Thus, EPYTHON & eselect-python are respected,
21 - PYTHON_COMPAT can be an array only.
22
23 What still needs considering:
24 - a nicer way of passing setup.py arguments (mysetuppyargs=()?,
25 esetuppy wrapper?);
26 - Prefix support.
27
28 [1]:https://bitbucket.org/mgorny/python-exec
29
30
31 Now, for the differences part.
32
33 Goals
34 -----
35
36 python.eclass aims to support every single Python package out there,
37 including rare corner cases supported in-eclass. It supports both
38 packages supporting one and multiple Python implementations. distutils
39 support is provided by second eclass, and both provide phase functions
40 (python.eclass providing default ph.f. wrappers).
41
42 python-distutils-ng aims to support majority of Python packages using
43 distutils. With a bit of hackery it can support non-distutils packages,
44 but the use is limited to the common cases. In an uncommon case, it's
45 not flexible enough. It supports Python packages supporting multiple
46 implementations only.
47
48 python-r1 aims mostly to provide tools to support majority of Python
49 packages. It tries to be simple & flexible, thus allowing handling
50 various corner cases without special branches of code in the eclass.
51 It doesn't export any phase functions, nor set dependencies by default
52 (just provides a variable with them).
53
54 Right now, it supports packages supporting multiple implementations
55 only; if necessary, the support will be extended -- either through
56 additional code if that wouldn't add too much complexity, or through
57 additional eclass.
58
59 It is accompanied by distutils-r1 which provides a simple overlay for
60 the very common case of distutils packages. This eclass exports phase
61 functions and sets dependencies implicitly. It also handles renaming
62 the distutils-installed scripts and linking the python-exec wrapper.
63
64
65 Python targets
66 --------------
67
68 python.eclass uses implicit Python target specifications. It provides
69 no ebuild-transparent way of enabling/disabling them.
70
71 python-distutils-ng and python-r1 use USE flags to explicitly list
72 enabled Python implementations. Both eclasses use the same values for
73 PYTHON_TARGETS USE_EXPAND.
74
75
76 Installed scripts
77 -----------------
78
79 python-distutils-ng rework the installed scripts creating copies for
80 Python implementations and changing the shebang. The created copies
81 don't differ any other way. The old script name is then symlinked to
82 the version for default implementation.
83
84 python.eclass & python-r1 instead let distutils rework the scripts
85 and just rename them before merging. A wrapper is used to choose
86 the correct version, respecting EPYTHON & eselect-python.
87
88 python.eclass installs the files to separate installation images
89 and merges them. python-r1 installs them to the main image directly,
90 renaming the installed scripts between successive implementations.
91
92 python.eclass creates a wrapper script for each package. The script is
93 written in python. python-r1 instead installs the compiled wrapper
94 once (in an ebuild), and symlinks it for the packages. The wrapper is
95 written in much simpler C.
96
97 The implementation suffixes for all three eclasses are different:
98 - python.eclass uses -2.6, -2.7 for Python, -2.7-pypy-1.8,
99 -2.7-pypy-1.9 for pypy and -2.5-jython for jython (enjoy!);
100 - p-d-ng uses Python target names (-python2_6, -python2_7, -pypy1_8),
101 - p-r1 uses $EPYTHON values (-python2.6, -python2.7, -pypy-c1.8 (sic!)).
102
103
104 Dependency on Python
105 --------------------
106
107 python.eclass has a few variables necessary to set dependencies
108 on Python implementation, including internal sub-syntax (and an even
109 more complete generator sub-syntax in progress overlay). I suspect that
110 most of the possible variants can be achieved using it, just please
111 don't make me try learning it all.
112
113 Additionally, packages supporting multiple Python implementations are
114 required to specify their supported Python versions twice -- with
115 PYTHON_DEPEND and RESTRICT_PYTHON_ABIS.
116
117 USE flag dependencies are specified using three variables, and I'd like
118 to avoid getting anywhere deeper.
119
120 p-d-ng has a very simple dependency setup. It has a variable for
121 listing supported Python versions and a variable to make Python
122 dependencies conditional under the 'python' flag. Lately, it has been
123 added a method of listing requested USE flags.
124
125 p-d-ng does not provide any support for more complex dependency
126 specifications, nor a way to disable adding default Python dependencies.
127
128 python-r1 does not append any dependencies by default, and instead
129 exports them in a variable. The variable can be used to easily express
130 simple cases, and avoids polluting the ebuild in more complex cases. It
131 also supports providing USE dependencies for the implementation.
132
133 distutils-r1 adds the Python dependencies to RDEPEND & DEPEND;
134 additionally, it adds a dependency on python-exec.
135
136
137 Dependencies on other packages
138 ------------------------------
139
140 As python.eclass (as of gx86 state) does not express enabled
141 implementations explicitly, it is not possible to request those
142 implementations from other packages. The dependencies on other Python
143 packages are thus simple.
144
145 p-d-ng does not provide any simpler way of writing dependencies
146 on other Python packages using the eclass. Thus, the necessary USE
147 dependencies have to be written by hand.
148
149 python-r1 does provide a simple PYTHON_USEDEP variable which can be
150 used in dependency atoms to request the same Python implementations
151 being enabled.
152
153
154 Phase functions for distutils
155 -----------------------------
156
157 distutils.eclass allows specifying additional arguments to setup.py.
158 src_install() installs default documentation files (*unconditionally*)
159 and ${DOCS}, it also does installation image magic.
160
161 p-d-ng has mixed unconditional and user-overridable stuff. Copying
162 sources is done unconditionally; redoing scripts can be disabled using
163 a separate variable. setup.py invocations are overridable.
164
165 d-r1 splits each phase into 'global' and 'per-implementation' stages
166 which are both overridable. The default stages apply PATCHES (and user
167 patches), copy sources, run setup.py, install DOCS & HTML_DOCS and link
168 python-exec wrappers.
169
170
171
172 Thank you for reading up to this. I'd appreciate any comments, ideas,
173 and especially any API suggestions while the eclass still ain't live.
174
175 --
176 Best regards,
177 Michał Górny

Attachments

File name MIME type
python-r1.eclass text/plain
distutils-r1.eclass text/plain
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-dev] [RFC] python-r1 + distutils-r1, v2 (+ comparison) Reinis Danne <rei4dan@×××××.com>