Skip to content
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

SCons: Fix Python 2 support after #43057 #45897

Closed
wants to merge 1 commit into from

Conversation

akien-mga
Copy link
Member

That's not a very pretty way to parse a string from a python file
though, there should definitely be cleaner and more reliable ways
to do this without using exec().

That's not a very pretty way to parse a string from a python file
though, there should definitely be cleaner and more reliable ways
to do this without using `exec()`.
@Xrayez
Copy link
Contributor

Xrayez commented Feb 11, 2021

That's what SCons does while parsing Python scripts. It's not reliable to import those files with sys.path.insert(0, tmppath), it would definitely require more finicky ways to make it work with custom modules which may reside virtually anywhere on your filesystem. I've actually tried this approach first, but with no success unfortunately.

There might be better ways to do this, not denying that. 🙂

@akien-mga
Copy link
Member Author

Found a slightly nicer way in https://stackoverflow.com/a/56800610.

@Xrayez
Copy link
Contributor

Xrayez commented Feb 11, 2021

I haven't used execfile because it's not supported by Python 3.x, which #43057 targeted. https://stackoverflow.com/questions/436198/what-is-an-alternative-to-execfile-in-python-3

@akien-mga
Copy link
Member Author

akien-mga commented Feb 11, 2021

Ah indeed, I had tested it with Python 3 but without actually making use of that code.

So back to:

exec(f.read(), version) in locals()

which seems to work.

That being said, with or without that fix, I'm getting:

$ scons p=x11 -j7 custom_modules=..
/usr/bin/scons p=x11 -j7 custom_modules=.. 2>&1 | tee -a build.log
scons: Reading SConscript files ...
  File "<string>", line 107
    raise ValueError, "invalid version number '%s'" % vstring
                    ^
SyntaxError: invalid syntax

Same error on the master branch.

@akien-mga
Copy link
Member Author

Superseded by #45901.

@akien-mga akien-mga closed this Feb 11, 2021
@akien-mga akien-mga modified the milestones: 3.2, 3.3 Apr 20, 2021
@akien-mga akien-mga deleted the 3.2-fix-py2-support branch October 4, 2021 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants