@@ -6,10 +6,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
6
6
{% block kolla_toolbox_header %}{% endblock %}
7
7
8
8
{% set venv_path ='/opt/ansible' %}
9
- {% if base_package_type == 'rpm' %}
10
- {% set distro_python_version = '3.12' %}
11
- {% endif %}
12
- {% set os_client_config = venv_path + '/lib/python' + distro_python_version + '/site-packages/os_client_config/defaults.json' %}
9
+ {% set os_client_config = venv_path + '/lib/python3/site-packages/os_client_config/defaults.json' %}
13
10
14
11
{% import "macros.j2" as macros with context %}
15
12
@@ -63,11 +60,32 @@ COPY apt_preferences_rabbitmq.{{ base_distro }} /etc/apt/preferences.d/rabbitmq
63
60
{% endif %}
64
61
{{ macros.install_packages(kolla_toolbox_packages | customizable("packages")) }}
65
62
63
+ {# NOTE(kevko):
64
+ In all distros, there is always a /usr/bin/python3 -> python3.X.
65
+ However, this is disrupted for RHEL-based systems because, unlike
66
+ other distros, we upgrade Python above [1], but we forget to set
67
+ the default python3 to the new python3.X. As a result also, everything
68
+ outside of the virtual environment ends up running on Python 3.9.
69
+
70
+ So, let's correctly set python3 -> python3.X since we had to install
71
+ it and now have default python3 points to the new version.
72
+
73
+ [1] https://review.opendev.org/c/openstack/kolla/+/924245
74
+ #}
75
+ {% if base_package_type == 'rpm' %}
76
+ RUN cd /usr/bin && \
77
+ rm -f python3 && \
78
+ ln -s python3.12 python3
79
+ {% endif %}
80
+
66
81
{% block kolla_toolbox_upper_constraints %}
67
82
RUN mkdir -p /requirements \
68
83
&& curl -o /requirements/upper-constraints.txt ${UPPER_CONSTRAINTS_FILE:-https://releases.openstack.org/constraints/upper/{{ openstack_release }}} \
69
84
&& {{ macros.upper_constraints_remove("openstacksdk") }} \
70
- && python{{ distro_python_version }} -m venv --system-site-packages {{ venv_path }}
85
+ && python3 -m venv --system-site-packages {{ venv_path }} \
86
+ && KOLLA_DISTRO_PYTHON_VERSION=$(/usr/bin/python3 -c "import sys; print('{}.{}'.format(sys.version_info.major, sys.version_info.minor))") \
87
+ && cd {{ venv_path }}/lib \
88
+ && ln -s python${KOLLA_DISTRO_PYTHON_VERSION} {{ venv_path }}/lib/python3
71
89
{% endblock %}
72
90
73
91
ENV PATH {{ venv_path }}/bin:$PATH
@@ -86,8 +104,8 @@ ENV PATH {{ venv_path }}/bin:$PATH
86
104
'pyudev' ,
87
105
] %}
88
106
89
- RUN {{ macros.install_pip(['pip', 'wheel', 'setuptools'] , python_version=distro_python_version ) }} \
90
- && {{ macros.install_pip((kolla_toolbox_pip_packages | customizable("pip_packages")), python_version=distro_python_version ) }} \
107
+ RUN {{ macros.install_pip(['pip', 'wheel', 'setuptools'] ) }} \
108
+ && {{ macros.install_pip((kolla_toolbox_pip_packages | customizable("pip_packages"))) }} \
91
109
&& mkdir -p /etc/ansible /usr/share/ansible \
92
110
&& echo 'localhost ansible_connection=local ansible_python_interpreter={{ venv_path }}/bin/python' > /etc/ansible/hosts \
93
111
&& sed -i 's| "identity_api_version": "2.0",| "identity_api_version": "3",|' {{ os_client_config }}
0 commit comments