Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,28 @@ Here is the list of all variables and their default values:
- `pyenv_update_git_install: true` (get latest pyenv from git)
- `pyenv_enable_autocompletion: false`
- `pyenv_enable_virtualenvs: true`
- `pyenv_shellrc_file "{% if pyenv_env == 'user' %}~/.bashrc{% else %}/etc/profile.d/pyenv.sh{% endif %}"`
- `pyenv_shellrc_file: "{% if pyenv_env == 'user' %}~/.bashrc{% else %}/etc/profile.d/pyenv.sh{% endif %}"`
- `pyenv_tmpdir: (must be explicitly defined)` - env variable `TMPDIR` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_build_build_path: (must be explicitly defined)` - env variable `PYTHON_BUILD_BUILD_PATH` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_build_cache_path: (must be explicitly defined)` - env variable `PYTHON_BUILD_CACHE_PATH` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_build_mirror_url: (must be explicitly defined)` - env variable `PYTHON_BUILD_MIRROR_URL` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_build_mirror_url_skip_checksum: (must be explicitly defined)` - env variable `PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_build_skip_mirror: (must be explicitly defined)` - env variable `PYTHON_BUILD_SKIP_MIRROR` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_build_skip_homebrew: (must be explicitly defined)` - env variable `PYTHON_BUILD_SKIP_HOMEBREW` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_build_root: (must be explicitly defined)` - env variable `PYTHON_BUILD_ROOT` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_build_definitions: (must be explicitly defined)` - env variable `PYTHON_BUILD_DEFINITIONS` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_configure_opts: (must be explicitly defined)` - env variable `PYTHON_CONFIGURE_OPTS` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_cflags: (must be explicitly defined)` - env variable `PYTHON_CFLAGS` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_make_opts: (must be explicitly defined)` - env variable `PYTHON_MAKE_OPTS` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_python_make_install_opts: (must be explicitly defined)` - env variable `PYTHON_MAKE_INSTALL_OPTS` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_configure_opts: (must be explicitly defined)` - env variable `CONFIGURE_OPTS` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_cc: (must be explicitly defined)` - env variable `CC` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_make: (must be explicitly defined)` - env variable `MAKE` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_make_opts: (must be explicitly defined)` - env variable `MAKE_OPTS` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_make_install_opts: (must be explicitly defined)` - env variable `MAKE_INSTALL_OPTS` used by [python-build][python-build] as described in [Special Environment Variables][special-env-vars].
- `pyenv_profile_task: (must be explicitly defined)` - env variable `PROFILE_TASK` to customize the task used for profile guided optimization as described in [building Python for maximum performance][max-performance]. See also [here](https://docs.python.org/3/using/configure.html#cmdoption-enable-optimizations).
- `pyenv_custom_pyenvrc_file: (must be explicitly defined)` - path to a custom `.pyenvrc` shell file that will be sourced from `{{ pyenvrc_path }}/.pyenvrc`. It allows you to freely customize the environment to be used during `pyenv` execution. If defined, this file will be copied as `{{ pyenvrc_path }}/.pyenvrc.custom`.
- `pyenv_install_extra_opts: ("" -no extra options added-)` - check output of `pyenv install --help` for available additional options.

## Dependencies

Expand Down Expand Up @@ -66,6 +87,10 @@ None.
py_version: 3.11.4
- venv_name: latest_v310
py_version: 3.10.12
pyenv_make_opts: "-j4"
pyenv_python_configure_opts: "--enable-optimizations --with-lto --with-ensurepip=upgrade"
pyenv_python_cflags: "-march=native -mtune=native"
pyenv_profile_task: "-m test.regrtest --pgo -j0"
```

## License
Expand All @@ -81,3 +106,6 @@ _Ansible role Pyenv_ is free and open source software.
[mit]: https://opensource.org/licenses/MIT
[pyenv]: https://github.com/yyuu/pyenv
[staticdev]: https://github.com/staticdev
[python-build]: https://github.com/pyenv/pyenv/tree/master/plugins/python-build "python-build plugin"
[special-env-vars]: https://github.com/pyenv/pyenv/blob/master/plugins/python-build/README.md#special-environment-variables "Special environment variables"
[max-performance]: https://github.com/pyenv/pyenv/blob/master/plugins/python-build/README.md#building-for-maximum-performance "Building for maximum performance"
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pyenv_init_options: "{% if pyenv_env != 'user' %}--no-rehash{% endif %}"
pyenv_update: false

# additional options for the build process, e.g "--enable-shared"
pyenv_install_extra_opts: ""
pyenv_python_configure_opts: ""
pyenv_uninstall_python_w_wrong_configure_opts: false

Expand Down
12 changes: 9 additions & 3 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
owner: "{{ pyenv_owner }}"
mode: "0644"

- name: Install custom .pyenvrc
ansible.builtin.copy:
src: "{{ pyenv_custom_pyenvrc_file }}"
dest: "{{ pyenvrc_path }}/.pyenvrc.custom"
owner: "{{ pyenv_owner }}"
mode: "0644"
when: pyenv_custom_pyenvrc_file is defined

- name: Use legacy variable pyenv_setting_path if available
ansible.builtin.set_fact:
pyenv_shellrc_file: "{{ pyenv_setting_path }}"
Expand Down Expand Up @@ -71,9 +79,7 @@
when: pyenv_uninstall_python_w_wrong_configure_opts

- name: "Install Python interpreters {{ pyenv_python_versions }}"
ansible.builtin.shell: ". {{ pyenvrc_path }}/.pyenvrc && pyenv install {{ item }}"
environment:
PYTHON_CONFIGURE_OPTS: "{{ pyenv_python_configure_opts }}"
ansible.builtin.shell: ". {{ pyenvrc_path }}/.pyenvrc && pyenv install {{ pyenv_install_extra_opts }} {{ item }}"
args:
creates: "{{ pyenv_path }}/versions/{{ item }}/bin/python"
with_items: "{{ pyenv_python_versions }}"
Expand Down
60 changes: 59 additions & 1 deletion templates/.pyenvrc.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,63 @@
# -------------------------------------
export PYENV_ROOT="{{ pyenv_path }}"
export PATH="$PYENV_ROOT/bin:$PATH"
{% if pyenv_tmpdir is defined %}
export TMPDIR="{{ pyenv_tmpdir }}"
{% endif %}
{% if pyenv_python_build_build_path is defined %}
export PYTHON_BUILD_BUILD_PATH="{{ pyenv_python_build_build_path }}"
{% endif %}
{% if pyenv_python_build_cache_path is defined %}
export PYTHON_BUILD_CACHE_PATH="{{ pyenv_python_build_cache_path }}"
{% endif %}
{% if pyenv_python_build_mirror_url is defined %}
export PYTHON_BUILD_MIRROR_URL="{{ pyenv_python_build_mirror_url }}"
{% endif %}
{% if pyenv_python_build_mirror_url_skip_checksum is defined %}
export PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM="{{ pyenv_python_build_mirror_url_skip_checksum }}"
{% endif %}
{% if pyenv_python_build_skip_mirror is defined %}
export PYTHON_BUILD_SKIP_MIRROR="{{ pyenv_python_build_skip_mirror }}"
{% endif %}
{% if pyenv_python_build_skip_homebrew is defined %}
export PYTHON_BUILD_SKIP_HOMEBREW="{{ pyenv_python_build_skip_homebrew }}"
{% endif %}
{% if pyenv_python_build_root is defined %}
export PYTHON_BUILD_ROOT="{{ pyenv_python_build_root }}"
{% endif %}
{% if pyenv_python_build_definitions is defined %}
export PYTHON_BUILD_DEFINITIONS="{{ pyenv_python_build_definitions }}"
{% endif %}
{% if pyenv_python_configure_opts is defined %}
export PYTHON_CONFIGURE_OPTS="{{ pyenv_python_configure_opts }}"
{% endif %}
{% if pyenv_python_cflags is defined %}
export PYTHON_CFLAGS="{{ pyenv_python_cflags }}"
{% endif %}
{% if pyenv_python_make_opts is defined %}
export PYTHON_MAKE_OPTS="{{ pyenv_python_make_opts }}"
{% endif %}
{% if pyenv_python_make_install_opts is defined %}
export PYTHON_MAKE_INSTALL_OPTS="{{ pyenv_python_make_install_opts }}"
{% endif %}
{% if pyenv_configure_opts is defined %}
export CONFIGURE_OPTS="{{ pyenv_configure_opts }}"
{% endif %}
{% if pyenv_cc is defined %}
export CC="{{ pyenv_cc }}"
{% endif %}
{% if pyenv_make is defined %}
export MAKE="{{ pyenv_make }}"
{% endif %}
{% if pyenv_make_opts is defined %}
export MAKE_OPTS="{{ pyenv_make_opts }}"
{% endif %}
{% if pyenv_make_install_opts is defined %}
export MAKE_INSTALL_OPTS="{{ pyenv_make_install_opts }}"
{% endif %}
{% if pyenv_profile_task is defined %}
export PROFILE_TASK="{{ pyenv_profile_task }}"
{% endif %}
[ -f "{{ pyenvrc_path }}/.pyenvrc.custom" ] && source "{{ pyenvrc_path }}/.pyenvrc.custom"
eval "$(pyenv init --path)"
eval "$(pyenv init - {{ pyenv_init_options}})"
eval "$(pyenv init - {{ pyenv_init_options }})"