PythonMacros: specify destination directory in byte-compiled files.
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 /wrkdir/buildroot/usr/lib/python2.7/site-packages/Foo/my_module.py in it. Not only does this show up in exception tracebacks, but if the user later invokes my_module.py and has write access to my_module's directory, my_module.pyc will be rewritten with the right path to my_module.py (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 PythonCompile.py script so that it takes a --destination-dir argument that we use to pass the full path to my_module.py instead of letting it be (wrongly) deduced. It is important to note that PythonCompile.py now uses the argparse module, which is not present in Python <= 2.6, Python 3.0 and Python 3.1. REVIEW: 126345
parent
a02df05e
Please register or sign in to comment