From bac5d0d22e77ab9f664a7d522100be4d1e4b8ec8 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Mon, 27 Jun 2022 21:59:57 +0200 Subject: [PATCH] wip --- odoo_openupgrade_wizard/cli/cli_init.py | 19 +++--- .../configuration_version_dependant.py | 62 +++++++------------ .../templates/config.yml.j2 | 6 +- .../templates/odoo/Dockerfile.j2 | 8 +-- 4 files changed, 35 insertions(+), 60 deletions(-) diff --git a/odoo_openupgrade_wizard/cli/cli_init.py b/odoo_openupgrade_wizard/cli/cli_init.py index 57c47f5..db575ef 100644 --- a/odoo_openupgrade_wizard/cli/cli_init.py +++ b/odoo_openupgrade_wizard/cli/cli_init.py @@ -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" ), ) diff --git a/odoo_openupgrade_wizard/configuration_version_dependant.py b/odoo_openupgrade_wizard/configuration_version_dependant.py index 38f3a81..57777fb 100644 --- a/odoo_openupgrade_wizard/configuration_version_dependant.py +++ b/odoo_openupgrade_wizard/configuration_version_dependant.py @@ -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 ( diff --git a/odoo_openupgrade_wizard/templates/config.yml.j2 b/odoo_openupgrade_wizard/templates/config.yml.j2 index d3209b5..3df6652 100644 --- a/odoo_openupgrade_wizard/templates/config.yml.j2 +++ b/odoo_openupgrade_wizard/templates/config.yml.j2 @@ -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 %} diff --git a/odoo_openupgrade_wizard/templates/odoo/Dockerfile.j2 b/odoo_openupgrade_wizard/templates/odoo/Dockerfile.j2 index 6a226d4..130559f 100644 --- a/odoo_openupgrade_wizard/templates/odoo/Dockerfile.j2 +++ b/odoo_openupgrade_wizard/templates/odoo/Dockerfile.j2 @@ -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}}