Gentoo Archives: gentoo-dev

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

Attachments

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