Bug 1862714

Summary: LIBSYSTEMD_VERSION value format change crashes systemd-python pip install
Product: Red Hat Enterprise Linux 8 Reporter: Carlos Goncalves <cgoncalves>
Component: systemdAssignee: systemd-maint
Status: CLOSED ERRATA QA Contact: Frantisek Sumsal <fsumsal>
Severity: high Docs Contact:
Priority: unspecified    
Version: 8.3CC: dtardon, fressi, jamacku, msekleta, ruairidh, sjayapra, systemd-maint-list
Target Milestone: rcKeywords: Regression
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemd-239-42.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 14:53:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Carlos Goncalves 2020-08-01 17:59:31 UTC
Command "pip install systemd-python" fails with the error log below.

LIBSYSTEMD_VERSION has change its format to become a string in RHEL 8.3 from just an integer up to RHEL 8.2:  -DLIBSYSTEMD_VERSION=239 (239-37.el8)

========
RHEL 8.2
========

$ cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.2 (Ootpa)

$ pkg-config --modversion libsystemd                                              
239

$ rpm -qa | grep systemd
systemd-pam-239-29.el8.aarch64
systemd-udev-239-29.el8.aarch64
systemd-devel-239-29.el8.aarch64
systemd-container-239-29.el8.aarch64
systemd-libs-239-29.el8.aarch64
systemd-239-29.el8.aarch64
rpm-plugin-systemd-inhibit-4.14.2-37.el8.aarch64

=============
RHEL 8.3 beta
=============

$ cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.3 Beta (Ootpa)

$ pkg-config --modversion libsystemd
239 (239-37.el8)

$ rpm -qa | grep systemd
rpm-plugin-systemd-inhibit-4.14.3-4.el8.aarch64
systemd-239-37.el8.aarch64
systemd-libs-239-37.el8.aarch64
systemd-pam-239-37.el8.aarch64
systemd-udev-239-37.el8.aarch64
systemd-devel-239-37.el8.aarch64


$ sudo pip install systemd-python
  ERROR: Command errored out with exit status 1:                                                                                                                                                                                              
   command: /usr/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cjx43znd/systemd-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cjx43znd/systemd-python/setup.py'"'"';f=getattr(tokenize, '"
'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-7ldwlu22
'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-7ldwlu22                                                     [55/398]
       cwd: /tmp/pip-install-cjx43znd/systemd-python/                                                                                                                                                                                         
  Complete output (32 lines):                                                                                                                                                                                                                 
  running bdist_wheel                                                                                                                                                                                                                         
  running build                                                                                                                                                                                                                               
  running build_py                                                                                                                                                                                                                            
  package init file 'systemd/test/__init__.py' not found (or not a regular file)                                                                                                                                                              
  creating build                                                                                                                                                                                                                              
  creating build/lib.linux-aarch64-3.6                                                                                                                                                                                                        
  creating build/lib.linux-aarch64-3.6/systemd                                                                                                                                                                                                
  copying systemd/__init__.py -> build/lib.linux-aarch64-3.6/systemd                                                                                                                                                                          
  copying systemd/journal.py -> build/lib.linux-aarch64-3.6/systemd                                                                                                                                                                           
  copying systemd/daemon.py -> build/lib.linux-aarch64-3.6/systemd                                                                                                                                                                            
  creating build/lib.linux-aarch64-3.6/systemd/test                                                                                                                                                                                           
  copying systemd/test/test_daemon.py -> build/lib.linux-aarch64-3.6/systemd/test                                                                                                                                                             
  copying systemd/test/test_journal.py -> build/lib.linux-aarch64-3.6/systemd/test                                                                                                                                                            
  copying systemd/test/test_login.py -> build/lib.linux-aarch64-3.6/systemd/test                                                                                                                                                              
  running build_ext                                                                                                                                                                                                                           
  building 'systemd/_journal' extension                                                                                                                                                                                                       
  creating build/temp.linux-aarch64-3.6                                                                                                                                                                                                       
  creating build/temp.linux-aarch64-3.6/systemd                                                                                                                                                                                               
  gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-swit
ches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switche
s -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -
fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPACKAGE_VERSION="234" -DLIBSYSTEMD_VERSION=239 (239-37.el8) -I/usr/include/python3.6m -c systemd/_journal.c -o build/temp.linux-aarch64-3.6/systemd/_
journal.o -Werror=implicit-function-declaration                                                                                                                                                                                               
  gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-swit
ches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switche
s -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -
fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPACKAGE_VERSION="234" -DLIBSYSTEMD_VERSION=239 (239-37.el8) -I/usr/include/python3.6m -c systemd/pyutil.c -o build/temp.linux-aarch64-3.6/systemd/pyu
til.o -Werror=implicit-function-declaration                                                                                                                                                                                                   
  gcc -pthread -shared -Wl,-z,relro -Wl,-z,now -g -Wl,-z,relro -Wl,-z,now -g build/temp.linux-aarch64-3.6/systemd/_journal.o build/temp.linux-aarch64-3.6/systemd/pyutil.o -L/usr/lib64 -lsystemd -lpython3.6m -o build/lib.linux-aarch64-3.6/
systemd/_journal.cpython-36m-aarch64-linux-gnu.so                                                                                                                                                                                             
  building 'systemd/_reader' extension                                                                                                                                                                                                        
  gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-swit
