5b578a8 Set $RPM_BUILD_ROOT in %{python3_...} macros, for alternate sysconfig install scheme

Authored and Committed by churchyard 2 years ago
    Set $RPM_BUILD_ROOT in %{python3_...} macros, for alternate sysconfig install scheme
    
    Our Pythons currently patches distutils to install packages to
    /usr/lib(64)/pythonX.Y/site-packages when the $RPM_BUILD_ROOT environment
    variable is set (and to /usr/local/lib(64)/pythonX.Y/site-packages otherwise).
    With the deprecation of distutils [1] we want to change the patch to create
    and use a different sysconfig install scheme [2].
    
    However, we have realized that macros defined as %(%{__python3} ...) don't
    "see" the environment variables set by rpmbuild because they are expanded earlier
    and hence e.g. %{python3_sitelib} evaluates to
    /usr/local/lib/python3.X/site-packages -- which is not desired.
    To be able to reliably detect an RPM build environment by checking
    the presence of the $RPM_BUILD_ROOT environment variable,
    we manually set it in the macro definitions.
    
    Since %{buildroot} in not fully populated
    (e.g. it can expand literally to
    /home/anna/rpmbuild/BUILDROOT/%{NAME}-%{VERSION}-%{RELEASE}.x86_64),
    we don't use it here.
    The variable simply needs to present in the environment.
    
    See also the analysis of the build failures when this is not done [3].
    
    [1] https://www.python.org/dev/peps/pep-0632/
    [2] https://bugs.python.org/issue43976
    [3] https://src.fedoraproject.org/rpms/python3.10/pull-request/63#comment-79042
    
        
file modified
+9 -7
file modified
+9 -7
file modified
+5 -1