Skip to content

Commit 03c64e9

Browse files
authored
Fix update_virtual_environment_for_custom_operators (#1632)
* Fix dpf-site.zip update on custom_operator.py/update_virtual_environment_for_custom_operators Signed-off-by: paul.profizi <[email protected]> * Fix Code Quality Signed-off-by: paul.profizi <[email protected]> --------- Signed-off-by: paul.profizi <[email protected]>
1 parent 86b7672 commit 03c64e9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/ansys/dpf/core/custom_operator.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def update_virtual_environment_for_custom_operators(
7979
# Store original dpf-site.zip for this DPF Server if no original is stored
8080
if not os.path.exists(os.path.dirname(original_dpf_site_zip_path)):
8181
os.mkdir(os.path.dirname(original_dpf_site_zip_path))
82+
if not os.path.exists(original_dpf_site_zip_path):
8283
shutil.move(src=current_dpf_site_zip_path, dst=original_dpf_site_zip_path)
8384
# Get the current paths to site_packages
8485
import site
@@ -93,11 +94,16 @@ def update_virtual_environment_for_custom_operators(
9394
warnings.warn("Could not find a currently loaded site-packages folder to update from.")
9495
return
9596
# If an ansys.dpf.core.path file exists, then the installation is editable
96-
path_file = os.path.join(current_site_packages_path, "ansys.dpf.core.pth")
97+
search_path = pathlib.Path(current_site_packages_path)
98+
potential_editable = list(search_path.rglob("__editable__.ansys_dpf_core-*.pth"))
99+
if potential_editable:
100+
path_file = potential_editable[0]
101+
else: # Keep for older setuptools versions
102+
path_file = os.path.join(current_site_packages_path, "ansys.dpf.core.pth")
97103
if os.path.exists(path_file):
98104
# Treat editable installation of ansys-dpf-core
99105
with open(path_file, "r") as f:
100-
current_site_packages_path = f.readline()
106+
current_site_packages_path = f.readline().strip()
101107
with tempfile.TemporaryDirectory() as tmpdir:
102108
os.mkdir(os.path.join(tmpdir, "ansys_dpf_core"))
103109
ansys_dir = os.path.join(tmpdir, "ansys_dpf_core")

0 commit comments

Comments
 (0)