From d6c1e56a79f3e96ae89ef048f0001278763dcff0 Mon Sep 17 00:00:00 2001 From: "paul.profizi" Date: Mon, 24 Jun 2024 16:33:12 +0200 Subject: [PATCH 1/2] Fix dpf-site.zip update on custom_operator.py/update_virtual_environment_for_custom_operators Signed-off-by: paul.profizi --- src/ansys/dpf/core/custom_operator.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ansys/dpf/core/custom_operator.py b/src/ansys/dpf/core/custom_operator.py index 1b696848e58..5114afcf9f4 100644 --- a/src/ansys/dpf/core/custom_operator.py +++ b/src/ansys/dpf/core/custom_operator.py @@ -8,6 +8,7 @@ import abc import ctypes +import glob import os import pathlib import re @@ -79,6 +80,7 @@ def update_virtual_environment_for_custom_operators( # Store original dpf-site.zip for this DPF Server if no original is stored if not os.path.exists(os.path.dirname(original_dpf_site_zip_path)): os.mkdir(os.path.dirname(original_dpf_site_zip_path)) + if not os.path.exists(original_dpf_site_zip_path): shutil.move(src=current_dpf_site_zip_path, dst=original_dpf_site_zip_path) # Get the current paths to site_packages import site @@ -93,11 +95,16 @@ def update_virtual_environment_for_custom_operators( warnings.warn("Could not find a currently loaded site-packages folder to update from.") return # If an ansys.dpf.core.path file exists, then the installation is editable - path_file = os.path.join(current_site_packages_path, "ansys.dpf.core.pth") + search_path = pathlib.Path(current_site_packages_path) + potential_editable = list(search_path.rglob("__editable__.ansys_dpf_core-*.pth")) + if potential_editable: + path_file = potential_editable[0] + else: # Keep for older setuptools versions + path_file = os.path.join(current_site_packages_path, "ansys.dpf.core.pth") if os.path.exists(path_file): # Treat editable installation of ansys-dpf-core with open(path_file, "r") as f: - current_site_packages_path = f.readline() + current_site_packages_path = f.readline().strip() with tempfile.TemporaryDirectory() as tmpdir: os.mkdir(os.path.join(tmpdir, "ansys_dpf_core")) ansys_dir = os.path.join(tmpdir, "ansys_dpf_core") From 9f72bc557cf19808cbea181d6377733d53ac4924 Mon Sep 17 00:00:00 2001 From: "paul.profizi" Date: Mon, 24 Jun 2024 17:53:43 +0200 Subject: [PATCH 2/2] Fix Code Quality Signed-off-by: paul.profizi --- src/ansys/dpf/core/custom_operator.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ansys/dpf/core/custom_operator.py b/src/ansys/dpf/core/custom_operator.py index 5114afcf9f4..7da42318500 100644 --- a/src/ansys/dpf/core/custom_operator.py +++ b/src/ansys/dpf/core/custom_operator.py @@ -8,7 +8,6 @@ import abc import ctypes -import glob import os import pathlib import re