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

Add PANDA_PLUGIN_PATH #1408

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
Open

Add PANDA_PLUGIN_PATH #1408

wants to merge 11 commits into from

Conversation

be32826
Copy link
Contributor

@be32826 be32826 commented Jan 5, 2024

Add a colon-separated PANDA_PLUGIN_PATH environment variable for specifying plugin directories similar to PATH, PYTHONPATH, and LD_LIBRARY_PATH.

@be32826 be32826 marked this pull request as draft January 6, 2024 04:27
@be32826 be32826 marked this pull request as ready for review January 9, 2024 16:48
Copy link
Member

@jamcleod jamcleod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall design question: using some combination of PANDA_PATH and PANDA_PLUGIN_DIR depending on needs has been the way of handling this usecase in the past. Is there a reason we're making a new variable with overlapping usecases rather than fixing the previous implementation?

The main differences I see here are:

  • supports providing multiple paths (beneficial, but I don't think requires adding a new environment variable)
  • supports absolute paths (the current code does support this, albeit inconsistently and definitely has bugs for usecases I haven't personally considered. however to me this would be a reason to fix the current code rather than)

This is mostly coming from a place of wanting to avoid having 5 different ways of doing this, each with their own little bugs, with documentation being unclear which one to use. It's also possible that incrementally deprecating the old system is the correct move, all up for consideration.

not saying these are reasons not to merge, just questions worth considering before merging. also be sure to notify me when the design has been ironed out so I can ensure panda-rs also receives a corresponding update.

plugin_name_ffi = self.ffi.new("char[]", bytes(plugin_name, "utf-8"))
plugin_path_ffi = self.libpanda.panda_plugin_path(plugin_name_ffi)
plugin_path = self.ffi.string(plugin_path_ffi).decode("utf-8")
# TODO: self.libpanda.g_free(plugin_path_ffi)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover TODO comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this is a memory leak without the free, but CFFI doesn't seem to find the g_free() function, which is weird because other parts of the code find g_malloc0(). I don't know what's going on here.

else:
raise ValueError(f"Could not find plugin path. Build dir={build_dir}")
return self.plugin_path
def get_plugin_path(self, plugin_name):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem to cover all the cases from before, was the /usr/local/bin special-casing redundant? it also doesn't appear to perform error propagation/checking, so this is a breaking change (as catching ValueError to handle missing plugins isn't possible)

gchar *plugin_path = attempt_normalize_path(g_strdup_printf(
"%s/%s/%s", *dir,
TARGET_NAME, name_formatted));
if (TRUE == g_file_test(plugin_path, G_FILE_TEST_EXISTS)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit but don't think you need to actually check against glibc TRUE here. just checking for non-zero return is a superset of checking for glib TRUE, so there's no real reason to write in this style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change it but all the other tests in the function use the same style so it would feel inconsistent.

@be32826
Copy link
Contributor Author

be32826 commented Jan 10, 2024

Overall design question: using some combination of PANDA_PATH and PANDA_PLUGIN_DIR depending on needs has been the way of handling this usecase in the past. Is there a reason we're making a new variable with overlapping usecases rather than fixing the previous implementation?

Mostly because I'm afraid of breaking backwards compatibility and I don't know how all the different cases apply to how PANDA is used in practice. Do you think it would be better to make PANDA_PLUGIN_DIR support colon-separated multiple directories instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants