Skip to content

Read Python version from .python-version in Dockerfile and Ansible#2540

Merged
fbacall merged 1 commit intopython-versionfrom
copilot/use-python-version-from-file
Apr 15, 2026
Merged

Read Python version from .python-version in Dockerfile and Ansible#2540
fbacall merged 1 commit intopython-versionfrom
copilot/use-python-version-from-file

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

Replaces hardcoded python3.13 throughout the Dockerfile and Ansible playbook with dynamic reads from the canonical .python-version file, consistent with how .ruby-version is already consumed.

Dockerfile

  • COPY .python-version .python-version added to base stage after WORKDIR, making the file available to all subsequent stages
  • Each RUN that references Python reads the version inline: PYTHON_VERSION=$(cat .python-version)
COPY .python-version .python-version

RUN PYTHON_VERSION=$(cat .python-version) && \
    apt-get install ... python${PYTHON_VERSION} ...

RUN PYTHON_VERSION=$(cat .python-version) && \
    python${PYTHON_VERSION} -m ensurepip --upgrade --default-pip && \
    python${PYTHON_VERSION} -m pip install -r requirements.txt

Note: the variable is re-read per RUN step — this is unavoidable since shell variables don't persist across Docker layers.

Ansible (Deploy-SEEK.yml)

  • Two tasks prepend the Python section to slurp .python-version and register it as a fact, mirroring the existing .ruby-version pattern
  • All python3.13 references in package names and shell commands replaced with python{{ python_version }}
- name: Read python version from .python-version file
  ansible.builtin.slurp:
    src: '{{git_dest}}/SEEK/.python-version'
  register: python_version_file

- name: Set python version fact
  ansible.builtin.set_fact:
    python_version: "{{ python_version_file.content | b64decode | trim }}"

@fbacall fbacall marked this pull request as ready for review April 15, 2026 13:06
@fbacall fbacall merged commit 678ef33 into python-version Apr 15, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants