Skip to content

DM-55791: Ignore bin.src Glob results with no source file (workaround SCons 4.11) - #150

Merged
timj merged 1 commit into
mainfrom
tickets/DM-55791
Aug 12, 2026
Merged

timj merged 1 commit into
mainfrom
tickets/DM-55791

Conversation

@timj

@timj timj commented Aug 12, 2026

Copy link
Copy Markdown
Member

SCons 4.11 changed Variables.Update() to resolve each saved-variables file through env.File() instead of testing it with os.path.exists(). File() creates the node whether or not the file is there, relative to the directory of the SConscript being read, so importing sconsUtils creates a node for the buildOpts.py that state._initVariables() always asks for. Glob() reports the nodes SCons knows about in a directory as well as the files on disk, so when a package first imports sconsUtils from bin.src/SConscript, the node lands in bin.src and shebang() builds a rewrite target for a source that does not exist:

scons: *** [bin/buildOpts.py] Source `bin.src/buildOpts.py' not found, needed by target `bin/buildOpts.py'.

Only rewrite entries backed by a readable file. Resolve through rexists() and the source node so a script found in a repository or a separate source directory is still rewritten.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.48%. Comparing base (aaf73f2) to head (83c77db).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #150   +/-   ##
=======================================
  Coverage   79.48%   79.48%           
=======================================
  Files           3        3           
  Lines          39       39           
  Branches        4        4           
=======================================
  Hits           31       31           
  Misses          4        4           
  Partials        4        4           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Glob() is documented to report the entries SCons knows about in a
directory, whether or not a file is present.  Only a file can have its
shebang rewritten, so ask the file system instead.

SCons 4.11 made this distinction matter.  Variables.Update() now
resolves each saved-variables file through env.File(), which creates
the node whether or not the file is there, relative to the directory of
the SConscript being read.  sconsUtils always offers an optional
buildOpts.py to Variables, so importing it from bin.src/SConscript, as
a package that does not use BasicSConstruct may do, left a node in
bin.src for a file that has never existed.  Glob() duly reported it and
the build failed:

  scons: *** [bin/buildOpts.py] Source `bin.src/buildOpts.py' not found,
  needed by target `bin/buildOpts.py'.

SCons upstream confirm in SCons/scons#4893 that Glob() is behaving as
intended and that code wanting the files on disk should use the glob
module.

Every entry in bin.src is a file checked in with the package, so nothing
is lost by ignoring the build graph here.  A caller passing src
explicitly is unaffected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@timj
timj force-pushed the tickets/DM-55791 branch from e8ae96a to 83c77db Compare August 12, 2026 17:30
@timj

timj commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

@mwittgen based on feedback from my scons ticket I've changed the PR to use glob.glob instead of Glob since we know that it is looking for existing files and not generated files.

Comment thread python/lsst/sconsUtils/scripts.py
@timj
timj merged commit 5d57135 into main Aug 12, 2026
25 checks passed
@timj
timj deleted the tickets/DM-55791 branch August 12, 2026 20:10
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.

2 participants