mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1170691 - part 1 - add the generating script's directory to sys.path in file_generate.py; r=glandium
The old way of writing scripts for generated files would invoke the script thusly: python script.py arg1... Invoking the script this way means that the script's directory is automatically added to sys.path, and importing modules from that directory is easy. Let's make it equally easy in the new world for GENERATED_FILES, too.
This commit is contained in:
parent
10f22ec9fa
commit
dd2f1cd7be
@ -30,6 +30,16 @@ def main(argv):
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
script = args.python_script
|
||||
# Permit the script to import modules from the same directory in which it
|
||||
# resides. The justification for doing this is that if we were invoking
|
||||
# the script as:
|
||||
#
|
||||
# python script arg1...
|
||||
#
|
||||
# then importing modules from the script's directory would come for free.
|
||||
# Since we're invoking the script in a roundabout way, we provide this
|
||||
# bit of convenience.
|
||||
sys.path.append(os.path.dirname(script))
|
||||
with open(script, 'r') as fh:
|
||||
module = imp.load_module('script', fh, script,
|
||||
('.py', 'r', imp.PY_SOURCE))
|
||||
|
Loading…
Reference in New Issue
Block a user