On dom, 2011-12-11 at 15:15 +0100, Sebastian Hilbert wrote: > On Sunday, December 11, 2011 01:56:16 PM Grant Paton-Simpson wrote: > > > The purpose of launch.py was to enable me to create an executable which > > contained Python and all the required libraries. The SOFA Statistics > > code itself remains separate in the form of standard Python scripts. > > So if I get this right you want to create an exe which calls the sofa python > script to have the ability to edit the sofa code without recreating the exe ? > > Never thought of that.
This is called "open-source mode" in PyInstaller; it's been discussed many times but never implemented. Basically, you modify the spec file so that, after Analysys() is running, you split all your source code (pathnames matching your local path) into a separate list. Then you package all the dependencies with the normal pipeline (say EXE() for one-file), and later add a COLLECT() pass to copy all your source code in the same output directory. You end up with a big exe file containing python and all standard + third-party libraries, plus your source code next to it, that can be freely editing. This works because PyInstaller allows external imports by default[1]. The only quirk is that PyInstaller required the boot script to be within the executable; so you will need a _bootstrap.py file that just import and execute your main application. I like it call "open-source mode" because it is well-suited for open source applications, since it allows people to freely modify the source code, apply patches, etc. You need to rebuild the executable *only* when you want to change the Python version or upgrade a third party package. [1] this is also a security issue because if for instance you create a file called "posix.py" and put it next to your Windows PyInstaller application, it *will* be executed at runtime (since os will try to import it and expect it to fail...), so an attacker can inject its custom Python code within your application. -- Giovanni Bajo :: Develer S.r.l. [email protected] :: http://www.develer.com Blog: http://giovanni.bajo.it Last post: The algorithms behind OTP tokens -- You received this message because you are subscribed to the Google Groups "PyInstaller" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pyinstaller?hl=en.
