Is there any way to make py2exe output .py source files instead of byte-compiled .pyc files in the library?
Is there any way to make py2exe output .py source files instead of byte-compiled
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I did it long ago, so I hope I remember correctly:
pycfiles.UPDATE: Ram Rachum is right, use the
skip_archiveoption instead ofcompressed.You won’t be able to modify your main Python file, since it will be embedded into the main executable, so keep that to a minimum. Then you’ll be able to replace the
pycfiles with yourpyfiles manually in your distribution as needed. No reason to replace the standard libraries, however, only your own code.(It is not optimal for debugging, but I guess you want to fix some problem happening only to the release build of your software this way.)
Please let me know if it does not work and I’ll try to help.
UPDATE:
I’ve just read the relevant parts of the py2exe source code. It seems that py2exe does not support it out of the box. So we’ve left with the option to touch its source code.
You can easily modify
py2exeto support this mode. See thebyte_compilefunction inbuild_exe.py. There’s a call to thecompilebuilt-in function in it, which you can replace with acopy_file. Don’t forget to modify the destination file name (dfile) to have the extension.pyinstead of.pycor.pyo. I know that it is patchwork, but I don’t see any other possibility to solve your problem.You can also add a new
py2exeoption or introduce a newoptimizevalue for this if you’re curious. It would be an open-source contribution to py2exe, actually. 😉