How to write RETE rules in Python for mapping services?

My requirement is to map source to target fields using RETE algorithm in Python and also lookup fields like country code using rules.

How can I create rules for this type of requirement please?

How to write RETE rules in Python for mapping services?