-
So my SConstruct looks like this import re
import os
from pathlib import Path
source_files_path_prefix = Path(__file__).parent / 'src'
source_files = [source_files_path_prefix / filename for filename in os.listdir(source_files_path_prefix)]
print(source_files) If I run this text file via Python 3.13, it will print
but if I run
I thought SConstruct files are regular python scripts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Strictly speaking, they're not standalone Python scripts - if they were, you'd have to be importing all of the things that form the SCons API. Instead, they are snippets (potentially very large ones) written in Python that are evaluated (actually, compiled then exec'd) in the context of SCons. While the result you get surprises me (not defined), you won't get what you are looking for here: the context while the If you're looking for a way to generate a list of files in a particular directory, SCons provides some ways that might help - see, in particular: https://scons.org/doc/production/HTML/scons-man.html#f-Glob To SCons' file-handling routines, source_files = Glob('#/src') # returns a list of nodes
# or
source_files = Glob('#/src', strings=True) # returns a list of strings Glob has the advantage of finding files that don't exist now, but might (that is, files generated by SCons during the run). |
Beta Was this translation helpful? Give feedback.
Strictly speaking, they're not standalone Python scripts - if they were, you'd have to be importing all of the things that form the SCons API. Instead, they are snippets (potentially very large ones) written in Python that are evaluated (actually, compiled then exec'd) in the context of SCons. While the result you get surprises me (not defined), you won't get what you are looking for here: the context while the
SConstruct
/SConscript
is being run is actually.../SCons/Script/SConscript.py
.If you're looking for a way to generate a list of files in a particular directory, SCons provides some ways that might help - see, in particular:
https://scons.org/doc/production/HTML/scons-man.html#f-Glob