Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix update_virtual_environment_for_custom_operators #1632

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/ansys/dpf/core/custom_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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
Expand All @@ -93,11 +94,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")
Expand Down
Loading