Commit 9a118cc8 authored by Xavier Thompson's avatar Xavier Thompson

Make venv for target Python in tests

When possible, use venv to create the target Python in the tests.
This creates an isolated Python, and quite importantly maintains
isolation from system packages when the initial Python is itself
from a virtual environment.
parent 83d658a0
...@@ -50,12 +50,16 @@ class Pyinstall: ...@@ -50,12 +50,16 @@ class Pyinstall:
def __init__(self, buildout, name, options): def __init__(self, buildout, name, options):
self.options = options self.options = options
options['executable'] = os.path.join(buildout['buildout'][ self.part_dir = os.path.join(buildout['buildout']['parts-directory'], name)
'parts-directory'], name, 'bin', 'python') options['executable'] = os.path.join(self.part_dir, 'bin', 'python')
def install(self): def install(self):
python = self.options['executable'] python = self.options['executable']
if not os.path.exists(python): if not os.path.exists(python):
try:
from venv import create
create(self.part_dir, clear=True)
except ImportError:
d = os.path.dirname(python) d = os.path.dirname(python)
os.path.exists(d) or os.makedirs(d) os.path.exists(d) or os.makedirs(d)
shutil.copy(sys.executable, python) shutil.copy(sys.executable, python)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment