[Distutils] bdist_rpm fails due to bytecompiled modules

Stefan Seefeld seefeld at sympatico.ca
Wed Dec 6 05:28:36 CET 2006


Christopher Blunck wrote:

> distutils/setuptools creates .pyc files - that's ok.
> 
> here's how the problem occurs: 
> 
> 1.) distutils generates a .spec file with an %install that calls
>     setup.py like below.  .py and .pyc files are generated, and are
>     included in the INSTALLED_FILES record.  see below for what is
>     called in %install:
> 
> python setup.py install --single-version-externally-managed --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES
> 
> 
> 2.) rpmbuild is called, and it generates a shell script that calls the
>     command above.  AFTER that command is executed, rpmbuild calls some
>     strip commands as well as brp-python-bytecompile.
>     brp-python-bytecompile generates .pyo files from .pyc but it does not
>     update INSTALLED_FILES (because that is a distutils artifact that
>     rpmbuild doesn't know about)
> 
> 3.) rpmbuild calls into %install, and INSTALLED_FILES is loaded.  it
>     does not include the .pyo files that rpmbuild created.  since
>     there are unpackaged files (the .pyo files) that exist in the
>     installation directory that are not referenced in the
>     INSTALLED_FILES file, rpmbuild chokes with an error.
> 
> 
> step #3 is where the error occurs.  it's basically an inconsistency
> between distutils and rpmbuild.  i can run distutils to generate
> optimized modules (.pyo) but that doesn't apply to my scripts.  as a
> result i still have unpackaged files...

Thanks for the detailed analysis !
It seems a workaround is to provide an install command that creates those
.pyo files upfront, so they find their way into the INSTALLED_FILES list.

Thus, I tried 'python setup.py bdist_rpm --install-script=install',
where the content of 'install' is
'python setup.py install --optimize=1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES',
and voila ! It works !

Not sure whether it is worth holding your breath for someone to fix distutils. :-(

Thanks,
		Stefan

-- 

      ...ich hab' noch einen Koffer in Berlin...


More information about the Distutils-SIG mailing list