[PATCH] tuna: Fix circular import in setup.py during isolated builds
John Kacur <[email protected]>
| Newsgroups | org.kernel.vger.linux-rt-users |
|---|---|
| Message-ID | <[email protected]> |
The setup.py file was importing TUNA_VERSION from tuna.version module, which caused a ModuleNotFoundError during isolated builds with python-build because the tuna package isn't installed yet in the build environment. This commit replaces the import with a get_version() function that reads tuna/version.py as a text file and parses the version string directly. This approach: - Works in both traditional setup.py builds (CentOS/RHEL RPM style) - Works with modern isolated builds using python -m build - Works when setup.py is removed and only pyproject.toml is used (c10s) - Maintains backward compatibility with all build systems The version is still sourced from tuna/version.py as the single source of truth, but without requiring the package to be importable during the build process. Reported-by: David Runge <[email protected]> Assisted-by: Claude:claude-sonnet-4-5 Signed-off-by: John Kacur <[email protected]> --- setup.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8036a647f698..99253600b20e 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,16 @@ from os.path import isfile, relpath from setuptools import setup # Get the tuna version from a single source -from tuna.version import TUNA_VERSION +# Read version without importing to avoid circular dependency during build +def get_version(): + version_file = os.path.join(os.path.dirname(__file__), 'tuna', 'version.py') + with open(version_file, 'r') as f: + for line in f: + if line.startswith('TUNA_VERSION'): + return line.split('=')[1].strip().strip("'\"") + raise RuntimeError("Unable to find version string") + +TUNA_VERSION = get_version() if isfile("MANIFEST"): os.unlink("MANIFEST") -- 2.55.0