[Rpm-maint] Reworking pythondeps.sh to support multiple parallel Python stacks

David Malcolm dmalcolm at redhat.com
Fri Oct 30 18:12:34 UTC 2009

(Further work towards support deploying multiple python versions via RPM
on one machine)

rpm.org's scripts/pythondeps.sh can be used to autogenerate Provides and
Requires items of the form:
   python(abi) = ${PYVER}
where PYVER is of the form MAJOR.MINOR

"pythondeps.sh" can take a list of buildroot paths as lines on stdin and
generate the "python(abi) = foo" line on stdout.

As I understand things, it's invoked due to these lines in
%__python_provides %{_rpmconfigdir}/pythondeps.sh --provides
%__python_requires %{_rpmconfigdir}/pythondeps.sh --requires
(which is invoked by rpmfcHelper/rpmfcGenerateDepends in build/rpmfc.c
when "_use_internal_dependency_generator" is enabled)

Incidentally, my reading of the above code [1] is that only files that
are categorized as python files get passed to the script.  Since the
python binary is not a python file, it's not passed to the script, so
the provides line is never generated.  In Fedora's "python.spec" we get
around this by manually supplying a couple of provides:
  Provides: python-abi = %{pybasever}
  Provides: python(abi) = %{pybasever}

The current implementation invokes "python" to determine PYVER.  This
assumes that /usr/bin/python is actually installed in the environment,
which isn't the case when rebuilding a "python" rpm in a clean
environment (e.g. mock chroot).

Attached is a reimplementation of the code which allows for multiple
python implementations and removes the assumption that /usr/bin/python
is installed (although in Fedora we don't actually use this for the
provides case as described above).

The code assumes that Python binaries are of the form
and generate "provides" items of the form
    python(abi) = MAJOR.MINOR

Python libraries are assumed to be of the form
    /usr/lib/pythonMAJOR.MINOR/  and
generating (uniquely) lines of the form:
    python(abi) = MAJOR.MINOR    

$ echo "/home/david/rpmbuild/BUILDROOT/python3-3.1.1-7.fc11.i386/usr/bin/python3.1" \
  | ./pythondeps.sh --provides
Output: python(abi) = 3.1
(though this path is never actually passed; see note above)

$ echo "/home/david/rpmbuild/BUILDROOT/python3-3.1.1-7.fc11.i386/usr/bin/python3.1-config" \
  | ./pythondeps.sh --provides
(no output)

$ echo "/home/david/rpmbuild/BUILDROOT/python3-3.1.1-7.fc11.i386/usr/lib/python3.1/test/test_bisect.py" \
  | ./pythondeps.sh --requires
Output: python(abi) = 3.1


[1] plus adding a "tee -a /tmp/whatever" to the file to capture it, for
playback into my test scripts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pythondeps.sh
Type: application/x-shellscript
Size: 874 bytes
Desc: not available
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20091030/b75b94aa/attachment.bin>

More information about the Rpm-maint mailing list