From 96c42ae6492913d9adac9e03b78e24882514eab2 Mon Sep 17 00:00:00 2001 From: Hugo Saporetti Junior Date: Thu, 3 Oct 2024 16:22:48 -0300 Subject: [PATCH] Fix project.ext.python --- gradle/dependencies.gradle | 29 ++++++++++-- gradle/python.gradle | 2 +- src/main/requirements.txt | 47 ------------------- .../resources/application-test.properties | 3 +- src/test/test_main.py | 4 +- 5 files changed, 31 insertions(+), 54 deletions(-) delete mode 100644 src/main/requirements.txt diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index e1cd7d82..67c1a426 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -7,10 +7,33 @@ */ import org.gradle.internal.os.OperatingSystem; +String detectPython() { + def pythonHome = System.getenv('PYTHON_HOME') ?: null + if (pythonHome != null) { + return pythonHome + '/python3' + } + + def output = new ByteArrayOutputStream() + exec { + commandLine 'bash', '-c', 'command -v python3' + standardOutput = output + } + + pythonHome = output.toString().trim() + assert pythonHome != null && !pythonHome.isEmpty(), "Could not find any installed python3 version" + + return pythonHome +} + + /* Project file definitions */ -project.ext.depsFile = "$project.projectDir/dependencies.hspd" -project.ext.reqsFile = "$project.projectDir/src/main/requirements.txt" -project.ext.os = OperatingSystem.current().getName() +ext { + depsFile = "$project.projectDir/dependencies.hspd" + reqsFile = "$project.projectDir/src/main/requirements.txt" + os = OperatingSystem.current().getName() + python = detectPython() + pyrcc = 'pyrcc5' +} /* Version compatibility mode map */ def modesMap = [ diff --git a/gradle/python.gradle b/gradle/python.gradle index 6a91b568..bacf1b30 100644 --- a/gradle/python.gradle +++ b/gradle/python.gradle @@ -109,7 +109,7 @@ task compileQrc(type: Task) { }.each { File file -> if (verbose) println "Compiling Qt Resource -> ${file.name}" exec { - commandLine project.pyrcc, '-m', 'py_compile', file.path + commandLine project.pyrcc, file.path } } } diff --git a/src/main/requirements.txt b/src/main/requirements.txt deleted file mode 100644 index d6966e93..00000000 --- a/src/main/requirements.txt +++ /dev/null @@ -1,47 +0,0 @@ -###### AUTO-GENERATED Requirements file for: AskAI ###### - -hspylib>=1.12.50 -hspylib-clitt>=0.9.138 -hspylib-setman>=0.10.41 -retry2>=0.9.5 -pause>=0.3 -tqdm>=4.66.5 -pyperclip>=1.9.0 -python-magic>=0.4.27 -pytz>=2024.1 -langchain>=0.3.0 -langchain-openai>=0.2.0 -langchain-community>=0.3.1 -langchain-google-community>=2.0.0 -openai-whisper>=20231117 -openai>=1.48.0 -google-api-python-client>=2.147.0 -fake_useragent>=1.5.1 -requests>=2.32.3 -urllib3>=1.26.20 -protobuf>=4.25.4 -aiohttp>=3.10.5 -html2text>=2024.2.26 -rich>=13.8.1 -textual>=0.80.1 -soundfile>=0.12.1 -PyAudio>=0.2.14 -SpeechRecognition>=3.10.4 -opencv-python>=4.10.0.84 -pyautogui>=0.9.54 -torch>=2.2.0 -torchvision>=0.17.2 -open-clip-torch -opentelemetry-api>=1.27.0 -opentelemetry-sdk>=1.27.0 -opentelemetry-proto>=1.27.0 -transformers>=4.44.2 -unstructured>=0.15.8 -unstructured[md]>=0.15.8 -tiktoken>=0.7.0 -stanza==1.1.1 -nltk>=3.9.1 -faiss-cpu~=1.8.0 -chromadb>=0.5.5 -deepl>=1.18.0 -argostranslate==1.9.1 diff --git a/src/test/resources/application-test.properties b/src/test/resources/application-test.properties index ecf02e4d..8ae513a9 100644 --- a/src/test/resources/application-test.properties +++ b/src/test/resources/application-test.properties @@ -1 +1,2 @@ -# Main test application property file \ No newline at end of file +# Main test application property file +any.property=12345 diff --git a/src/test/test_main.py b/src/test/test_main.py index 230f59a0..2d436109 100644 --- a/src/test/test_main.py +++ b/src/test/test_main.py @@ -27,11 +27,11 @@ class TestMain(unittest.TestCase): # Setup tests def setUp(self): - resource_dir = "{}/resources".format(TEST_DIR) + resource_dir = f"{TEST_DIR}/resources" os.environ["ACTIVE_PROFILE"] = "test" self.configs = AppConfigs(resource_dir=resource_dir) self.assertIsNotNone(self.configs) - self.assertIsNotNone(AppConfigs.INSTANCE) + self.assertEqual(self.configs.get_int('any.property'), 12345) log.info(self.configs) # Teardown tests