On Thu, 12 Oct 2023 14:09:25 +0200, Phil Howard <phil@xxxxxxxxxxxxx> said: > Import __version__ from gpiod.version instead of using exec > since the latter is potentially unsafe and unnecessary. > > Signed-off-by: Phil Howard <phil@xxxxxxxxxxxxx> > --- > bindings/python/setup.py | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/bindings/python/setup.py b/bindings/python/setup.py > index 66b7908..278baee 100644 > --- a/bindings/python/setup.py > +++ b/bindings/python/setup.py > @@ -5,6 +5,7 @@ from os import environ, path > from setuptools import setup, Extension, find_packages > from setuptools.command.build_ext import build_ext as orig_build_ext > from shutil import rmtree > +from gpiod.version import __version__ > > > class build_ext(orig_build_ext): > @@ -54,9 +55,6 @@ if "GPIOD_WITH_TESTS" in environ and environ["GPIOD_WITH_TESTS"] == "1": > extensions.append(gpiosim_ext) > extensions.append(procname_ext) > > -with open("gpiod/version.py", "r") as fd: > - exec(fd.read()) > - > setup( > name="libgpiod", > packages=find_packages(exclude=["tests", "tests.*"]), > -- > 2.34.1 > > I get the following with this patch applied: GPIOD_WITH_TESTS=1 \ /usr/bin/python setup.py build_ext --inplace \ --include-dirs=../../include/:../../tests/gpiosim/ \ --library-dirs=../../lib/.libs/:../../tests/gpiosim/.libs/ Traceback (most recent call last): File "/home/brgl/workspace/gitbook/libgpiod/bindings/python/setup.py", line 8, in <module> from gpiod.version import __version__ File "/home/brgl/workspace/gitbook/libgpiod/bindings/python/gpiod/__init__.py", line 10, in <module> from . import _ext ImportError: cannot import name '_ext' from partially initialized module 'gpiod' (most likely due to a circular import) (/home/brgl/workspace/gitbook/libgpiod/bindings/python/gpiod/__init__.py) Bart