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

Run.py: Prioritize sibling modules over installed modules #2772

Merged
merged 4 commits into from
Feb 10, 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
18 changes: 12 additions & 6 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,20 @@ def prepare():
# Find the directories for the source and build
root = abspath(dirname(realpath(__file__)))

# TODO: Do we prioritize the sibling repo or the installed package?
# TODO: Can we use sasview/run.py from a distributed sasview.exe?
# Put supporting packages on the path if they are not already available.
for sibling in ('periodictable', 'bumps', 'sasdata', 'sasmodels'):
try:
import_module(sibling)
except:
addpath(joinpath(root, '..', sibling))
# run.py is only used by developers. The sibling directory should be the priority over installed packages.
# This allows developers to modify and use separate packages simultaneously.
devel_path = joinpath(root, '..', sibling)
if os.path.exists(devel_path):
addpath(devel_path)
else:
try:
import_module(sibling)
except ImportError:
raise ImportError(f"The {sibling} module is not available. Either pip install it in your environment or"
f" clone the repository into a directory level with the sasview directory.")


# Put the source trees on the path
addpath(joinpath(root, 'src'))
Expand Down
Loading