although it sounds like a lot of work, the easiest way to get started with all of this is to make a simple python package with your code (you could use the cookiecutter template for this). if you install this package into your environment and in Rhino, calling its code from Rhino using RPC is quite straightforward.
as @arpastrana has pointed out, you can then still choose to run the analysis in Rhino or just in an editor with some basic geometric inputs.
i f you provide a little bit more detail about what you are trying to achieve i could point you in the right direction…