-
Notifications
You must be signed in to change notification settings - Fork 167
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
Remove the need of set up environment variables in CLI or MetaCall #233
Comments
@viferga I would like to get started by picking up this issue. Can you please assign it to me? |
The order of priority for setting up the paths is:
The paths (and environment variables) are initialized here: core/source/loader/source/loader_env.c Line 30 in 35652b3
As you can see the code is pretty copy pasted. It can be improved but there's no need to do so in this patch, you can focus only in removing the need of setting up the environment variables. My suggestion is to create a function that obtains the prefix path when metacall initializes (in metacall_initialize or similar), and then this can be queried by the different modules in order to obtain the respective path and then generate its own paths. Just a reminder, we snake case (function_hello) instead of camel case (functionHello). |
@viferga I wanted to discuss this approach with you. I was planning to define a function
|
I think it's fine but I would start doing the function that gives you the path, and only that, then create a unit test for it. Once you have this, which works independently of metacall, then you can try to integrate this into the codebase. With unit tests you ensure your function works properly. I can help you to set up them. We use a lot Test Driven Development in this project, it helps us a lot to verify that the changes we do work properly. Also, depending on the module we are, usually we set the module name as a prefix. For example metacall module has functions starting by |
🚀 Feature
MetaCall has the need to set up multiple environment variables ( https://github.com/metacall/core/blob/develop/docs/README.md#42-environment-variables ), for example, in order to find the global configuration or plugins. This can be basically avoided if we use a trick for locating
libmetacall.so
/metacall.dll
/libmetacall.dylib
from the executable itself. This solution is platform dependent but we can use it just as a fallback in case the environment variables are not detected, so MetaCall is still able to work as normally it does in multiple platforms.The trick is the following:
python.exe
ornode.exe
( Allow MetaCall to run frompython.exe
ornode.exe
#231 ), and in this caselibmetacall.so
/metacall.dll
/libmetacall.dylib
will be linked dynamically bydlopen
orLoadLibrary
.libmetacall.so
/metacall.dll
/libmetacall.dylib
(taking into account versioning in the future if any, probably we need some way of parsing the library name or finding a symbol inside of the library in order to verify that it is the correct library)./home/custom/metacall/lib/libmetacall.so
, we can take this path and obtain all the environment variables from it. All the*_LIBRARY_PATH
would be pointing to/home/custom/metacall/lib
and the configurationCONFIGURATION_PATH
can be deduced from it too and it will be pointing to/home/custom/metacall/configurations/global.json
.With this we remove all the need for setting up metacall and we improve the user experience with it, specially when using Ports because it is problematic to set them up properly.
Something we must review and it's critical in order to make this work properly, some loaders rely on getting the environment variables by themselves, specially in node loader or typescript loader with
bootstrap.js
andbootstrap.ts
. We should remove the environment variable access from them and pass them from the C/C++ side, so it works too. This can be done easily because in theinitialize
step of each loader, we pass the configuration with the required paths as values, we can take them from there and pass them into JavaScript land.Some of the reference for implementing this can be found here:
The function for finding the module path can be implemented either on dynlink or in portability (dynlink can be interesting because it contains suffixes and prefixes for the dynamic libraries for each platform).
The text was updated successfully, but these errors were encountered: