Review Request 126345: PythonMacros: specify destination directory in byte-compiled files

Raphael Kubo da Costa rakuco at
Wed Dec 16 17:30:44 GMT 2015

This is an automatically generated e-mail. To reply, visit:

(Updated Dec. 16, 2015, 5:30 p.m.)


This change has been marked as submitted.

Review request for Build System, kdelibs and Alex Merry.


Submitted with commit 94f1d2fa9582a2942d5154b85c849cc3c6140e31 by Raphael Kubo da Costa to branch KDE/4.14.

Repository: kdelibs


The `PYTHON_INSTALL()` macro is a wrapper around the `py_compile` Python module that also installs the byte-code (.pyc) file it generates.

However, when a .py file is passed to `py_compile` without any additional arguments, its full path is recorded in the .pyc file. This is problematic, as most distributions install all files into a build root instead of simply copying files to `/` as part of the packaging process. In this case, the generated .pyc file will have something like
in it. Not only does this show up in exception tracebacks, but if the user later invokes `` and has write access to `my_module`'s directory, `my_module.pyc` will be rewritten with the right path to `` (without the build root). This can lead to uninstallation errors if the package management system checks each file before removal, for example.

Fix it by rewritting the `` script so that it takes a `--destination-dir` argument that we use to pass the full path to `` instead of letting it be (wrongly) deduced.


  cmake/modules/ 156fea2 
  cmake/modules/PythonMacros.cmake 6a82d88 



Fedora has packaging macros that will regenerate .pyc and .pyo files with the right paths as part of the build, so it is not affected. Debian disables this macro in pykde4, FreeBSD and openSUSE contain wrong paths in its .pyc files. With this patch, I was able to verify with `hexdump` that the right path is present in the .pyc files installed by pykde4.


Raphael Kubo da Costa

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
Kde-buildsystem mailing list
Kde-buildsystem at

More information about the kde-core-devel mailing list