On Thu, 2010-02-11 at 10:57 +0100, Marcin Krol wrote: > Giovanni Bajo wrote: > > On Wed, 10 Feb 2010 20:00:10 +0100, Marcin Krol <[email protected]> wrote: > >> Florian Höch wrote: > >>> Hi, > >>> What you really want to do is remove the directory where your > >>> application resides from sys.path, while keeping other entries. > >> I'm well aware that sys.path should not be empty -- the point is, even > >> if it's empty the packed binary is still doing those damn imports of > >> scripts in current directory and I have no idea how to stop that. > > > > So let me get this straight: you need those Python files to stay in the > > same directory of the final executable, but you don't want them to be > > imported? Is this correct? > > Precisely! > > Consider such a scenario: an unsuspecting user downloads my binary. He > doesn't even know or care that it has been developed using Python. > However, he happens to have a script called "warnings.py" in a current > directory, as I do, which serves a totally different purpose than > Python's "warnings" module (just like in my case). > > And then the user gets an exception in my program. Since he doesn't know > what's going on, he's just going to throw my program away.
I understand your concerns. There are two different issues there: 1) The fact that PyInstaller *ever* looks outside of the bundled executable is surely worth an option. It is debatable which is the correct default, and I suspect that most people would expect the default to be "never import a python file from the file system". This option is on the todo list. 2) In case that we want to allow importing files from the filesystem, there are two possibilities: either we look on the filesystem BEFORE looking within the bundled executable, or AFTER. You know understand that this is a matter of how the sys.path is assembled at startup. I believe there are good arguments for both cases (eg: looking on the filesystem BEFORE is a good way to distribute small and fast patches to the program), so this should also be an option. > >> Apparently they are imported via a way different than sys.path: it's > >> probably that importHook function in pyinstaller. > > > This is because you're rebinding sys.path to a different list. > > Now I get it. > > >PyInstaller > > takes a reference to sys.path at startup, so it doesn't see your > > modification. I agree this is a bug, and I have just committed a patch to > > fix it. Try if it helps. > > Thanks a lot, Giovanni! > > I take it that I can modify sys.path now and the search path for modules > in a program that is being packed will work as expected? > It should, but I await your tests :) -- Giovanni Bajo Develer S.r.l. http://www.develer.com -- 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.
