[ADD] virtualenv creation

This commit is contained in:
Sylvain LE GAL 2022-03-28 16:59:36 +02:00
parent a27fcabbba
commit c069757168
4 changed files with 25 additions and 5 deletions

View File

@ -4,6 +4,7 @@ from odoo_openupgrade_wizard.configuration_version_dependant import (
_get_repo_file,
)
from odoo_openupgrade_wizard.tools_system import (
create_virtualenv,
ensure_folder_exists,
git_aggregate,
)
@ -24,5 +25,8 @@ def build(ctx):
# 1. Create main folder for the odoo version
ensure_folder_exists(step["local_path"], mode="777")
# 2. gitaggregate source code
# 2. Create virtual environment
create_virtualenv(step["local_path"], step["python"])
# 3. gitaggregate source code
git_aggregate(step["local_path"], _get_repo_file(ctx, step))

View File

@ -1,10 +1,12 @@
import argparse
import os
import subprocess
from git_aggregator import main as gitaggregate_cmd
from git_aggregator.utils import working_directory_keeper
from jinja2 import Template
from loguru import logger
from plumbum import local
from plumbum.cmd import mkdir
@ -63,3 +65,18 @@ def git_aggregate(folder_path, config_path):
% config_path
)
gitaggregate_cmd.run(args)
def create_virtualenv(folder_path, python_version):
"""
Create a virtual env named ``env`` in the ``folder_path`` folder
with the given ``python_version``.
"""
with local.cwd(folder_path):
logger.info(
"Create Virtual Env in %s with version %s"
% (folder_path, python_version)
)
subprocess.check_output(
["virtualenv", "env", "--python", python_version]
)

View File

@ -1,2 +1,2 @@
[pytest]
norecursedirs = output/*
norecursedirs = output/*

View File

@ -1,4 +1,3 @@
import filecmp
from pathlib import Path
from click.testing import CliRunner
@ -9,10 +8,10 @@ from odoo_openupgrade_wizard.cli import main
def test_cli_build():
output_folder_path = Path("./tests/output")
expected_folder_path = Path("./tests/output_expected")
mkdir([output_folder_path, "--parents"])
# We initialize an env with only one version to avoid to git clone large data
# We initialize an env with only one version to avoid to git clone
# large data
CliRunner().invoke(
main,
[