Python based constraints

I was wondering if is it possible to create a python based constraint??
Are there any docs or examples of how to accomplish this?

I’ve written the main logic to run and tested it as a button, but I’m looking to add it into a framework so it can be run interactively.

Thanks

Geoff