From 85985cdadc35769e19c4f4d4e82f9fe001ab3830 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Mon, 13 Mar 2017 15:57:00 +1100 Subject: [PATCH] Make our virtualenv source py3 safe execfile() has gone in python3, and if you google various stackoverflow results, python-dev mailing list threads and other projects it seems runpy is considered one of the better solutions. This should be py2.7 safe too. Change-Id: I18077ba9d603752492cc81f260e12710981f4dff --- diskimage_builder/disk_image_create.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/diskimage_builder/disk_image_create.py b/diskimage_builder/disk_image_create.py index fba2bdc0d..35388d148 100644 --- a/diskimage_builder/disk_image_create.py +++ b/diskimage_builder/disk_image_create.py @@ -14,6 +14,7 @@ import os import os.path +import runpy import sys import diskimage_builder.paths @@ -32,7 +33,9 @@ def running_under_virtualenv(): def activate_venv(): if running_under_virtualenv(): activate_this = os.path.join(sys.prefix, "bin", "activate_this.py") - execfile(activate_this, dict(__file__=activate_this)) + globs = runpy.run_path(activate_this, globals()) + globals().update(globs) + del globs def main():