Long story short:
- Encrypt your source code
- Write your own python module loader to decrypt your code when importing
- Implement the module loader in C/C++
- You can add more features to the module loader, for example anti-debugger, license control, hardware fingerprint binding, etc.
For more detail, look this answer.
If you are interested in the topic, this project will help you - pyprotect.