Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile to .pyd file #7637

Closed
ustcfdm opened this issue Mar 23, 2023 · 11 comments
Closed

Compile to .pyd file #7637

ustcfdm opened this issue Mar 23, 2023 · 11 comments
Assignees
Labels
question Question on using Taichi

Comments

@ustcfdm
Copy link

ustcfdm commented Mar 23, 2023

Is it possible to compile taichi code into .pyd file? The purpose is to protect source code when I want share my program with others. I tried to compile a python file with taichi code into a pyd file using nuitka. It worked for pure python part, but raised an error for taichi part.

@ustcfdm ustcfdm added the question Question on using Taichi label Mar 23, 2023
@github-project-automation github-project-automation bot moved this to Untriaged in Taichi Lang Mar 23, 2023
@ustcfdm
Copy link
Author

ustcfdm commented Mar 23, 2023

I raised a same issue in Nuitka repo. Details are here: Nuitka/Nuitka#2132

@neozhaoliang
Copy link
Contributor

neozhaoliang commented Mar 23, 2023

@ustcfdm Taichi uses the inspect module to parse the source code, and it fails to find the source code file when your code is compiled into binary format. I'm not familiar with nuitka, but one possible fix is to let nuitka also includes the source code in the result executable. Maybe you can check nuitka's doc that whether they have such options?

@ustcfdm
Copy link
Author

ustcfdm commented Mar 24, 2023

@neozhaoliang Thanks for your suggestion. I am wondering whether there is Python API for Taichi AOT? This should also be a solution for me.

@neozhaoliang neozhaoliang moved this from Untriaged to Todo in Taichi Lang Mar 24, 2023
@neozhaoliang
Copy link
Contributor

neozhaoliang commented Mar 24, 2023

What about using some third-party lib to obfuscate your python code?

@ustcfdm
Copy link
Author

ustcfdm commented Mar 24, 2023

This is a solution, but not my preference. Since Taichi needs the source code to compile, obfuscation does not really protect code. I would prefer AOT for Python API if possible.

@neozhaoliang
Copy link
Contributor

neozhaoliang commented Mar 24, 2023

The AOT module gives shader output that can be called by C++. The shader output is obfuscated but can still be analyzed by AI. So I doubt AOT is the perfect solution.

@ustcfdm
Copy link
Author

ustcfdm commented Mar 24, 2023

I see. This may beyond my understanding and requirement. 😮 It will be okay as long as there is no .py files somehow.

@ailzhang
Copy link
Contributor

@ustcfdm aha then maybe give taichi AOT a try? It currently doesn't support loading from python but writing pybind for the C++ can be pretty straightforward.

@ustcfdm
Copy link
Author

ustcfdm commented Mar 24, 2023

@ailzhang It doesn't support Windows for now. I will give it a try when AOT is supported in Windows system.

@ailzhang
Copy link
Contributor

ailzhang commented Apr 7, 2023

@ustcfdm btw AOT is supported on Windows ;) Feel free to give it a try and let us know if you hit any issues!

@ailzhang
Copy link
Contributor

Closing as resolved, please feel free to reopen if you have followup questions!

@github-project-automation github-project-automation bot moved this from Todo to Done in Taichi Lang Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question on using Taichi
Projects
Status: Done
Development

No branches or pull requests

3 participants