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

Fix CacheDir initialization so works on 3.7 also #4695

Merged
merged 4 commits into from
Mar 13, 2025

Conversation

mwichmann
Copy link
Collaborator

Although there is no indication of a change in this area of the tempfile module, it seems if the temporary directory has been renamed so the original no longer exists, the context manager fails on 3.7, though not on any later Python versions (maybe a bugfix rather than a planned behavior change?). Now use mkdtemp instead, and clean it up by hand if the rename failed (also use os.replace instead of os.rename, so it will actually fail if the destination directory existed and is nonempty, on Linux os.rename doesn't fail in this case).

Fixes #4694

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt and RELEASE.txt (and read the README.rst).
  • I have updated the appropriate documentation

Although there is no indication of a change in this area of the tempfile
module, it seems if the temporary directory has been renamed so the
original no longer exists, the context manager fails on 3.7, though
not on any later Python versions (maybe a bugfix rather than a planned
behavior change?). Now use mkdtemp instead, and clean it up by hand
if the rename failed (also use os.replace instead of os.rename,
so it will actually fail if the directory existed and is nonempty,
on Linux os.rename doesn't fail in this case).

Fixes SCons#4694

Signed-off-by: Mats Wichmann <[email protected]>
@jcbrill
Copy link
Contributor

jcbrill commented Mar 10, 2025

FWIW: all 30 CacheDir related tests that failed in #4694 pass for all python versions 3.7 to 3.13 in both linux and Windows with the first commit of this PR locally.

@mwichmann
Copy link
Collaborator Author

Thanks for that update!

Mainly restores VS 2022 image builds, which were commented out.
If they're still broken, we can revert.

Signed-off-by: Mats Wichmann <[email protected]>
mwichmann and others added 2 commits March 12, 2025 08:37
The failure on Python 3.7 caused a rewrite. Redo that so the version
released with SCons 4.9.0 is still present, but commented out, so it's
easier to restore it in future.  tempfile.TemporaryDirectory has better
cleanup logic, so we'll want to flip to that when Python 3.7 support
is retired.

Signed-off-by: Mats Wichmann <[email protected]>
@bdbaddog bdbaddog merged commit abdfea7 into SCons:master Mar 13, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SCons 4.9.0 test suite failures with python 3.7
3 participants