Catching python syntax errors at build time

Panu Matilainen pmatilai at laiskiainen.org
Sat Feb 21 08:09:50 UTC 2009


On Fri, 20 Feb 2009, Florian Festi wrote:

> Panu Matilainen wrote:
>> If somebody feels like scripting a bit, it should be possible to fairly 
>> accurately determine affected packages: if a package has *.py files but not 
>> the corresponding *.pyc and *.pyo files for each of them, the byte-compile 
>> has failed and with the new check, building the package will fail.
>
> Unfortunately this is not that precise. Attached is a list of packages from 
> the x86_64 repo which contain .py files without .pyc or .pyo files. The file 
> list has 0.5 MB so I am not posting it here. Use rpm -qpl or ask me off list 
> if you are interested or owner of one of those packages. To me it looks like 
> all those files are not failing to be compiled but are just not even tried to 
> be compiled.

Yup, there's one other cause for missing python byte-compilations: missing 
python in the buildroot, in which case the script will just silently exit. 
That's the reason for the big pile of yum-utils subpackages showing up on 
the list:

...
Processing files: yum-downloadonly-1.1.19-1.fc11
/usr/lib/rpm/pythondeps.sh: line 8: python: command not found
/usr/lib/rpm/pythondeps.sh: line 8: python: command not found
Provides:
  config(yum-downloadonly) = 1.1.19-1.fc11
Requires(rpmlib):
  rpmlib(CompressedFileNames) <= 3.0.4-1
  rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Processing files: yum-allowdowngrade-1.1.19-1.fc11
Provides:
  config(yum-allowdowngrade) = 1.1.19-1.fc11
Requires(rpmlib):
  rpmlib(CompressedFileNames) <= 3.0.4-1
  rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Processing files: yum-priorities-1.1.19-1.fc11
/usr/lib/rpm/pythondeps.sh: line 8: python: command not found
/usr/lib/rpm/pythondeps.sh: line 8: python: command not found
Provides:
...

The missing BuildRequires doesn't only miss byte-compilation (which can in 
turn leave leftover *.py[co] files), it'll also cause missing 
dependencies. So that's something to watch out for. Yum-utils I just 
fixed to buildrequire python.

 	- Panu -




More information about the devel mailing list