This commit is contained in:
Sylvain LE GAL 2022-06-27 21:59:57 +02:00
parent bacca4f7c6
commit bac5d0d22e
4 changed files with 35 additions and 60 deletions

View File

@ -3,10 +3,8 @@ from pathlib import Path
import click
from odoo_openupgrade_wizard.configuration_version_dependant import (
get_odoo_version_settings,
get_odoo_version_template_value,
get_odoo_versions,
get_python_major_version,
get_python_minor_version_short,
get_version_options,
)
from odoo_openupgrade_wizard.tools.tools_odoo import get_odoo_env_path
@ -69,9 +67,6 @@ def init(
odoo_versions = get_odoo_versions(
float(initial_version), float(final_version)
)
odoo_version_settings = get_odoo_version_settings(
float(initial_version), float(final_version)
)
# 2. Compute Migration Steps
@ -137,7 +132,6 @@ def init(
project_name=project_name,
steps=steps,
odoo_versions=odoo_versions,
odoo_version_settings=odoo_version_settings,
)
# 7. Ensure module list file exists
@ -186,9 +180,14 @@ def init(
path_version / Path("Dockerfile"),
"odoo/Dockerfile.j2",
odoo_version=odoo_version,
python_major_version=get_python_major_version(odoo_version),
python_minor_version_short=get_python_minor_version_short(
odoo_version
python_major_version=get_odoo_version_template_value(
odoo_version, "python_major_version"
),
python_minor_version_short=get_odoo_version_template_value(
odoo_version, "python_minor_version_short"
),
prebuild_wheel_url=get_odoo_version_template_value(
odoo_version, "prebuild_wheel_url"
),
)

View File

@ -7,73 +7,70 @@ _ODOO_VERSION_TEMPLATES = [
"version": 8.0,
"python_major_version": "python2",
"python_minor_version_short": "py27",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux1",
},
{
"version": 9.0,
"python_major_version": "python2",
"python_minor_version_short": "py27",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux1",
},
{
"version": 10.0,
"python_major_version": "python2",
"python_minor_version_short": "py27",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux1",
},
{
"version": 11.0,
"python_major_version": "python3",
"python_minor_version_short": "py36",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux2014",
},
{
"version": 12.0,
"python_major_version": "python3",
# Note: doesn't work with latest available version py37
"python_minor_version_short": "py36",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux2014",
},
{
"version": 13.0, # OK.
"python_major_version": "python3",
# Note: doesn't work with latest available version py37
"python_minor_version_short": "py36",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux2014",
},
{
"version": 14.0, # OK
"python_major_version": "python3",
"python_minor_version_short": "py39",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux2014",
},
{
"version": 15.0, # OK
"python_major_version": "python3",
"python_minor_version_short": "py39",
"prebuild_wheel_url": "https://wheelhouse.acsone.eu/manylinux2014",
},
]
def get_version_template(version: float) -> dict:
"""return a version template dictionnary according to a version
provided"""
for version_template in _ODOO_VERSION_TEMPLATES:
if version_template["version"] == version:
return version_template
def get_odoo_version_template_value(version: float, key: str) -> str:
"""Return a value depending on a odoo given version and key.
Possible key:
- python_major_version. (python2, python3)
- python_minor_version_short. (py27, py36, ...)
- prebuild_wheel_url.
"""
version_template = False
for odoo_version_template in _ODOO_VERSION_TEMPLATES:
if odoo_version_template["version"] == version:
version_template = odoo_version_template
break
else:
raise ValueError
def get_python_libraries(version: float) -> list:
"""Return a list of python librairies that should be
installed in each docker container for a given version"""
return get_version_template(version)["python_libraries"]
def get_python_major_version(version: float) -> str:
"""Return the major python version (2.0, 3.0) of Odoo for
a given version"""
return get_version_template(version)["python_major_version"]
def get_python_minor_version_short(version: float) -> str:
"""Return the default minor python version (py27, py38) of Odoo for
a given version"""
return get_version_template(version)["python_minor_version_short"]
return version_template[key]
def get_version_options(mode: str) -> list:
@ -93,27 +90,10 @@ def get_version_options(mode: str) -> list:
return version_options
def get_odoo_version_settings(
initial_version: float, final_version: float
) -> list:
"""Return a list of odoo version settings from the initial version to the final
version
"""
result = []
for version_template in _ODOO_VERSION_TEMPLATES:
if (
version_template["version"] >= initial_version
and version_template["version"] <= final_version
):
result.append(version_template)
return result
def get_odoo_versions(initial_version: float, final_version: float) -> list:
"""Return a list of odoo versions from the initial version to the final
version
"""
# TODO, call get_odoo_version_settings() and call keys()
result = []
for version_template in _ODOO_VERSION_TEMPLATES:
if (

View File

@ -14,9 +14,9 @@ odoo_versions:
odoo_version_settings:
{%- for setting in odoo_version_settings %}
{{setting['version']}}:
python_minor_version_short: {{setting['python_minor_version_short']}}
{%- for odoo_version in odoo_versions %}
{{odoo_version}}:
repo_url: False
{%- endfor %}

View File

@ -11,9 +11,5 @@ RUN apt-get update || true \
# 3. Install extra Python librairies
RUN \
pip install --no-cache-dir \
-r /odoo_requirements.txt \
-f https://wheelhouse.acsone.eu/manylinux2014\
&& pip install --no-cache-dir \
-r /python_requirements.txt \
-f https://wheelhouse.acsone.eu/manylinux2014
/odoo/bin/pip install --no-cache-dir -r /odoo_requirements.txt -f {{prebuild_wheel_url}} \
&& /odoo/bin/pip install --no-cache-dir -r /python_requirements.txt -f {{prebuild_wheel_url}}