Bug 558997
Summary: | brp-python-bytecompile does not enter correct paths in python bytecode | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Toshio Ernie Kuratomi <a.badger> |
Component: | rpm | Assignee: | Panu Matilainen <pmatilai> |
Status: | CLOSED RAWHIDE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | medium | Docs Contact: | |
Priority: | low | ||
Version: | rawhide | CC: | dmalcolm, ffesti, jnovy, pmatilai |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2010-02-03 10:55:44 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | |||
Bug Blocks: | 530636 | ||
Attachments: |
Description
Toshio Ernie Kuratomi
2010-01-26 21:21:04 UTC
Created attachment 386948 [details]
New version -- tested on py2/py3 package
New version of brp-python-bytecompile
This version of the script has a few bug fixes. Tested that it works on a
python2/python3 module package (python-setuptools with a python3 subpackage). Embeds the expected directory paths.
No private libraries were tested in the package to make sure the default_python call worked.
Also didn't test what happens when SyntaxErrors are found.
Tested SyntaxErrors. The behaviour is that it gives a warning and then exits. If the syntax error happens in the compilation of .pyc in the site-packages directory then none of the rest of the files will be byte compiled. This seems wrong to me.... This can be fixed in one of two ways: 1) If a SyntaxError is encountered, fail the build 2) If a SyntaxError is encountered, print a warning and continue #2 seems more in line with what the comments imply is wanted so I'll change the patch to do that. I like #1 better though :-) Perhaps its not the case because we aren't able to differentiate SyntaxErrors from other reasons py.compile might fail? In either case, distutils and setuptools packages should be byte compiling themselves in the %build section of the spec file (according to Guidelines and the rpmdevtools python spec template) so we should be catching SyntaxErrors earlier in the build. Created attachment 386963 [details]
brp-python-bytecompile that warns and continues
Last revision, this version will warn and continue on SyntaxErrors.
1) was what originally went in, but it triggered some unforeseen problems (always the case, sigh :) with python template files, jython-related packages and whatnot. So the quick-n-dirty solution was to just warn and bail out for now. As there's no way to automatically determine whether a .py file fails compilation for a legitimate reason or not, the best option would probably be defaulting to 1) but permitting those packages to opt for 2) through a spec override to stumble through thouse special cases. Okay. I've reworked the script, macros and redhat/macros from rpm-redhat-config to almost do this. The one piece I'm missing is how to get brp-python-bytecompile to actually fail the build. I tried exit 1 but that doesn't do it. Any help? Hmm, exit 1 is certainly supposed to fail the build, and does here for an artificial test-case. Can you attach the updated script so I can have a look? The current state of https://fedoraproject.org/wiki/PackagingDrafts/Python3#TODO says that "Must get this bug fixed so byte compilation does not stop midway through if there's a SyntaxError bug 558997" Does this aspect work yet in F13's rpm? (trying to get the packaging guidelines done) Found my bug. Working on this today. Created attachment 387680 [details]
brp-python-bytecompile that stops build on SyntaxError
Here's the changes to /usr/lib/rpm/redhat/macros to enable this: %{!?__debug_package:/usr/lib/rpm/redhat/brp-strip %{__strip}} \ /usr/lib/rpm/redhat/brp-strip-static-archive %{__strip} \ /usr/lib/rpm/redhat/brp-strip-comment-note %{__strip} %{__objdump} \ - /usr/lib/rpm/brp-python-bytecompile \ + /usr/lib/rpm/brp-python-bytecompile %{_python_bytecompile_errors_terminate_build} \ /usr/lib/rpm/redhat/brp-python-hardlink \ %{!?__jar_repack:/usr/lib/rpm/redhat/brp-java-repack-jars} \ %{nil} +# +# Should bytecompilation errors terminate a build? +%_python_bytecompile_errors_terminate_build 1 + Didn't test it yet, but one immediate problem spotted: changing the order of arguments for brp-python-bytecompile creates a pesky and unnecessary incompatibility issue between rpm <-> redhat-rpm-config versions. Better leave $1 for optional python interpreter path and add the "strict" mode as $2, defaulting to former behavior where it doesn't abort the build. That way it'll work regardless of the rpm version, otherwise it'd need some brittle release-specific require on rpm version. Oh and there are a bunch of now incorrect "XXX TODO: parametrize the exit code, only warn for now" comments. I dont mind doing these final tweaks, unless you have either objections or insist on doing them yourself :) Oh well, I went ahead and changed the arg order and removed the old comments. Should be fixed now in rawhide as of rpm-4.8.0-5.fc13 and also applied upstream. Thanks for your work on this Toshio! |