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

Allow PathLib objects in sources #4400

Merged
merged 2 commits into from
Aug 27, 2023
Merged

Conversation

mwichmann
Copy link
Collaborator

Changes BuilderBase._adjustixes() to try converting the files arguments to path string - in a way that doesn't flip an existing SCons Node back to a string.

Unittest for _adjustixes is added to validate.

Fixes #4398

Open question:

A similar change in .src_builder_sources() may be needed, but the context here allows just using str() if needed, like:

diff --git a/SCons/Builder.py b/SCons/Builder.py
index 16b0cc22d..411bd1d8c 100644
--- a/SCons/Builder.py
+++ b/SCons/Builder.py
@@ -767,6 +767,8 @@ class BuilderBase:

         result = []
         for s in SCons.Util.flatten(source):
+            if isinstance(s, os.PathLike):
+                s = str(s)
             if SCons.Util.is_String(s):
                 match_suffix = match_src_suffix(env.subst(s))
                 if not match_suffix and '.' not in s:

Not sure at the moment how to force something down this code path so can check - comments welcome.

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 read the README.rst)
  • I have updated the appropriate documentation

mwichmann and others added 2 commits August 23, 2023 05:20
Changes BuilderBase._adjustixes() to try converting the files arguments
to path string - in a way that doesn't flip an existing SCons Node back
to a string.

Unittest for _adjustixes is added to validate.

Fixes SCons#4398

Signed-off-by: Mats Wichmann <mats@linux.com>
@bdbaddog bdbaddog merged commit 705ec08 into SCons:master Aug 27, 2023
4 of 5 checks passed
@mwichmann mwichmann added this to the NextRelease milestone Aug 27, 2023
@mwichmann mwichmann deleted the pathlib-in-builder branch August 27, 2023 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for sources specified as pathlib.Path objects
2 participants