Seems to be the reason for adding a path to the .pyc file: https://docs.python.org/3/library/compileall.html#cmdoption-compileall-d
"This will appear in compilation time tracebacks, and is also compiled in to the byte-code file, where it will be used in tracebacks and other messages in cases where the source file does not exist at the time the byte-code file is executed."
The path specified in the second argument to source_to_code is included into the dump of a code object:
source_to_code is used to load the code object which has a source path specified:
https:/ /github. com/python/ cpython/ blob/0f5a28f834 bdac2da8a04597d c0fc5b71e50da9d /Lib/py_ compile. py#L144- L145 /docs.python. org/3/library/ importlib. html#importlib. abc.InspectLoad er.source_ to_code
https:/
"The path argument should be the “path” to where the source code originated from, which can be an abstract concept (e.g. location in a zip file)."
Seems to be the reason for adding a path to the .pyc file: /docs.python. org/3/library/ compileall. html#cmdoption- compileall- d
https:/
"This will appear in compilation time tracebacks, and is also compiled in to the byte-code file, where it will be used in tracebacks and other messages in cases where the source file does not exist at the time the byte-code file is executed."
The path specified in the second argument to source_to_code is included into the dump of a code object:
python -m py_compile ./bdist_egg.py _/bdist_ egg.cpython- 38.pyc'
(Pdb) cfile
'./__pycache_
(Pdb) dfile
(Pdb) file
'./bdist_egg.py'
# vs
pip3 install -t ./ setuptools unpacked- wheel-79blnlyq/ setuptools/ command/ __pycache_ _/bdist_ egg.cpython- 38.pyc' unpacked- wheel-79blnlyq/ setuptools/ command/ bdist_egg. py'
(Pdb) cfile
'/tmp/pip-
(Pdb) dfile
(Pdb) file
'/tmp/pip-
(Pdb) '/tmp/pip-unpacked' in str(marshal. dumps(loader. source_ to_code( source_ bytes, dfile or file, _optimize= optimize) ))
True
(Pdb) '/tmp/pip-unpacked' in str(marshal. dumps(loader. source_ to_code( source_ bytes, './setuptools/ command/ bdist_egg. py', _optimize= optimize) ))
False
(Pdb) './setuptools/ command/ bdist_egg. py' in str(marshal. dumps(loader. source_ to_code( source_ bytes, './setuptools/ command/ bdist_egg. py', _optimize= optimize) ))
True
The absolute paths are passed in from pip: /github. com/pypa/ pip/blob/ 20.0.2/ src/pip/ _vendor/ distlib/ util.py# L596
https:/