3.2. Software Collection Macro Files Support

In some cases, you may need to ship macro files with your Software Collection packages. They are located in the %{?scl:%{_root_sysconfdir}}%{!?scl:%{_sysconfdir}}/rpm/ directory, which corresponds to the /etc/rpm/ directory for conventional packages. When shipping macro files, ensure that:
  • You rename the macro files by appending .%{scl} to their names so that they do not conflict with the files from the base system installation.
  • The macros in the macro files are either not expanded, or they are using conditionals, as in the following example:
    %__python2 %{_bindir}/python
    %python2_sitelib %(%{?scl:scl enable %scl '}%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"%{?scl:'})
As another example, there may be a situation where you need to create a Software Collection mypython that depends on a Software Collection python26. The python26 Software Collection defines the %{__python2} macro as in the above sample. This macro will evaluate to /opt/provider/mypython/root/usr/bin/python2, but the python2 binary is only available in the python26 Software Collection (/opt/provider/python26/root/usr/bin/python2).
To be able to build software in the mypython Software Collection environment, ensure that:
  • The macros.python.python26 macro file, which is a part of the python26-python-devel package, contains the following line:
    %__python26_python2 /opt/provider/python26/root/usr/bin/python2
  • And the macro file in the python26-build subpackage, and also the build subpackage in any depending Software Collection, contains the following line:
    %scl_package_override() {%global __python2 %__python26_python2}
This will redefine the %{__python2} macro only if the build subpackage from a corresponding Software Collection is present, which usually means that you want to build software for that Software Collection.