-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hi, Dne 16.10.2014 v 12:11 Johannes Meixner napsal(a):
A question regarding "include .pycs and .pyos":
Do you recommend that a package schould provide both .pyc files and .pyo files for each .py file i.e. that during build both "%py_compile" and "%py_compile -O" should be run?
as long as it's not too much trouble, then yes
For me it looks overcomplicated to make and provide both and then link them via "%fdupes" if they are the same.
fair point
Why not only make and provide the optimized files in any case?
That's a long story. You can run the python interpreter either in "normal" or "optimized" mode; the latter is enabled by "python -O". In normal mode, python only looks for .pyc; in optimized mode, it only looks for .pyo. No fallback to the other one. (IIRC, there are some technical and semantical issues, and the fallback feature is not important enough to justify the tradeoff) So if we want to support users of optimized mode, we need to provide both kinds of files. At this moment, the optimizations in the "optimized" bytecode are extremely limited, so in the majority of cases, the resulting bytecode is the same. The biggest potential difference is that .pyo does not include certain kinds of strings; that also means that there is a potential difference of behavior, and that's the main reason why the optimized mode is kept separate. Personally, I believe that .pyo is kept around because the upstream is hoping that someone will start implementing some worthwhile optimizations ;) There is some work ongoing, but it's very low-priority. In practice, maybe this is one more thing we don't have to care about. I have never in my life met anyone who uses the optimized mode, so i believe it's a minority usecase; people looking for more performance are switching to PyPy or Cython implementations. My rule of thumb is this: if it's not too much trouble, provide both .pyc and .pyo and merge them with fdupes. If it causes problems, forget about .pyo.
A subsequent question:
When a package ships .pyc and/or .pyo files, I wonder if the .py files are still needed by a normal users.
Does Python software work correctly only with .pyc and/or .pyo files?
yes
If yes, shoudn't then the .py files moved into a *-python-source sub-package that is not installed by default?
We also do not install *.c source files but only the binaries.
That's honestly something that never crossed my mind. It's somewhat different than with C sources though. On an installed system, C sources are for reference only -- if you want to make changes, you have to recompile and install the result. For Python, source code is the primary material and the bytecode is just a "cached result". Changes to sources are reflected immediately on the next run; the interpreter checks mtimes, and if the source doesn't match the bytecode, runs from source (and updates the bytecode if it can). Personally, i'd vote to keep the sources for this reason alone :) It more closely matches the spirit of open source, after all. And there's also a number of smaller reasons: don't fix what ain't broken, every other distro does it like this, *-python-source would complicate packaging, etc. But it is something worth thinking about. regards m.
Strictly spaking, if it works only with .pyc and/or .pyo files, there is no need to provide the Python source files in the RPM. Only the SRPM provides the sources.
Exception: Python scripts that are meant to be adapted by the end-user.
Kind Regards Johannes Meixner
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJUP9/PAAoJEIskb84DCy7LTTwQAJpOnVuHtkbnj2zMAb7q4EOU rz7hKKrrv3zXgk15nGd2CiiSizaPzzqfADHFGYWajpWNP23j4fHGePdtGoFtsTWn mCJef1Nh9JYQAUboHtubtwa0DTOnqxqzEDnC4KPtfBFfPn79Y2jlt/oAYBCzUrNS PLJtCCQV76wZMCfvsY7KGe3G3UVT59NhvVXXIWMoi26CfmVQWGucjLhkZ+ychR0K sINuNn6Q799irov4SZzQnwW301swaiEGb55qy+fYNT8N1kPez0oi9jfTK8sqbUya 5KWoE3VD33+ejLxVkgONjfecFHnEaHvyZgfpvRAwVaNtmgoyv+WQ84DL5P9wx0Su edsj5GPNJrhW+bjhHujXEpdJ67NqnJmeBEU2G7DO0+AKWz0JO/x4YwhSkE3S8cJc mylbnMNDVOWJInIdUpUxOuoHlHq/dESM0LiokD3sSkBEVWnTmaAOQvmGtg8zRBuv 62/YX659KJ89ZqkaGzIQssOz7UVQwmWKg6gRRX0TrvnYv3hAcuEdkPhZf0gnu5tA y2tXfZ01zGWFWZo8APSXzMN4hfFn6IKih/eUw0A2FaxqT4r8hTrNhz26sxJmoVfL b0gTheEX1RBX+K3IhKV0A1km/ZDxH5ABtA9FyH1NkiHjlOLI895SJZj3/vJ8aUQD 3l1vIpcjzuMmmgUQj2Wx =oWTH -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org