scons icon indicating copy to clipboard operation
scons copied to clipboard

Supply modules in the globals passed to eval

Open bdbaddog opened this issue 7 years ago • 1 comments

This issue was originally created at: 2002-02-06 21:00:00. This issue was reported by: stevenknight. stevenknight said at 2002-02-06 21:00:00

Mail from Charles Crain (7 Feb 2002):

  • One person didn't like our special ${TARGET.dir} attributes. He wondered why we didn't do something like the Pythonic ${os.dirname(TARGET)}. I think that's too verbose, myself.

Again, it's the old question of do we invent our own syntax. Here's an idea...since we are eval()'ing everything that goes in the ${...} to being with, all we need to do is supply some modules (like os.path) in the globals we pass to eval(), and the above would work. You could use Python API's, or our own syntax (which IS still Python syntax BTW, or else we couldn't eval() it).

issues@scons said at 2002-02-06 21:00:00

Converted from SourceForge task item 47449

stevenknight said at 2006-05-20 20:37:48

Remove obsolete (and bogus) "Blue Sky" keyword.

gregnoel said at 2008-04-02 12:20:39

Assigned to Brandon to research and suggest an API for placing modules in the eval namespace and then return this issue to triage.

gregnoel said at 2008-04-18 18:47:39

We shouldn't have UNCONFIRMED issues; changing them to NEW.

azverkan said at 2009-03-01 22:41:27

This is already possible with the existing code, but the syntax is a bit wordy as you have to convert TARGET into a string.

import os

env = Environment(os=os)
env.Command("fake_out", None, "echo ${os.path.abspath(str(TARGET))}")

It's not obvious that you can store Python modules in the Environment (but is intuitive after you think about it). I'd suggest we just add this trick to the documentation rather than inventing something new to do what is already possible.

stevenknight said at 2009-03-03 06:56:31

Reset target milestone to -unspecified- for Bug Party re-triaging.

gregnoel said at 2009-04-30 13:51:11

Bug party triage. Needs to be done quickly before 1.3 freezes.

gregnoel said at 2010-01-20 03:37:53

Not completed in time for the 1.3 release; move to 2.1 p2.

garyo said at 2012-09-01 10:01:49

Bumping all old issues targeted for past releases to 2.x.

bdbaddog avatar Jan 02 '18 05:01 bdbaddog

This morphed to a doc request: worth doing?

mwichmann avatar May 28 '22 17:05 mwichmann