Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.
This repository was archived by the owner on May 8, 2025. It is now read-only.

Enhance role to have more control over the Python build #216

@PrieJos

Description

@PrieJos

Dear developers,

This is a request for improvement that will allow this role to have more control over the Python build.

Basically in order to compile and build Python for maximum performance, the following configure and GCC flags are recommended to be specified:

  • configure: --enable-optimizations --with-lto
  • GCC flags: -march=native -mtune=native

This is what indeed pyenv also recommends at Building for maximum performance.

In addition, to shorten the compilation time, Python source code tarball allows you add the option -j <#jobs> when calling command make.

However, due to how the task calling command pyenv install... is designed here, even though I can pass configure options via variable pyenv_python_configure_opts, I can't do so for GCC flags or make opts.

I would suggest to enhance the task above similar to:

- name: "Install Python interpreters {{ pyenv_python_versions }}"
  ansible.builtin.shell: ". {{ pyenvrc_path }}/.pyenvrc && pyenv install {{ item }}"
  environment:
    PYTHON_CONFIGURE_OPTS: "{{ pyenv_python_configure_opts }}"
    PYTHON_CFLAGS: "{{ pyenv_python_cflags }}"
    MAKE_OPTS: "{{ pyenv_make_opts }}"
    PROFILE_TASK: "{{ pyenv_profile_task | default('-m test --pgo -j0') }}"
  args:
    creates: "{{ pyenv_path }}/versions/{{ item }}/bin/python"
  with_items: "{{ pyenv_python_versions }}"

Indeed you can even think into extent that task to support the full range of environment variables provided by pyenv plugin python-build at Special environment variables (e.g. this way I can even have control over the GCC compiler I want to use via env variable CC).

Thanks
Jose M. Prieto

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions