running py2exe
Traceback (most recent call last):
File "setup.py", line 5, in <module>
data_files=[('.', ['data.txt'])]
File "C:\Python37\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python37\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Python37\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "D:\py2exesample\testing\lib\site-packages\py2exe\distutils_buildexe.py", line 192, in run
self._run()
File "D:\py2exesample\testing\lib\site-packages\py2exe\distutils_buildexe.py", line 272, in _run
builder.analyze()
File "D:\py2exesample\testing\lib\site-packages\py2exe\runtime.py", line 177, in analyze
target.analyze(mf)
File "D:\py2exesample\testing\lib\site-packages\py2exe\runtime.py", line 78, in analyze
modulefinder.run_script(self.script)
File "D:\py2exesample\testing\lib\site-packages\py2exe\mf34.py", line 62, in run_script
self._scan_code(mod.__code__, mod)
File "D:\py2exesample\testing\lib\site-packages\py2exe\mf34.py", line 386, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\py2exesample\testing\lib\site-packages\py2exe\mf34.py", line 122, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\py2exesample\testing\lib\site-packages\py2exe\mf34.py", line 104, in import_hook
module = self._gcd_import(name)
File "D:\py2exesample\testing\lib\site-packages\py2exe\mf34.py", line 258, in _gcd_import
return self._find_and_load(name)
File "D:\py2exesample\testing\lib\site-packages\py2exe\mf34.py", line 348, in _find_and_load
self._scan_code(module.__code__, module)
File "D:\py2exesample\testing\lib\site-packages\py2exe\mf34.py", line 386, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "D:\py2exesample\testing\lib\site-packages\py2exe\mf34.py", line 122, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "D:\py2exesample\testing\lib\site-packages\py2exe\mf34.py", line 107, in import_hook
module = self._gcd_import(name, package, level)
File "D:\py2exesample\testing\lib\site-packages\py2exe\mf34.py", line 258, in _gcd_import
return self._find_and_load(name)
File "D:\py2exesample\testing\lib\site-packages\py2exe\mf34.py", line 303, in _find_and_load
spec = importlib.util.find_spec(name, path)
File "C:\Python37\lib\importlib\util.py", line 94, in find_spec
parent = __import__(parent_name, fromlist=['__path__'])
File "D:\py2exesample\samplePKG\__init__.py", line 1, in <module>
import printData
File "D:\py2exesample\printData.py", line 3, in <module>
DATA_PATH = os.path.join(globalVars.appPath, globalVars.DATA_FILE_NAME)
AttributeError: module 'globalVars' has no attribute 'appPath'
Obviously the reproducer attached above is extremely silly and it would be easy to rewrite it, but as mentioned above we follow similar pattern in NVDA and it would be pretty difficult to modify its code so that this bug is not triggered. As soon as the line from .functions import my_avesome_func in samplePKG\__init__.py is commented out the program can be frozen successfully.
Originally reported as nvaccess/nvda#12357 as this issue stops us from upgrading to post 0.10.1.0 versions of py2exe.
To reproduce try to freeze
py2exesample.zip
with version 0.10.1.0 and then with any later versions including the latest 0.10.4.1. While with 10.1.0 the freezing process works as it should all later versions provide the following error:
Obviously the reproducer attached above is extremely silly and it would be easy to rewrite it, but as mentioned above we follow similar pattern in NVDA and it would be pretty difficult to modify its code so that this bug is not triggered. As soon as the line
from .functions import my_avesome_funcinsamplePKG\__init__.pyis commented out the program can be frozen successfully.