Closed Bug 1605128 Opened 4 years ago Closed 4 years ago

build fails with "AttributeError: 'module' object has no attribute 'ensure_text'"

Categories

(Firefox Build System :: General, defect)

defect
Not set
normal

Tracking

(firefox-esr68 unaffected, firefox72 unaffected, firefox73 fixed, firefox74 fixed)

RESOLVED FIXED
mozilla74
Tracking Status
firefox-esr68 --- unaffected
firefox72 --- unaffected
firefox73 --- fixed
firefox74 --- fixed

People

(Reporter: froydnj, Assigned: bwc)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

I just tried building (with Python 2.7), and got:

 0:00.71 /usr/bin/make -f client.mk MOZ_PARALLEL_BUILD=50 -s
 0:00.81 Traceback (most recent call last):
 0:00.81   File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
 0:00.81     "__main__", fname, loader, pkg_name)
 0:00.81   File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
 0:00.81     exec code in run_globals
 0:00.81   File "/home/froydnj/src/gecko/python/mozbuild/mozbuild/action/preprocessor.py", line 25, in <module>
 0:00.81     main(sys.argv[1:])
 0:00.82   File "/home/froydnj/src/gecko/python/mozbuild/mozbuild/action/preprocessor.py", line 21, in main
 0:00.82     pp.handleCommandLine(args, True)
 0:00.82   File "/home/froydnj/src/gecko/python/mozbuild/mozbuild/preprocessor.py", line 509, in handleCommandLine
 0:00.82     self.processFile(input=input, output=out)
 0:00.82   File "/home/froydnj/src/gecko/python/mozbuild/mozbuild/preprocessor.py", line 420, in processFile
 0:00.82     self.do_include(input, False)
 0:00.82   File "/home/froydnj/src/gecko/python/mozbuild/mozbuild/preprocessor.py", line 821, in do_include
 0:00.82     self.includes.add(six.ensure_text(abspath))
 0:00.82 AttributeError: 'module' object has no attribute 'ensure_text'
 0:00.82 /home/froydnj/src/gecko/config/rules.mk:1151: recipe for target '.cargo/config' failed

Are we using an in-tree six?

Flags: needinfo?(rstewart)

Er, apparently some other bug modified preprocessor.py to use ensure_text.

Regressed by: 1603262
No longer regressed by: 1603181
Has Regression Range: --- → yes

Yeah, six lives in-tree (third_party/python/six) and the version we're using is new enough:

rickystewart-a5lvdq:mozilla-unified rickystewart$ rg ensure_text third_party/python/six
third_party/python/six/six.py
903:def ensure_text(s, encoding='utf-8', errors='strict'):

third_party/python/six/test_six.py
1048:    def test_ensure_text(self):
1049:        converted_unicode = six.ensure_text(self.UNICODE_EMOJI, encoding='utf-8', errors='strict')
1050:        converted_binary = six.ensure_text(self.BINARY_EMOJI, encoding="utf-8", errors='strict')

third_party/python/six/documentation/index.rst
451:.. function:: ensure_text(s, encoding='utf-8', errors='strict')

third_party/python/six/CHANGES
25:- Pull request #204: Add `six.ensure_binary`, `six.ensure_text`, and

I can't reproduce locally and automation is fine (of course, or else this wouldn't have made it to central).

mars, ahal: any idea why this might happen?

Flags: needinfo?(rstewart)
Flags: needinfo?(mars)
Flags: needinfo?(ahal)

Apparently I had an old copy in my virtualenv (or on my system itself, not sure), and blowing away my objdir fixed things. I'd like to understand why things didn't work in the first place, though.

Not sure. Could some tool have installed an older six into the build system's virtualenv which was getting picked up ahead of the in-tree one?

Flags: needinfo?(ahal)

FWIW, if your Python virtualenvs get borked (happens to me not infrequently working on Python 3 stuff), you can just rm -rf objdir/_virtualenvs and the next build will recreate them. You don't have to trash your entire objdir in that case.

