Mailinglist Archive: opensuse-factory (381 mails)

< Previous Next >
Re: [opensuse-factory] Re: [opensuse-packaging] Proposal to remove pyc/pyo from Python on TW
  • From: Brüns, Stefan <Stefan.Bruens@xxxxxxxxxxxxxx>
  • Date: Fri, 5 Oct 2018 17:43:56 +0000
  • Message-id: <2627456.nuXzl84PW8@sbruens-linux.lcs.intern>
On Freitag, 5. Oktober 2018 13:24:24 CEST Matěj Cepl wrote:
On 2018-10-04, 16:39 GMT, Jan Engelhardt wrote:
Or one could remove py and keep pyc/pyo.
That's basically how GNU C C++ & Fortran, Erlang, ocaml, .. all work ;-)

Well, it's a bit more complicated than that.

1. *.pyc files are arch independent (it's just an ouput of the
marshall underneath), but they are not interpreter
independent. So, if you install only *.pyc files generated by
CPython, you cannot use the same library with Jython or PyPy
(IronPython seems to be catching second breath on That
limitation probably isn’t a problem with IoT microimages, but
I think it is quite showstopper for the general openSUSE/SLE.

And no, if you study (Case 3 and Case 4)
carefully, it is not possible to have both __pycache__ and
sourceless *.pyc files together.

If you read it *really carefully*, you will see you can have both __pycache__
and {name}.pyc together, but not {name}.pyc and {name}.py (or more
specifically, {name}.py disables {name}.pyc).

$> echo "import bar" >
$> echo "print('bar')" >
$> python3
$> ln -s ln -s __pycache__/bar.cpython-36.pyc bar.pyc
$> strace -efile -o '|grep bar' python3 ./
$> mv{,_bak}
$> strace -efile -o '|grep bar' python3 ./

(Re)moving does not stop bar.pyc from working. So you can ship foo.pyc
and __pycache__/foo.{implementation}[opt-*].pyc in the same package, in
in a different one.

You still have to decide with the different optimization levels.

Kind regards,

< Previous Next >