Skip to content

Commit

Permalink
[dockerfile-macros] Make install_python_wheels work with both py2 and…
Browse files Browse the repository at this point in the history
… py3 packages

Use PEP-425 Python tag to differentiate between package python version

Signed-off-by: Volodymyr Boyko <[email protected]>
  • Loading branch information
vboykox committed Sep 26, 2020
1 parent e6ca715 commit 3106a78
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion dockers/dockerfile-macros.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,31 @@ RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return
{%- endfor %}
{%- endmacro %}

{% macro install_python_wheels(packages) -%}
{% macro install_python2_wheels(packages) -%}
RUN cd /python-wheels/ && pip install {{ packages | join(' ') }}
{%- endmacro %}

{% macro install_python3_wheels(packages) -%}
RUN cd /python-wheels/ && pip3 install {{ packages | join(' ') }}
{%- endmacro %}

{% macro install_python_wheels(packages) -%}
{%- set py2_pkgs, py3_pkgs = [], [] %}
{%- for pkg in packages %}
{%- if 'py3' in pkg %}
{{- py3_pkgs.append(pkg) or '' }}
{%- else %}
{{- py2_pkgs.append(pkg) or '' }}
{%- endif %}
{%- endfor %}
{%- if py3_pkgs | length %}
{{ install_python3_wheels(py3_pkgs) }}
{%- endif %}
{%- if py2_pkgs | length %}
{{ install_python2_wheels(py2_pkgs) }}
{%- endif %}
{%- endmacro %}

{% macro copy_files(prefix, files, dest) -%}
COPY \
{%- for file in files %}
Expand Down

0 comments on commit 3106a78

Please sign in to comment.