I have an IDAPython script written for a specific analysis. Also, I am using another in-house tool for the same analysis that, too, exposes Python API. My intention is to augment the script such that when it is run within IDA, it'll run IDA specific methods and when it is run outside IDA, it has to call the method specific to the in-house tool. Does IDAPython provide any special environment variable to detect if a Python script is running inside IDA environment?
I don't think there is directly, but there is a trick I've seen a few times (works with any dependency):
try: import idc print 'ida' except Exception as e: print 'no ida'
You may set a special variable instead of the print statements.
Requires that your systems python and IDAs python are actually separate (the default case)