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 1 commit
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
11 changes: 9 additions & 2 deletions src/ansys/dpf/core/custom_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import abc
import ctypes
import glob
import os
import pathlib
import re
Expand Down Expand Up @@ -79,6 +80,7 @@
# 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):

Check warning on line 83 in src/ansys/dpf/core/custom_operator.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/custom_operator.py#L83

Added line #L83 was not covered by tests
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 +95,16 @@
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]

Check warning on line 101 in src/ansys/dpf/core/custom_operator.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/custom_operator.py#L98-L101

Added lines #L98 - L101 were not covered by tests
else: # Keep for older setuptools versions
path_file = os.path.join(current_site_packages_path, "ansys.dpf.core.pth")

Check warning on line 103 in src/ansys/dpf/core/custom_operator.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/custom_operator.py#L103

Added line #L103 was not covered by tests
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()

Check warning on line 107 in src/ansys/dpf/core/custom_operator.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/custom_operator.py#L107

Added line #L107 was not covered by tests
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