
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 https://github.com/IronLanguages/ironpython2). 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 https://is.gd/EgL9S4 (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" > foo.py $> echo "print('bar')" > bar.py $> python3 foo.py $> ln -s ln -s __pycache__/bar.cpython-36.pyc bar.pyc $> strace -efile -o '|grep bar' python3 ./foo.py $> mv bar.py{,_bak} $> strace -efile -o '|grep bar' python3 ./foo.py --- (Re)moving bar.py does not stop bar.pyc from working. So you can ship foo.pyc and __pycache__/foo.{implementation}[opt-*].pyc in the same package, in foo.py in a different one. You still have to decide with the different optimization levels. Kind regards, Stefan