Bill Deegan
2018-09-06 21:09:57 UTC
Perhaps you can explain what you're actually trying to do, rather than
providing a toy example?
That will help provide more context correct help.
providing a toy example?
That will help provide more context correct help.
Hi,
I've got another question, this is over the use of SConscriptChdir
such as env.SConscriptChdir(0)
from what I can gather when specifying a File or Dir object or making a
call to a Command builder at least which will automatically convert a
string target to a File object.
The File / Dir object will always be relative to the current SConstruct
file.
Not relative to the originating SConstruct file (which is what I'm trying
to do)
To give an example
src1\test1.txt - empty test file
src1\test2.txt - empty test file
src1\SConstruct
```
import os
EnsureSConsVersion(3, 0, 0)
# Setup the construction env
env = Environment(ENV={'PATH': os.environ['PATH']})
# Set working directory to not change
env.SConscriptChdir(0)
# Load in an external script
SConscript('../src2/testsubscript.py', {'env': env})
```
src2\SConstruct
```
# Import the scons environment from the calling script
Import('env')
# At this point the 'testfile.txt' will be automatically changed to a
File class by SCons
# print the path scons thinks this file is located at
print(target[0].path)
tgt = env.Command(File('testfile.txt'), [], build_test)
env.Default(tgt)
tgt2 = env.Command('testfile2.txt', [], build_test)
env.Default(tgt2)
# Even though SConscriptChdir is set to 0 in the originating env, File
uses the current script as it's reference point
# D:\Temp\testproject\src2\testfile.txt
# D:\Temp\testproject\src2\testfile2.txt
```
Is this expected behaviour?
perhaps SConscriptChdir only influences when calling exe's rather than the
use of File or Dir
is there some public API way of setting the current directory for File /
Dir calls?
thats not the directory of the current SConsscript
since builders wrap everything in a File automatically, it might mean I
have to make sure all file paths are absolute before hand.
Many Thanks
Richard
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
I've got another question, this is over the use of SConscriptChdir
such as env.SConscriptChdir(0)
from what I can gather when specifying a File or Dir object or making a
call to a Command builder at least which will automatically convert a
string target to a File object.
The File / Dir object will always be relative to the current SConstruct
file.
Not relative to the originating SConstruct file (which is what I'm trying
to do)
To give an example
src1\test1.txt - empty test file
src1\test2.txt - empty test file
src1\SConstruct
```
import os
EnsureSConsVersion(3, 0, 0)
# Setup the construction env
env = Environment(ENV={'PATH': os.environ['PATH']})
# Set working directory to not change
env.SConscriptChdir(0)
# Load in an external script
SConscript('../src2/testsubscript.py', {'env': env})
```
src2\SConstruct
```
# Import the scons environment from the calling script
Import('env')
# At this point the 'testfile.txt' will be automatically changed to a
File class by SCons
# print the path scons thinks this file is located at
print(target[0].path)
tgt = env.Command(File('testfile.txt'), [], build_test)
env.Default(tgt)
tgt2 = env.Command('testfile2.txt', [], build_test)
env.Default(tgt2)
# Even though SConscriptChdir is set to 0 in the originating env, File
uses the current script as it's reference point
# D:\Temp\testproject\src2\testfile.txt
# D:\Temp\testproject\src2\testfile2.txt
```
Is this expected behaviour?
perhaps SConscriptChdir only influences when calling exe's rather than the
use of File or Dir
is there some public API way of setting the current directory for File /
Dir calls?
thats not the directory of the current SConsscript
since builders wrap everything in a File automatically, it might mean I
have to make sure all file paths are absolute before hand.
Many Thanks
Richard
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users