Use venv API for building the venv instead of calling pyvenv
This commit is contained in:
parent
7813d9a93d
commit
2404c75012
@ -30,6 +30,7 @@ import argparse
|
|||||||
import subprocess
|
import subprocess
|
||||||
import distutils.sysconfig # pylint: disable=import-error
|
import distutils.sysconfig # pylint: disable=import-error
|
||||||
# see https://bitbucket.org/logilab/pylint/issue/73/
|
# see https://bitbucket.org/logilab/pylint/issue/73/
|
||||||
|
import venv
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
|
||||||
from scripts import utils
|
from scripts import utils
|
||||||
@ -140,20 +141,28 @@ def link_pyqt():
|
|||||||
|
|
||||||
def create_venv():
|
def create_venv():
|
||||||
"""Create a new venv."""
|
"""Create a new venv."""
|
||||||
utils.print_title("Creating venv using pyvenv")
|
utils.print_title("Creating venv")
|
||||||
|
|
||||||
if os.name == 'nt':
|
system_site_packages = True
|
||||||
sys_site = ['--system-site-packages']
|
|
||||||
else:
|
|
||||||
sys_site = []
|
|
||||||
|
|
||||||
command = ['pyvenv'] + sys_site
|
clear = False
|
||||||
if g_args.clear or g_args.force:
|
if g_args.clear or g_args.force:
|
||||||
command += ['--clear']
|
clear = True
|
||||||
|
|
||||||
|
upgrade = False
|
||||||
if g_args.upgrade:
|
if g_args.upgrade:
|
||||||
command += ['--upgrade']
|
upgrade = True
|
||||||
command += [g_path]
|
|
||||||
subprocess.check_call(command)
|
symlinks = False if os.name == 'nt' else True
|
||||||
|
|
||||||
|
builder = venv.EnvBuilder(system_site_packages=system_site_packages,
|
||||||
|
clear=clear, upgrade=upgrade,
|
||||||
|
symlinks=symlinks, with_pip=True)
|
||||||
|
|
||||||
|
context = builder.ensure_directories(g_path)
|
||||||
|
builder.create_configuration(context)
|
||||||
|
builder.setup_python(context)
|
||||||
|
builder.setup_scripts(context)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
Reference in New Issue
Block a user