:frodynj what likely happened is you objectdir was built with a version of the mozilla source tree that included our previous version of the six library. If you built an objectdir with an old revision of mozilla-central that included six 1.10, and then updated to the latest mozilla-central, then you'd trigger this error.

We've run with six v1.10 until recently and v1.10 does not have the ensure_text() function. We recently upgraded to six v1.13 and people have started using its new features liberally. The virtualenv should have detected the change in library version requirements and clobbered itself. Perhaps you found a case where that didn't happen.

Unfortunately there's no way to tell what version of the source tree your virtualenv was built with now that the objectdir has been refreshed.

Flags: needinfo?(mars)

I've seen this happen after running a mochitest and then rebuilding.

(In reply to Michael Froman [:mjf] from comment #7)

I've seen this happen after running a mochitest and then rebuilding.

I'm on current head (3a51a5d07942) as of 2020/01/07. Specifically, I can repro with the following:

./mach build
./mach mochitest --headless --keep-open=false dom/media/tests/mochitest/identity/test_getIdentityAssertion.html &> log.txt
./mach build

If I follow the advice in Comment 5, I can rebuild successfully, but another mochitest run will cause the build failure again.

:mars, please let me know if there is anything you need from me to help figure out what is going on.

Flags: needinfo?(mars)

One bit of additional info, the first few lines of the output from the mochitest output:

mfroman@moz:~/mozilla/moz-central$ ./mach mochitest --headless --keep-open=false dom/media/tests/mochitest/identity/test_getIdentityAssertion.html &> log.txt
tail: log.txt: file truncated
 /home/mfroman/mozilla/obj/deb/backend.TestManifestBackend is out of date with respect to /home/mfroman/mozilla/obj/deb/config.status
Test configuration changed. Regenerating backend.
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting six==1.10.0
  Using cached https://files.pythonhosted.org/packages/c8/0a/b6723e1bc4c516cb687841499455a8505b44607ab535be01091c0f24f079/six-1.10.0-py2.py3-none-any.whl

Seems like ./mach mochitest is causing an old version of six to be used.

callek pointed this out: https://searchfox.org/mozilla-central/source/testing/mozharness/configs/unittests/mac_unittest.py#15

Not sure why we wouldn't just be using the vendored six here.

Punting to ahal, I don't know why mozharness would hardcode its own six module version.

I think the fix is trivial: bump six to v1.13.0. I don't see anything in the six changelog that would be a risk.

Flags: needinfo?(mars) → needinfo?(ahal)

It's possible we can remove the mozharness copy now, though you should follow-up with releng. Historically there were some places that plucked testing/mozharness directly from hg.m.o and for some reason that I can't remember it would have been very annoying to update this code to also pluck things from other places in the tree. So instead modules that mozharness dependend on were duplicated to testing/mozharness.

IIRC, this was fixed, but please don't take my word for it. Maybe Callek knows more.

Flags: needinfo?(ahal) → needinfo?(bugspam.Callek)

Oops, should have checked the link first. Looks like six isn't duplicated but installed at runtime somehow. Though this likely exists for the same reason I mentioned in the last comment. Things used to (and possibly still do) pluck mozharness from out of tree.

Flags: needinfo?(bugspam.Callek)

This is because the webrtc mochitests need six:

https://searchfox.org/mozilla-central/source/testing/tools/websocketprocessbridge/websocketprocessbridge_requirements.txt

We could probably just remove the version, and it would work ok.

Byron, this works fine for me, can you land it?

Flags: needinfo?(docfaraday)
Assignee: nobody → docfaraday
Status: NEW → ASSIGNED

Up for review.

Flags: needinfo?(docfaraday)
Pushed by bcampen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e73c840984e6
Make websocket_process_bridge less picky about the version of six it wants. r=ahal
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: