I want to create a Swift app that calls some embedded Python.py files using PythonKit.
In the docs and a sample file it says that I should use
let sys = Python.import("sys")
sys.path.append("/Users/mlboy/PythonTest/") // path to your Python file's directory.
This path is hardcoded and works when I do that with my own path..
But how can I reach those files relatively from the project when they are in the same project directory, so I don't need any hardcoded file.
I thought thats easy, so I did try.....
sys.path.append("./myPythonFiles/")
sys.path.append("./pythonTest/myPythonFiles/")
and some more. But none are working. After some googling I can't find a solution.
Suggestions?
Thank you.
Took me a week of nights to come up with a solution for my similar needs. I am making a command line tool but I want to bundle the (unique) Python code with it. I also want to debug in Xcode, not deploy and run from command line disconnected from debugger most of the time. So my command line tool initializes a main struct (BpK) that initializes another struct PyRunner (first declared as static var bpPy: PyRunner! = nil) that does the Python invocations. My experimental strings are still included as this is WIP. I hope it will evolve into something more elegant.
then in the runner