[SERVER-41424] scons should fail early if invoked with wrong Python interpreter Created: 31/May/19  Updated: 29/Oct/23  Resolved: 12/Jun/19

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: None
Fix Version/s: 3.4.22, 3.6.14, 4.0.11

Type: Improvement Priority: Major - P3
Reporter: Geert Bosch Assignee: Mathew Robinson (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
Backwards Compatibility: Fully Compatible
Backport Requested:
v3.6, v3.4
Sprint: Dev Tools 2019-06-17
Participants:
Linked BF Score: 0

 Description   

When on a 4.0 branch and running scons with Python3, it fails with a cryptic error message, causing lots of developer time to be wasted in trying to figure out what went wrong.

A simple early check for the correct Python version would help a lot



 Comments   
Comment by Githook User [ 12/Jun/19 ]

Author:

{'name': 'Mathew Robinson', 'email': 'chasinglogic@gmail.com', 'username': 'chasinglogic'}

Message: SERVER-41424 Ignore python patch version when verifying python can build MongoDB

(cherry picked from commit c517556ca985f60b52b983049410cb278c919434)
Branch: v3.4
https://github.com/mongodb/mongo/commit/f9c9dd17f411e8db26d898a3b74bcc2fb07fd8eb

Comment by Githook User [ 12/Jun/19 ]

Author:

{'name': 'Mathew Robinson', 'email': 'chasinglogic@gmail.com', 'username': 'chasinglogic'}

Message: SERVER-41424 Ignore python patch version when verifying python can build MongoDB

(cherry picked from commit c517556ca985f60b52b983049410cb278c919434)
Branch: v3.6
https://github.com/mongodb/mongo/commit/6329d3f5cbfcea79ec9d49a7e0123890b7fd040e

Comment by Githook User [ 12/Jun/19 ]

Author:

{'name': 'Mathew Robinson', 'email': 'chasinglogic@gmail.com', 'username': 'chasinglogic'}

Message: SERVER-41424 Ignore python patch version when verifying python can build MongoDB
Branch: v4.0
https://github.com/mongodb/mongo/commit/c517556ca985f60b52b983049410cb278c919434

Comment by Githook User [ 12/Jun/19 ]

Author:

{'name': 'Mathew Robinson', 'email': 'chasinglogic@gmail.com', 'username': 'chasinglogic'}

Message: SERVER-41424 scons should fail early if invoked with wrong Python interpreter

(cherry picked from commit 6a8f5d33543088dbf39b26275fb2a90cbd466cf5)
Branch: v3.4
https://github.com/mongodb/mongo/commit/629826f3140932ef34ebeecc109086591fe28a60

Comment by Githook User [ 12/Jun/19 ]

Author:

{'name': 'Mathew Robinson', 'email': 'chasinglogic@gmail.com', 'username': 'chasinglogic'}

Message: SERVER-41424 scons should fail early if invoked with wrong Python interpreter

(cherry picked from commit 6a8f5d33543088dbf39b26275fb2a90cbd466cf5)
Branch: v3.6
https://github.com/mongodb/mongo/commit/12ceace70831e9b2467cec60cc7f1782c8db85c1

Comment by Githook User [ 12/Jun/19 ]

Author:

{'name': 'Mathew Robinson', 'email': 'chasinglogic@gmail.com', 'username': 'chasinglogic'}

Message: SERVER-41424 scons should fail early if invoked with wrong Python interpreter
Branch: v4.0
https://github.com/mongodb/mongo/commit/6a8f5d33543088dbf39b26275fb2a90cbd466cf5

Comment by Mathew Robinson (Inactive) [ 11/Jun/19 ]

acm

So it appears the actual error is not that the buildscripts/scons.py file is not compatible with Py2+3 but that SCons is not compatible with Python 3. This means that our EnsurePythonVersion never gets run and instead you get the following stack trace (from scons itself):

(mongo) @rocinante ➜  mongo git:(v3.6) python ./buildscripts/scons.py -j8 core
Traceback (most recent call last):
  File "./buildscripts/scons.py", line 21, in <module>
    import SCons.Script
  File "/Users/chasinglogic/Work/mongo/src/third_party/scons-2.5.0/scons-local-2.5.0/SCons/Script/__init__.py", line 377
    exec "%s = _SConscript.DefaultEnvironmentCall(%s)" % (name, repr(name))
                                                     ^
SyntaxError: invalid syntax

I've added a a version check to buildscripts/scons.py before it imports SCons. While it's unfortunate that we need to basically duplicate EnsurePythonVersion but even if we backported the SCons upgrade to 3.0.4 it would still fail because EnsurePythonVersion allows any version equal to or greater. Meaning Python 3 would still pass that check and then fail on our SConscripts since they're only Python 2 compatible.

Comment by Andrew Morrow (Inactive) [ 07/Jun/19 ]

The issue here is that buildscripts/scons.py on some older branches isn't py3 compatible.

We should ensure that buildscripts/scons.py is py2 and py3 compatible on all branches.

It appears that this is already the case for master and v4.2, however, we should update the file to contain documentation at the top stating that it must remain that way. So we should do that on master and backport to v4.2.

For the older branches (v4.0, v3.6, and v3.4), we should update the file to be also compatible with py3, and add the same documentation to the file stating that it must remain that way.

mathew.robinson, I'm handing this ticket over to you to make the necessary changes. It isn't our most pressing issue, so I'm going to kick it to the next sprint too.

Generated at Thu Feb 08 04:57:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.