From e64a1bc73b74e8784f955dc4b3a74debb7b40119 Mon Sep 17 00:00:00 2001 From: Aareon Sullivan Date: Tue, 10 Jun 2025 13:32:47 -0500 Subject: [PATCH] Fix undefined __version__ variable in setup.py Replace exec() call with direct string parsing to read version from RNS/_version.py. This resolves the Pylance "reportUndefinedVariable" error while maintaining single-source-of-truth for version management. - Remove exec(open("RNS/_version.py").read()) pattern - Add simple string parsing: f.read().split('=')[1].strip().strip('"') - Eliminates scope issues with version variable access --- setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c828f00..47db9bc 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ import setuptools import sys +from RNS._version import __version__ pure_python = False pure_notice = "\n\n**Warning!** *This package is the zero-dependency version of Reticulum. You should almost certainly use the [normal package](https://pypi.org/project/rns) instead. Do NOT install this package unless you know exactly why you are doing it!*" @@ -9,7 +10,9 @@ if '--pure' in sys.argv: sys.argv.remove('--pure') print("Building pure-python wheel") -exec(open("RNS/_version.py", "r").read()) +with open("RNS/_version.py", "r") as f: + __version__ = f.read().split('=')[1].strip().strip('"') + with open("README.md", "r") as fh: long_description = fh.read()