I see. I'm not sure there's an easy fix for that: the filename it's
retrieving for the calling code is baked in when it's byte-compiled, i.e.
when cx_Freeze freezes it, while the filename in modulesbyfilename is
calculated at runtime.
Looking up the stack at the calling function is a nasty practice, and I'd
be wary of using any code that does that in production.
Thomas
On 5 October 2014 14:06, Paul Apostolescu <apbog...@gmail.com> wrote:
> Thomas,
>
> I'm running as root and the project is under "temp".
>
> When running the "unfrozen" version (python controller.py):
> - getabsfile returns "/root/temp/fail/caller.py
> - in modulesbyfilename I have the same path: /root/temp/fail/caller.py
>
> When running the frozen version:
> - getabsfile returns the same path
> - this time modulesbyfilame has a different
> path: /root/temp/fail/build/exe.linux-x86_64-2.7/library.zip/caller.py
>
> - Paul
>
>
> On Sun, Oct 5, 2014 at 3:35 PM, Thomas Kluyver <tak...@gmail.com> wrote:
>
>> Hi Paul,
>>
>> What does inspect.getabsfilename(frm[0]) return? If that returns a
>> filename, is it in inspect.modulesbyfilename, and what's the value
>> associated with it?
>>
>> Thomas
>>
>> On 3 October 2014 13:41, Paul Apostolescu <apbog...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I'm getting the following stack trace when running my frozen script:
>>>
>>> Traceback (most recent call last):
>>> File
>>> "/opt/rh/python27/root/usr/lib64/python2.7/site-packages/cx_Freeze/initscripts/Console.py",
>>> line 27, in <module>
>>> exec(code, m.__dict__)
>>> File "controller.py", line 1, in <module>
>>> import caller
>>> File "/root/temp/fail/caller.py", line 3, in <module>
>>> handler.register_service('something')
>>> File "/root/temp/fail/handler.py", line 6, in register_service
>>> m._SERVICE_NAME = service
>>> AttributeError: 'NoneType' object has no attribute '_SERVICE_NAME'
>>>
>>> The root cause is inspect.getmodule fails to locate the module of
>>> caller. Any ideas how can I get this fixed ? Unfortunately this code is
>>> part of a 3rd-party library code which I cannot change.
>>>
>>> This is my setup.py:
>>>
>>> import sys
>>> from cx_Freeze import setup, Executable
>>>
>>> options = {
>>> 'build_exe': {
>>> }
>>> }
>>>
>>> executables = [
>>> Executable('controller.py')
>>> ]
>>>
>>> setup( name = "fail",
>>> version = "0.0.1",
>>> options = options,
>>> executables = executables)
>>>
>>> This is the source code for controller.py:
>>>
>>> import caller
>>>
>>> if __name__ == "__main__":
>>> print 'random stuff here'
>>>
>>> This is the source for caller.py:
>>>
>>> import handler
>>> handler.register_service('something')
>>>
>>> And this is the code for handler.py:
>>>
>>> import inspect
>>>
>>> def register_service(service):
>>> frm = inspect.stack()[1]
>>> m = inspect.getmodule(frm[0])
>>> m._SERVICE_NAME = service
>>>
>>> Thanks
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>>> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>>> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>>> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>>>
>>> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> cx-freeze-users mailing list
>>> cx-freeze-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/cx-freeze-users
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
>> _______________________________________________
>> cx-freeze-users mailing list
>> cx-freeze-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/cx-freeze-users
>>
>>
>
>
> ------------------------------------------------------------------------------
> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>
> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
> _______________________________________________
> cx-freeze-users mailing list
> cx-freeze-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/cx-freeze-users
>
>
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
cx-freeze-users mailing list
cx-freeze-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cx-freeze-users