0

I have a script (Python) that check if I have the right modules installed and if they are up to date -- at least a certain version. I want to run this script in the scons Configure phase. I tried something like:

print 'Configuring... '
conf = Configure(env)
print 'Checking Python modules ', 
ret = conf.TryRun("""#!/usr/bin/env python
print 'ook' # test
import my_script
my_script.run()
""", '.py')
if ret == (0, ''):
    print 'Fail'
    sys.exit(2)
env = conf.Finish()

But all I get is (0, '') which means that TryRun failed but I cannot see why it would fail! Any idea as to what I am doing wrong?

Sardathrion - against SE abuse
  • 17,269
  • 27
  • 101
  • 156

1 Answers1

0

This does the trick but is not very elegant:

from subprocess import call
if call(os.path.join(os.getcwd(), 'my_script.py')):
    sys.exit(2)

I am still looking for a more elegant solution.

Sardathrion - against SE abuse
  • 17,269
  • 27
  • 101
  • 156