[Scons-users] visual studio 2019 with 2017 addon

Mats Wichmann mats at wichmann.us
Thu Jun 11 15:07:57 EDT 2020


On 6/11/20 12:09 PM, Pierre-Luc Boily wrote:
> Hello,
> 
> I am trying your solution like that : 
> 
>         sconsEnv =
> SCons.Environment.Environment(MSVC_VERSION=SCons.Script.GetOption('msvc'), 
>                                                  TARGET_ARCH='x86_64',
>                                                  MSVC_USE_SCRIPT='C:\Program
> Files (x86)\Microsoft Visual
> Studio\2017\Professional\VC\Auxiliary\Build\vcvarsx86_amd64.bat')
> 
> but I do have this error : 
> 
> AttributeError: __exit__:
>   File "C:\SVN\products\ice\angola\integ-clean\SConstruct", line 27:

For what it's worth, in your SConstruct/SConscript, you don't have to
use the module path qualifiers, when running SCons those are already in
scope.  So you can do

sconsEnv = Environment(MSVC_VERSION=GetOption('msvc')...) etc.

I notice with some dismay that there are no unit tests or integration
tests about using MSVC_USE_SCRIPT, so I'm worried about how solid it has
been across various changes since it was introduced in 2009-ish
(according to git).

> .
>   File
> "c:\users\pboily\appdata\local\programs\python\python35\lib\site-packages\scons\SCons\Tool\MSCommon\vc.py",
> line 579:
>     stdout = common.get_output(script, args)
>   File
> "c:\users\pboily\appdata\local\programs\python\python35\lib\site-packages\scons\SCons\Tool\MSCommon\common.py",
> line 192:
>     with popen.stdout:
> 
> After a quick search I found that : 
> "with statement requires an object with __enter__ and __exit__ methods"
> 
> In common.py, popen object is created by SCons.Action._subproc. It looks
> like _subproc is based on subprocess.popen.
> 
> I am not sure if that object has an __enter__ and __exit__ methods?  Or is
> there something else I am doing that is incorrect?
> 
> I also tried the following (removed with statement) : 
> 
>     #with popen.stdout:
>     stdout = popen.stdout.read()
>     #with popen.stderr:
>     stderr = popen.stderr.read()
> 
> But then, I have the error : 
> AttributeError: 'str' object has no attribute 'decode':
> 
> I guess that popen.stdout.read() returns an str object...

this area is a familiar problem.  I wanted to shift all this to using
text mode (aka universal_newlines), but apparently there are places
where this won't work on Windows.  So yeah, we get back bytes - this may
be code that has been made better in current master, there's been work
here.

The whole bit of stuff *should* be able to use subprocess.run() which
gets you back a CompletedProcess object with data already fetched, and
don't have to play with context managers while reading from the pipe,
waiting, etc... but apparently that doesn't work on non-threaded
Windows, which NOBODY uses any more, but it's still technically a
supported build model for the two older Python versions scons still
supports (3.5, 3.6).

all this doesn't help you, just ack'ing that there is much pain here.

I'll try to take a quick look later since I brought it up, maybe not today.




More information about the Scons-users mailing list