This question is about calling a Mathematica Package (.m file) from Python employing the "Wolfram Client Library for Python" (https://github.com/WolframResearch/WolframClientForPython).
For concreteness, consider the following Mathematica Package:
BeginPackage["basicPackage`"]
AddTwo::usage = "AddTwo[a, b] returns a+b";
Begin["Private`"]
AddTwo[a_, b_] := a + b;
End[]
EndPackage[]
Aim: call AddTwo from Python using the Wolfram Client Library for Python. If this is not currently supported add this feature to the library.
The documentation for the library is located at: https://reference.wolfram.com/language/WolframClientForPython/index.html.
A similar question, asked before the Wolfram Client Library for Python was released, is: How to run a Mathematica package (.m) from python?
wl.SetDirectory. Be sure it is a valid with the\character property escaped in Python syntax. – Edmund Apr 03 '20 at 19:50ResetDirectory[]is not guaranteed to reset the directory back to what it was, sinceSetDirectory[]could've been called multiple times by the code in the package being loaded. In general, theSetDirectory-ResetDirectoryis a failed concept, which I would avoid using. – Leonid Shifrin Apr 04 '20 at 00:04