On Tue, Apr 7, 2009 at 12:10 AM, Tony Meyer <[email protected]> wrote:
>> The code you reference is for module specific exclusions. Ordinarily
>> that dictionary is empty but if you look at hooks.py you will find
>> plenty of places where module.ExcludeName() is called. The excludes
>> themselves are simply put into the list of modules found by the finder
>> with a value of None. There are ways of forcing the value back in --
>> which is another reason why I'd like to know what is causing the
>> import in the first place to see if a hook is causing it. If that is
>> the case I'll find some way of forcing it to __stay__ excluded. :-)
>
> I've done some more digging into this.  A hook (load_Tkinter() in
> hooks.py) is involved - it does both "import Tkinter" (which raises an
> ImportError, when it tries to import _tkinter) and "import _tkinter"
> (which would raise an ImportError if the code got that far).  My
> limited understanding is that if these imports fail, the module
> shouldn't be included (since it's not available).

Agreed. I have checked in a change to do just this.

> In terms of the 'excludes' list - It looks like when createLibraryZip
> is True, the excludes list of the Executable object does not come into
> play, because (in _FreezeExecutable() in freezer.py) the global module
> finder is used, rather than one created based on the settings in the
> Executable object.

Yes, that is true. If you are creating a library zipfile then anything
dealing with finding modules is ignored at the executable level. That
makes sense, I believe, but if you don't think about it I can see
confusion setting in. :-)

> However, I can get it to work from the command-line (using the example
> code in my previous post) with `python freeze_test.py build_exe
> --excludes=Tkinter` (I must have been doing something wrong in my
> previous attempts to use the command-line options).

Good. I was worried that you had a special case since that works fine for me.

> This doesn't work in the code, because "excludes" isn't a known
> attribute.  I think to get that to work, the Distribution class in
> cx_Freeze/dist.py would need to be told about the "excludes" option
> (since the regular distutils Distribution class is unaware of it).

Hmm, this seems to work for me. You need to do something like this:

buildOptions = dict(excludes = ["Tkinter"])

setup(
        name = "hello",
        version = "0.1",
        description = "Sample cx_Freeze script",
        options = dict(build_exe = buildOptions),
        executables = [Executable("hello.py")])

> To sum up: I think that the cx_Freeze.dist.Distribution class should
> support "excludes".  I suspect that "excludes" values in Executables
> should be passed to the global module finder when createLibraryZip is
> true.  I wonder if the load_Tkinter() hook should fail to add Tkinter
> if it cannot be imported.  However, for now I can make do by invoking
> on the command-line or monkey-patching.

It would seem that it is working as expected. Can you confirm? Thanks.

> All of this is conjecture based on trawling through the source, so I
> may be making incorrect assumptions in places.  I hope this
> information is useful, however.  Please let me know if I can provide
> any more!

Thanks for taking the time to explain yourself clearly. And apologies
for taking this long to get back to you. Things have been rather busy
lately so I haven't really had a chance to look into this until now.

Anthony

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
cx-freeze-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cx-freeze-users

Reply via email to