godot: TypeError in methods.py when running initial build with vsproj=yes (SCons 4.5.0 regression)

Godot version

4.0-stable, 3.5.2-stable

System information

Windows 10

Issue description

My first time building Godot ever, I compiled 4.0 with scons platform=windows and everything ran perfectly fine, but once I realized I needed to specify something else to get the visual studio solution, I compiled it again with scons platform=windows vsproj=yes and received the following error:

Found MSVC version 14.3, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
TypeError: can only concatenate deque (not "list") to deque:
  File "\godot\SConstruct", line 927:
    methods.generate_vs_project(env, GetOption("num_jobs"), env["vsproj_name"])
  File "\godot\methods.py", line 860:
    module_configs = ModuleConfigs()
  File "\godot\methods.py", line 764:
    self.add_mode()  # default
  File "\godot\methods.py", line 787:
    self.arg_dict["cppdefines"] += ModuleConfigs.for_every_variant(env["CPPDEFINES"] + defines)

I then tried to figure out if it was just a 4.0 issue, so I cloned a fresh 3.5.2 repo and tried compiling with vsproj=yes and yet again was met with the same error. I also tried downgrading from current python version down to 3.6.1, but the error remained. Prior to posting this, I noticed this issue, which seems like it could be related, but being unsure since it was slightly different, I’m proceeding here.

I ended up “solving” the issue by adding from collections import deque to the start of methods.py and changing line 773 from defines = [] to defines = deque(). It allowed the build to proceed, created the visual studio solution, and doesn’t appear to have created any issues. However, I do not know enough about the build process or the project in general to truly know whether my “fix” creates any negative side effects, so hopefully someone more knowledgeable than me can chime in on that.

Steps to reproduce

  1. Clone a fresh repo from either 4.0-stable or 3.5.2-stable (possibly even older versions as well).
  2. Build on windows 10 with scons platform=windows vsproj=yes
  3. Should give you the error.

Minimal reproduction project

N/A

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 14
  • Comments: 16 (2 by maintainers)

Most upvoted comments

This is a SCons 4.5.0 regression. Run pip uninstall scons then pip install scons==4.4.0 to fix this.

I ran into this issue as well.

For now I just installed an older version of SCons instead using pip install SCons==4.4.0.

Also worth mentioning for anyone searching: SCons 4.5.1 also doesn’t work with 2022 Preview but gives a slightly different error: TypeError: 'NoneType' object is not iterable (Full error screenshot – sorry didn’t think to copy the text.)

I’m having this issue with Visual Studio 2022 (Not preview) and even when rolling back to 4.4.0. Anyone having any luck?

I just ran into this as well, it looks to be cause by this change in Scons: https://github.com/SCons/scons/commit/b28e86d47635d1ae4ae63eac603f166ec7c95221

methods.py appears to be bypassing the Scons public API and just using a + operator, which is now illegal, because (as you can tell by the symptoms) env["CPPDEFINES"] is no longer a list, but a deque.

It looks like the “Scons way” is to use env.Append(CPPDEFINES = ...) or env.AppendUnique(CPPDEFINES = ...) (See https://github.com/SCons/scons/issues/3876)

Although I have a lot of Python experience, I have no Scons experience at all, so I’m not certain about the above, or which solution is appropriate. Although changing line 773 from defines = [] to defines = deque() will work for Scons 4.5.1, it will almost certainly break previous versions.

I have multiple visual studio versions installed, but if you check the start of the error message, you can see that it is using the 14.3 compiler.

I have the exact same issue with latest main branch too What Visual Studio version you on?