-
Notifications
You must be signed in to change notification settings - Fork 17
possible fix to get rid of _get_real_dir_from_pth_file empty folder error #1385
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
base: release
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment below
src/esm_motd/esm_motd.py
Outdated
| print(self.message_dict[message]["message"]) | ||
| if mypackage == "esm_tools": | ||
| esm_tools_path = esm_tools._get_real_dir_from_pth_file("") | ||
| esm_tools_path = esm_tools._get_real_dir_from_pth_file("motd_flag") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this mean that esm_tools_path will always be None and consequently the print below will never print the esm_tools_path?
This doesn't look like a fix, but just a patch to get things going.
@chrisdane, if MOTD is giving you troubles in your current branch I recommend you deactivate it by using --no-motd. If that doesn't fix it, then please open an issue.
@pgierz, is this problem existing on release? If it does can you please try to fix it? The function esm_tools._get_real_dir_from_pth_file("") should be able to give you the path of esm_tools independently from where it's installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, ._get_real_dir_from_pth_file("") looks like at the very least like I badly named the function.
This happens on release too, by the way. I'll try to fix it
…for MOTD This commit properly fixes the FileNotFoundError that occurs when using esm_runscripts with venv by replacing the fragile .egg-link parsing approach with a simpler, more reliable method using Python's __file__ attribute. Changes: - Added new get_esm_tools_root_dir() function that uses __file__ to locate the esm_tools installation directory - Works for both editable installs (finds git repo root) and normal installs - Updated MOTD handler to use the new function with proper None handling - Removed the motd_flag workaround from _get_real_dir_from_pth_file The new approach: - Works regardless of virtual environment configuration - Doesn't depend on finding .egg-link files - Handles cases where venv filtering removes the home site-packages - Provides graceful fallback message when path cannot be determined Fixes the issue reported in PR #1385 where the venv filtering logic was too aggressive and prevented finding the .egg-link file in mixed installation scenarios.
|
OK, I have a better way to fix this now :-) @chrisdane, can you please try again and let me know if that works? @mandresm, see if the code is to your liking |
Yeah, this is now good code, thanks :) I'll be trying it with the venv |
Hi
While being on a rather old esm_tools branch, I suddenly had problems using
venvwith this error:Together with @pgierz we made the proposed changes.
Hope this helps,
Chris