ches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switche
s -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -
fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPACKAGE_VERSION="234" -DLIBSYSTEMD_VERSION=239 (239-37.el8) -I/usr/include/python3.6m -c systemd/_reader.c -o build/temp.linux-aarch64-3.6/systemd/_r
eader.o -Werror=implicit-function-declaration                                                                                                                                                                                                 
  <command-line>: error: missing binary operator before token "("                                                                                                                                                                             
  systemd/_reader.c:41:5: note: in expansion of macro ‘LIBSYSTEMD_VERSION’                                                                                                                                                                    
   #if LIBSYSTEMD_VERSION >= 229                                                                                                                                                                                                              
       ^~~~~~~~~~~~~~~~~~                                                                                                                                                                                                                     
  <command-line>: error: missing binary operator before token "("                                                                                                                                                                             
  systemd/_reader.c:47:5: note: in expansion of macro ‘LIBSYSTEMD_VERSION’                                                                                                                                                                    
   #if LIBSYSTEMD_VERSION >= 230                                                                                                                                                                                                              
       ^~~~~~~~~~~~~~~~~~                                                                                                                                                                                                                     
  error: command 'gcc' failed with exit status 1                                                                                                                                                                                              
  ----------------------------------------                                                                                                                                                                                                    
  ERROR: Failed building wheel for systemd-python                                                                                                                                                                                             
DEPRECATION: Could not build wheels for systemd-python which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel bu
ild issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.                                                                                                                                  
    ERROR: Command errored out with exit status 1:                                                                                                                                                                                            
     command: /usr/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cjx43znd/systemd-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cjx43znd/systemd-python/setup.py'"'"';f=getattr(tokenize, 
'"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-g78xaig4/install-record.txt --single-version-externally-managed 
--compile --install-headers /usr/local/include/python3.6m/systemd-python
         cwd: /tmp/pip-install-cjx43znd/systemd-python/
    Complete output (32 lines):
    running install
    running build
    running build_py
    package init file 'systemd/test/__init__.py' not found (or not a regular file)
    creating build
    creating build/lib.linux-aarch64-3.6
    creating build/lib.linux-aarch64-3.6/systemd
    copying systemd/__init__.py -> build/lib.linux-aarch64-3.6/systemd
    copying systemd/journal.py -> build/lib.linux-aarch64-3.6/systemd
    copying systemd/daemon.py -> build/lib.linux-aarch64-3.6/systemd
    creating build/lib.linux-aarch64-3.6/systemd/test
    copying systemd/test/test_daemon.py -> build/lib.linux-aarch64-3.6/systemd/test
    copying systemd/test/test_journal.py -> build/lib.linux-aarch64-3.6/systemd/test
    copying systemd/test/test_login.py -> build/lib.linux-aarch64-3.6/systemd/test
    running build_ext
    building 'systemd/_journal' extension
    creating build/temp.linux-aarch64-3.6
    creating build/temp.linux-aarch64-3.6/systemd
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPACKAGE_VERSION="234" -DLIBSYSTEMD_VERSION=239 (239-37.el8) -I/usr/include/python3.6m -c systemd/_journal.c -o build/temp.linux-aarch64-3.6/systemd/_journal.o -Werror=implicit-function-declaration
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPACKAGE_VERSION="234" -DLIBSYSTEMD_VERSION=239 (239-37.el8) -I/usr/include/python3.6m -c systemd/pyutil.c -o build/temp.linux-aarch64-3.6/systemd/pyutil.o -Werror=implicit-function-declaration
    gcc -pthread -shared -Wl,-z,relro -Wl,-z,now -g -Wl,-z,relro -Wl,-z,now -g build/temp.linux-aarch64-3.6/systemd/_journal.o build/temp.linux-aarch64-3.6/systemd/pyutil.o -L/usr/lib64 -lsystemd -lpython3.6m -o build/lib.linux-aarch64-3.6/systemd/_journal.cpython-36m-aarch64-linux-gnu.so
    building 'systemd/_reader' extension
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPACKAGE_VERSION="234" -DLIBSYSTEMD_VERSION=239 (239-37.el8) -I/usr/include/python3.6m -c systemd/_reader.c -o build/temp.linux-aarch64-3.6/systemd/_reader.o -Werror=implicit-function-declaration
    <command-line>: error: missing binary operator before token "("
    systemd/_reader.c:41:5: note: in expansion of macro ‘LIBSYSTEMD_VERSION’
     #if LIBSYSTEMD_VERSION >= 229
         ^~~~~~~~~~~~~~~~~~
    <command-line>: error: missing binary operator before token "("
    systemd/_reader.c:47:5: note: in expansion of macro ‘LIBSYSTEMD_VERSION’
     #if LIBSYSTEMD_VERSION >= 230
         ^~~~~~~~~~~~~~~~~~
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cjx43znd/systemd-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cjx43znd/systemd-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-g78xaig4/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/systemd-python Check the logs for full command output.

Comment 1 David Tardon 2020-08-03 07:34:57 UTC
This is a regression from bug 1804252. The fix for it is missing https://github.com/systemd/systemd/commit/a67c318df8800ba98d7361308937ed276dc73982 .

Comment 3 Lukáš Nykrýn 2020-11-02 13:44:01 UTC
fix merged to github master branch -> https://github.com/systemd-rhel/rhel-8/pull/116

Comment 9 Federico Ressi 2020-12-16 09:01:32 UTC
To workaround this problem in DevStack I started writing patch [1] to install python3-systemd package instead of using this package from PIP. This solution looks to work also for other Linux distros like Fedora 32, Ubuntu Focal and Suse 15 according to the results of OpenStack CI jobs.

[1] https://review.opendev.org/c/openstack/devstack/+/766740

Comment 13 errata-xmlrpc 2021-05-18 14:53:56 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: systemd security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:1611