systemd / pystemd

A thin Cython-based wrapper on top of libsystemd, focused on exposing the dbus API via sd-bus in an automated and easy to consume way.
GNU Lesser General Public License v2.1
414 stars 36 forks source link

Python 3.11 support #70

Closed Paolo97Gll closed 1 year ago

Paolo97Gll commented 1 year ago

I can't install pystemd with Python 3.11 because of the following error: pystemd/journal.c:214:12: fatal error: longintrepr.h: No such file or directory. I found a similar solved issue in https://github.com/aio-libs/aiohttp/issues/6600. Unfortunately, I never worked with CPython or Cython, so I can't say more about this error.

This is the pip install pystemd command output:

Collecting pystemd
  Using cached pystemd-0.10.0.tar.gz (277 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pystemd
  Building wheel for pystemd (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [43 lines of output]
      /home/osservatorio/venv/lib/python3.11/site-packages/setuptools/config/setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
        warnings.warn(msg, warning_class)
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-311
      creating build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/run.py -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/exceptions.py -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/base.py -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/__version__.py -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/utils.py -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/__init__.py -> build/lib.linux-x86_64-cpython-311/pystemd
      creating build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      copying pystemd/systemd1/manager.py -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      copying pystemd/systemd1/unit.py -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      copying pystemd/systemd1/unit_signatures.py -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      copying pystemd/systemd1/__init__.py -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      creating build/lib.linux-x86_64-cpython-311/pystemd/machine1
      copying pystemd/machine1/manager.py -> build/lib.linux-x86_64-cpython-311/pystemd/machine1
      copying pystemd/machine1/machine.py -> build/lib.linux-x86_64-cpython-311/pystemd/machine1
      copying pystemd/machine1/__init__.py -> build/lib.linux-x86_64-cpython-311/pystemd/machine1
      creating build/lib.linux-x86_64-cpython-311/pystemd/DBus
      copying pystemd/DBus/__init__.py -> build/lib.linux-x86_64-cpython-311/pystemd/DBus
      copying pystemd/RELEASE -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/daemon.pyi -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/utils.pyi -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/base.pyi -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/dbuslib.pyi -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/__init__.pyi -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/systemd1/manager.pyi -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      copying pystemd/systemd1/unit.pyi -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      running build_ext
      building 'pystemd.journal' extension
      creating build/temp.linux-x86_64-cpython-311
      creating build/temp.linux-x86_64-cpython-311/pystemd
      x86_64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/osservatorio/venv/include -I/usr/include/python3.11 -c pystemd/journal.c -o build/temp.linux-x86_64-cpython-311/pystemd/journal.o
      pystemd/journal.c:214:12: fatal error: longintrepr.h: No such file or directory
        214 |   #include "longintrepr.h"
            |            ^~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pystemd
  Running setup.py clean for pystemd
Failed to build pystemd
Installing collected packages: pystemd
  Running setup.py install for pystemd ... error
  error: subprocess-exited-with-error

  × Running setup.py install for pystemd did not run successfully.
  │ exit code: 1
  ╰─> [45 lines of output]
      /home/osservatorio/venv/lib/python3.11/site-packages/setuptools/config/setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
        warnings.warn(msg, warning_class)
      running install
      /home/osservatorio/venv/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-311
      creating build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/run.py -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/exceptions.py -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/base.py -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/__version__.py -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/utils.py -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/__init__.py -> build/lib.linux-x86_64-cpython-311/pystemd
      creating build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      copying pystemd/systemd1/manager.py -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      copying pystemd/systemd1/unit.py -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      copying pystemd/systemd1/unit_signatures.py -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      copying pystemd/systemd1/__init__.py -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      creating build/lib.linux-x86_64-cpython-311/pystemd/machine1
      copying pystemd/machine1/manager.py -> build/lib.linux-x86_64-cpython-311/pystemd/machine1
      copying pystemd/machine1/machine.py -> build/lib.linux-x86_64-cpython-311/pystemd/machine1
      copying pystemd/machine1/__init__.py -> build/lib.linux-x86_64-cpython-311/pystemd/machine1
      creating build/lib.linux-x86_64-cpython-311/pystemd/DBus
      copying pystemd/DBus/__init__.py -> build/lib.linux-x86_64-cpython-311/pystemd/DBus
      copying pystemd/RELEASE -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/daemon.pyi -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/utils.pyi -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/base.pyi -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/dbuslib.pyi -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/__init__.pyi -> build/lib.linux-x86_64-cpython-311/pystemd
      copying pystemd/systemd1/manager.pyi -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      copying pystemd/systemd1/unit.pyi -> build/lib.linux-x86_64-cpython-311/pystemd/systemd1
      running build_ext
      building 'pystemd.journal' extension
      creating build/temp.linux-x86_64-cpython-311
      creating build/temp.linux-x86_64-cpython-311/pystemd
      x86_64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/osservatorio/venv/include -I/usr/include/python3.11 -c pystemd/journal.c -o build/temp.linux-x86_64-cpython-311/pystemd/journal.o
      pystemd/journal.c:214:12: fatal error: longintrepr.h: No such file or directory
        214 |   #include "longintrepr.h"
            |            ^~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pystemd

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Thanks for the support!

Paolo97Gll commented 1 year ago

UPDATE

The code in the main branch has no problem and perfectly installs with the following command:

pip install git+https://github.com/facebookincubator/pystemd

As noted in #69 the package in pypi is outdated (version in pypi: 0.10.0, version in main branch: 0.11.0). An update of the version uploaded on pypi with the version currently in the main branch will solve this issue.

EDIT: before installing from the repo, you need to manually install cython with pip install cython

aleivag commented 1 year ago

Hi...

yes you are right, the package in pypi its really old, and I just got around to this... on monday i'll release a new version, update setup.py to reflect compatibility and publish to pypi

thanks for flaging this up

aleivag commented 1 year ago

added suport!

https://pypi.org/project/pystemd/0.11.0/