0

I create a pyd compiled python file of a function called sm that calculate the sum of two numbers (just to test the use of compiled python file). The compiled file name is somme.pyd

To test I create main.py :

import somme
somme.sm(400,1473)`

How can I use both somme.pyd and main.py using pyscript to run the code in browser ?

3
  • 1
    The main.py part is covered in this answer on SO. As for the other part, you could use the python code in the file that you used to produce the compiled dll. However, I doubt you can use the Windows binary file with WASM because of the architecture, see here: "WebAssembly is a different architecture from what those libraries were compiled for so, just as you can't run ARM binaries on an x86 machine without slow emulation, you can't run x86 binaries on wasm." Commented Sep 10, 2024 at 18:07
  • The idea behind using compiled python code is to protect the code. I want just to allow others to execute my python code on the browser without showing the code (demo). What is the solution to this situation? Commented Sep 10, 2024 at 19:07
  • 1
    I think you mean "without exposing the code", and not "without showing the code "? If you do it right, typical users wouldn't see the code, and so it wouldn't be showing like as if you were running a Jupyter Notebook cell. But those with developer knowledge could access it. Hopefully, Jeff Glass or John Hanley will chime in; in the meantime, I think John Hanley's answer here and comments addressed that & it's not possible. Commented Sep 10, 2024 at 19:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.