-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
6 tests fail using SOURCE_DATE_EPOCH env var #78203
Comments
https://build.opensuse.org/package/show/home:mcepl:work/python3 6 tests failed: ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/runpy.py", line 153, in _get_module_details
code = loader.get_code(mod_name)
zipimport.ZipImportError: can't find module '__main__'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/runpy.py", line 219, in _get_main_module_details
return _get_module_details(main_name)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/runpy.py", line 155, in _get_module_details
raise error(format(e)) from e
ImportError: can't find module '__main__'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_runpy.py", line 715, in test_zipfile_compiled
mod_name=mod_name, check_loader=False)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_runpy.py", line 631, in _check_script
self.check_code_execution(create_ns, expected_ns)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_runpy.py", line 130, in check_code_execution
result_ns = create_namespace(None)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_runpy.py", line 606, in create_ns
return run_path(script_name, init_globals)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/runpy.py", line 275, in run_path
mod_name, mod_spec, code = _get_main_module_details()
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/runpy.py", line 223, in _get_main_module_details
(main_name, sys.path[0])) from exc
ImportError: can't find '__main__' module in '/tmp/tmp40k8q99u/test_zip.zip' ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_cmd_line_script.py", line 268, in test_zipfile_compiled
zipimport.zipimporter)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_cmd_line_script.py", line 129, in _check_script
*run_args, __isolated=False, __cwd=cwd, **env_vars
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 157, in assert_python_ok
return _assert_python(True, *args, **env_vars)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 143, in _assert_python
res.fail(cmd_line)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 84, in fail
err))
AssertionError: Process return code is 1
command line: ['/home/abuild/rpmbuild/BUILD/Python-3.7.0/python', '-X', 'faulthandler', '-E', '/tmp/tmpwlsj3czm/test_zip.zip', 'test1', 'test2', 'test3'] stdout: --- stderr: ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/util.py", line 303, in wrapper
to_return = fxn(*args, **kwargs)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/source/test_file_loader.py", line 349, in test_overiden_unchecked_hash_based_pyc
self.assertEqual(int.from_bytes(data[4:8], 'little'), 0b1)
AssertionError: 3 != 1 ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/util.py", line 303, in wrapper
to_return = fxn(*args, **kwargs)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/source/test_file_loader.py", line 315, in test_unchecked_hash_based_pyc
self.assertEqual(mod.state, 'old')
AssertionError: 'new' != 'old'
- new
+ old ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/util.py", line 303, in wrapper
to_return = fxn(*args, **kwargs)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/source/test_file_loader.py", line 635, in test_old_timestamp
self.assertEqual(bytecode_file.read(4), source_timestamp)
AssertionError: b'\xf0%\x1e8' != b'\xe2L6[' ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/util.py", line 303, in wrapper
to_return = fxn(*args, **kwargs)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/source/test_file_loader.py", line 635, in test_old_timestamp
self.assertEqual(bytecode_file.read(4), source_timestamp)
AssertionError: b'\xf0%\x1e8' != b'\xe2L6[' ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/util.py", line 303, in wrapper
to_return = fxn(*args, **kwargs)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/source/test_file_loader.py", line 349, in test_overiden_unchecked_hash_based_pyc
self.assertEqual(int.from_bytes(data[4:8], 'little'), 0b1)
AssertionError: 3 != 1 ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/util.py", line 303, in wrapper
to_return = fxn(*args, **kwargs)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/source/test_file_loader.py", line 315, in test_unchecked_hash_based_pyc
self.assertEqual(mod.state, 'old')
AssertionError: 'new' != 'old'
- new
+ old ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/util.py", line 303, in wrapper
to_return = fxn(*args, **kwargs)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/source/test_file_loader.py", line 635, in test_old_timestamp
self.assertEqual(bytecode_file.read(4), source_timestamp)
AssertionError: b'\xf0%\x1e8' != b'\xe2L6[' ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/util.py", line 303, in wrapper
to_return = fxn(*args, **kwargs)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_importlib/source/test_file_loader.py", line 635, in test_old_timestamp
self.assertEqual(bytecode_file.read(4), source_timestamp)
AssertionError: b'\xf0%\x1e8' != b'\xe2L6[' ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_multiprocessing_main_handling.py", line 225, in test_zipfile_compiled
self._check_script(zip_name)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_multiprocessing_main_handling.py", line 156, in _check_script
rc, out, err = assert_python_ok(*run_args, __isolated=False)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 157, in assert_python_ok
return _assert_python(True, *args, **env_vars)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 143, in _assert_python
res.fail(cmd_line)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 84, in fail
err))
AssertionError: Process return code is 1
command line: ['/home/abuild/rpmbuild/BUILD/Python-3.7.0/python', '-X', 'faulthandler', '-E', '/tmp/tmpjsax7ksh/test_zip.zip', 'fork'] stdout: --- stderr: ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_multiprocessing_main_handling.py", line 225, in test_zipfile_compiled
self._check_script(zip_name)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_multiprocessing_main_handling.py", line 156, in _check_script
rc, out, err = assert_python_ok(*run_args, __isolated=False)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 157, in assert_python_ok
return _assert_python(True, *args, **env_vars)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 143, in _assert_python
res.fail(cmd_line)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 84, in fail
err))
AssertionError: Process return code is 1
command line: ['/home/abuild/rpmbuild/BUILD/Python-3.7.0/python', '-X', 'faulthandler', '-E', '/tmp/tmp50n_prgl/test_zip.zip', 'forkserver'] stdout: --- stderr: ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_multiprocessing_main_handling.py", line 225, in test_zipfile_compiled
self._check_script(zip_name)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_multiprocessing_main_handling.py", line 156, in _check_script
rc, out, err = assert_python_ok(*run_args, __isolated=False)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 157, in assert_python_ok
return _assert_python(True, *args, **env_vars)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 143, in _assert_python
res.fail(cmd_line)
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/support/script_helper.py", line 84, in fail
err))
AssertionError: Process return code is 1
command line: ['/home/abuild/rpmbuild/BUILD/Python-3.7.0/python', '-X', 'faulthandler', '-E', '/tmp/tmp1npoq9bq/test_zip.zip', 'spawn'] stdout: --- stderr: ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_py_compile.py", line 153, in test_invalidation_mode
self.assertEqual(flags, 0b1)
AssertionError: 3 != 1
----------------------------------------------------------------------
====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_compileall.py", line 365, in test_force
self.assertEqual(mtime, mtime2)
AssertionError: 1530285241.0427392 != 1530285301.18 ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_compileall.py", line 299, in test_no_args_respects_force_flag
self.assertEqual(mtime, mtime2)
AssertionError: 1530285243.012693 != 1530285303.168 ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_compileall.py", line 533, in test_pyc_invalidation_mode
self.assertEqual(int.from_bytes(data[4:8], 'little'), 0b01)
AssertionError: 3 != 1 ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_compileall.py", line 78, in test_magic_number
self.recreation_check(b'\0\0\0\0')
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_compileall.py", line 61, in recreation_check
self.assertEqual(*self.data())
AssertionError: b'B\r\r\n\x03\x00\x00\x00\\s\xa0J' != b'B\r\r\n\x00\x00\x00\x00\xfaL6[' ====================================================================== Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_compileall.py", line 74, in test_mtime
0, 1))
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_compileall.py", line 61, in recreation_check
self.assertEqual(*self.data())
AssertionError: b'B\r\r\n\x03\x00\x00\x00\\s\xa0J' != b'B\r\r\n\x00\x00\x00\x00\xfaL6[' |
It seems like the same (or similar? I didn't check) tests fail on Debian: |
I would add that Debian doesn't seem to fare that much better ... https://buildd.debian.org/status/fetch.php?pkg=python3.7&arch=amd64&ver=3.7.0-1&stamp=1530136859&raw=0 |
I'm unable to reproduce the issue on Fedora using the same configure command: $ ./configure --host=x86_64-suse-linux-gnu --build=x86_64-suse-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/lib --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking --docdir=/usr/share/doc/packages/python --enable-ipv6 --with-fpectl --enable-shared --with-ensurepip=no --with-system-ffi --with-system-expat --with-lto --enable-loadable-sqlite-extensions
$ make
$ LD_LIBRARY_PATH=$PWD ./python -m test -j0 test_cmd_line_script test_compileall test_importlib test_multiprocessing_main_handling test_py_compile test_runpy
...
All 6 tests OK.
...
Tests result: SUCCESS |
Thread on python-dev: My reply: Extract: """ Wait, there is a SLES buildbot and all tests pass except of The Debian buildbot is green on all branches. |
I also ran the Python test suite on Debian sid using the master branch of Python and all tests pass: $ ./configure --prefix=/usr --enable-ipv6 --enable-loadable-sqlite-extensions --with-dbmliborder=bdb:gdbm --with-computed-gotos --without-ensurepip --with-system-expat --with-system-libmpdec --with-system-ffi
$ make
$ LD_LIBRARY_PATH=$PWD ./python -m test -j0 test_cmd_line_script test_compileall test_importlib test_multiprocessing_main_handling test_py_compile test_runpy All 6 tests OK. I also ran the full test suite on Debian Stretch: again, all tests passed. Maybe the package builder use a custom configuration or patches? Or issues are specific to Python 3.7? (again, I tested the master branch) |
Hmm, what about version of gcc? I suspect some troubles could be caused by gcc version 8 (we have in openSUSE), or LTO option switched on? |
For my tests on Fedora, I used gcc 8.1.1. I used the OpenSUSE configure command which includes --with-lto. |
I built and ran these tests using commands from msg320892 on openSUSE Leap 42.3, and all tests are passed. |
It's somehow complicated, in the build chroot I can make tests run only with LD_LIBRARY_PATH set to $(readlink -f Python-3.7.0) and PYTHONPATH to Lib directory. However, then the set of failed tests changes. For example test_runpy runs without problems, but other fails: 5 tests failed: (complete log is attached) |
Yes, it must be something in the chroot, because when run in the plain command line, all tests as well on openSUSE Tumbleweed (with the latest updates). 393 tests OK. 1 test failed: 21 tests skipped: Re-running failed tests in verbose mode ---------------------------------------------------------------------- OK == Tests result: FAILURE then SUCCESS == 393 tests OK. 21 tests skipped: 1 re-run test: |
Are you testing with patches? It may be interesting to try to get these patches upstream: [ 59s] Patch #1 (Python-3.0b1-record-rpm.patch): Some patches seem old. Are they still needed? Where can I find these patches? I'm interested by patches modifying site.py for example. |
Tested both and without patches, the same results. Everything in openSUSE is done in open (rather strikingly similar to RH openness, although things are even more simple, because so much is web accessible), so the official project for development of openSUSE python3 is https://build.opensuse.org/package/show/devel:languages:python:Factory/python3 all patches are there (from there I can make push request to the https://build.opensuse.org/package/show/openSUSE:Factory/python3 which is where openSUSE packages come from). |
I applied manually these patches on 3.7: the 6 tests still pass. |
I created PR 8057 to upstream distutils-reproducible-compile.patch. Matej Cepl: Would you mind to try to find the original author of this patch file? I would like to credit them. |
FAIL: test_invalidation_mode (test.test_py_compile.PyCompileTests) Traceback (most recent call last):
File "/home/abuild/rpmbuild/BUILD/Python-3.7.0/Lib/test/test_py_compile.py", line 153, in test_invalidation_mode
self.assertEqual(flags, 0b1)
AssertionError: 3 != 1 This failure looks suspicious. I looked at the code, and the tested function behaves differently depending of the SOURCE_DATE_EPOCH environment variable is set. Aha! I found something: $ SOURCE_DATE_EPOCH=1530605018 ./python -m test -j0
...
6 tests failed:
test_cmd_line_script test_compileall test_importlib
test_multiprocessing_main_handling test_py_compile test_runpy
... |
From https://mail.python.org/pipermail/python-dev/2018-July/154273.html In particular, if a build system sets SOURCE_DATE_EPOCH without |
we're compiling similar to debian and getting the same issues now only with 3.7 so interested in what the resolution is. I tried both w/ and w/o setting SOURCE_DATE_EPOCH and still get failures. |
Actually, py_compile will _force_ the CHECKED_HASH mode if SOURCE_DATE_EPOCH is set, regardless of what you specified for py_compile or compileall. I'm not sure if that's actually intended or a bug. The fix for the tests is to actually be aware of py_compile behavior and control for SOURCE_DATE_EPOCH. I submitted a PR with a fix. |
I dislike that having SOURCE_DATE_EPOCH set magically changes command line tools behavior. In my view, this problem should be fixed by reverting ccbe581. |
Perhaps SOURCE_DATE_EPOCH should only be consulted to determine the default behavior if invalidation_mode was not passed explicitly to py_compile.compile(). |
#9607 turns SOURCE_DATE_EPOCH into a *default* rather than absolute override. test_cmd_line_script and test_runpy fail due to the lack of support for hash-based .pycs in zipimport, which needs fixing also. |
There are still tests which fail when SOURCE_DATE_EPOCH env var is defined: $ SOURCE_DATE_EPOCH=0 ./python -m test -j0 -r
(...)
3 tests failed:
test_cmd_line_script test_multiprocessing_main_handling test_runpy
(...) |
#10327 fixes the remaining test failures. |
As #10327 has been merged, I think this issue can be closed? |
The Versions field of this issue is set to Python 3.7, but 7 tests are failing with: $ SOURCE_DATE_EPOCH=0 ./python -m test -j0 -r -u all,-gui
(...)
7 tests failed:
test_cmd_line_script test_compileall test_importlib
test_multiprocessing_main_handling test_posix test_py_compile
test_runpy Note: the full test suite pass with SOURCE_DATE_EPOCH=0 on master. |
Looks like in #10327, Serhiy Storchaka considers fixing these issues for 3.8 only - "It is easier to skip the test on 3.7." and then remove the "needs backport to 3.7" label. How about changing the target version to 3.8 only and close this issue? |
"What’s New In Python 3.7" mentions twice "build reproducibility": |
Got it. Thanks for the pointer. |
test_compileall, test_importlib, test_py_compile: I created #10775 backport. test_cmd_line_script, test_runpy and test_multiprocessing_main_handling failures are related to zipimport. They have been fixed in master by commit a6e956b which modifies Lib/zipimport.py... but in 3.7, zipimport is written in C. It seems non-trivial to fix zipimport, and I'm not sure that it's worth it. Note: test_posix now pass, no idea why it failed a few days ago. |
With this change, only 3 tests fail on 3.7, and all these 3 fail because of zipimport: test_cmd_line_script, test_multiprocessing_main_handling and test_runpy. Chih-Hsuan Yen:
Now I agree to close the issue :-) I'm ok to not fix zipimport in 3.7. Anyway, it's not like Python is perfect in the master branch: frozenset in marshal is still not reproducible. See bpo-29708. |
These tests were fixed by: commit a6e956b
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: