[csw-maintainers] Python 2.7

Peter FELECAN pfelecan at opencsw.org
Thu Jul 25 19:37:01 CEST 2013


"Maciej (Matchek) Bliziński" <maciej at opencsw.org> writes:

> 2013/7/25 Peter FELECAN <pfelecan at opencsw.org>
>>
>> As an aside, this brings up the question: why do we need to
>> compile at installation time and not deliver the pre-compiled bits; is
>> the p-code not portable on different architectures?
>
> The Debian Python policy doesn't provide the reasons why they do it that way.
> http://www.debian.org/doc/packaging-manuals/python-policy/ch-module_packages.html#s-byte_compilation
>
> According to my own web searching, the *.pyc files are
> Python-version-dependent according to this entry on stackoverflow:
> http://stackoverflow.com/questions/2263356/are-python-2-5-pyc-files-compatible-with-python-2-6-pyc-files
>
> They don't provide sources, so I couldn't quickly verify it. I did see
> an example where the Python version has been shown to be encoded
> inside a *.pyc file. I'm not sure how Python handles version
> mismatches. I'm expecting that it reads the file, deserializes it,
> check the version and if a mismatch is detected, it discards the *.pyc
> file and compiles the *.py file. This would mean that a *.pyc file is
> always useless for one of the two installed Python versions.

Thank you for the research and abstract. All this is not very convincing
(beware, I'm not talking about you). I remember a discussion that I had
in a distant past with Philip Brown about Emacs Lisp compiled files (.el is the source,
.elc is the compiled version); after a lot of wrangling I won by the
missing argument for architectural / version specific compiled
components and eventually delivered them in the package as it seems
suitable from my stand point for Python.

> I looked at the Debian pyshared solution by poking an installed
> system. The quick summary is:
>
> - /usr/share/pyshared contains the .py files and is not a member of sys.path
> - for each Python version a /usr/lib/pythonX.Y/dist-modules directory
> exists and is a member of sys.path
> - when a module is installed, symlinks from
> /usr/lib/pythonX.Y/dist-modules to respective entries in
> /usr/share/pyshared are made. They are exclusively file symlinks, and
> never directory symlinks.
> - the *.py files are compiled once per Python version, and *.pyc files
> live in the /usr/lib/pythonX.Y/dist-modules directory tree

This is a genuine example of over-engineering, especially that there is
no real argument for doing that (see above). Moreover, if we have
separate versioned trees what's the need for that?

> Sounds very reasonable to me. Somebody has to implement it for us though.

IMHO we don't have the resources for that. However, someone willing to
spend his time on it is free to do it.

In the mean time, what we must do is to find a solution for the
compilation errors during the installation of some Python modules, as
reported in the original message.
-- 
Peter


More information about the maintainers mailing list