Skip to content

Conversation

Copy link

Copilot AI commented Oct 18, 2025

Problem

The CI jobs were failing because pip, tox, and pytest commands were being invoked directly, causing them to run under the system Python (3.9.13) instead of the Python version installed by actions/setup-python (3.11/3.12).

Solution

Updated all GitHub Actions workflow files to invoke pip, tox, and pytest through the Python module syntax (python -m), which ensures these tools use the same interpreter that actions/setup-python configures.

Changes

Modified 4 workflow files to consistently use:

  • python -m pip instead of pip
  • python -m tox instead of tox
  • python -m pytest instead of pytest

Files Changed:

  • .github/workflows/python-ci.yml - Updated pip, tox, and pytest invocations in Code_Testing and Package_Testing jobs
  • .github/workflows/python-package.yml - Updated pip and pytest invocations in build job
  • .github/workflows/documentation-build.yml - Updated pip invocations in documentation build job
  • .github/workflows/python-publish.yml - Updated pip invocations in deploy job

This change follows Python packaging best practices and ensures reliable CI execution across all supported Python versions (3.11 and 3.12).

Original prompt

The CI job is failing because pip is running under the system Python (3.9.13) instead of the Python installed by actions/setup-python (3.11/3.12). Change the workflow to ensure all pip/tox/pytest invocations use the same interpreter that actions/setup-python selects by invoking them via python -m . Also add a short debug step to verify the interpreter and pip being used.

Files to change:

  • .github/workflows/python-ci.yml

Required changes to .github/workflows/python-ci.yml:

  1. After each actions/setup-python@v5 step, add a debug step that prints python --version, which python, python -c "import sys; print(sys.executable)", python -m pip --version, pip --version (non-fatal), and PATH.

  2. Replace every bare pip install invocation with python -m pip install to ensure pip runs under the selected interpreter. Specifically replace:

    • pip install -e '.[dev]'
    • pip install tox tox-gh-actions coverage
      with
    • python -m pip install -e '.[dev]'
    • python -m pip install tox tox-gh-actions coverage
  3. Run tox and pytest via the selected interpreter:

    • Replace tox with python -m tox
    • Replace pytest ../ with python -m pytest ../
  4. Keep the existing python -m build as-is.

Provide the full updated .github/workflows/python-ci.yml content below (this will be committed in a PR):

--- Updated .github/workflows/python-ci.yml ---

This workflow will for a variety of Python versions

- install the code base

- lint the code base

- test the code base

- upload the test coverage to codecov

It will also

- build the package

- check the package

For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: CI using pip

on: [push, pull_request]

jobs:
Code_Consistency:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
- name: Suggestion to fix issues
if: ${{ failure() }}
run: |
echo "::notice::In project root run 'python.exe -m ruff . --fix' and commit changes to fix issues."
exit 1

Code_Testing:
strategy:
max-parallel: 4
matrix:
python-version: ['3.11', '3.12']
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, '[ci skip]')"

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
  with:
    python-version: ${{ matrix.python-version }}

- name: Check Python and pip
  run: |
    python --version
    which python || where python
    python -c "import sys; print(sys.executable)"
    python -m pip --version
    pip --version || true
    echo "PATH=$PATH"

- name: Upgrade pip
  run: |
    python -m pip install --upgrade pip

- name: Install dependencies
  run: python -m pip install -e '.[dev]'

- name: Test with tox
  run: |
    python -m pip install tox tox-gh-actions coverage
    python -m tox

- name: Upload coverage
  uses: codecov/codecov-action@v3
  with:
    name: Pytest coverage
    env_vars: OS,PYTHON,GITHUB_ACTIONS,GITHUB_ACTION,GITHUB_REF,GITHUB_REPOSITORY,GITHUB_HEAD_REF,GITHUB_RUN_ID,GITHUB_SHA,COVERAGE_FILE
  env:
    OS: ${{ matrix.os }}
    PYTHON: ${{ matrix.python-version }}

Package_Testing:

runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
  with:
    python-version: 3.11

- name: Check Python and pip
  run: |
    python --version
    which python || where python
    python -c "import sys; print(sys.executable)"
    python -m pip --version
    pip --version || true
    echo "PATH=$PATH"

- name: Install dependencies and build
  run: |
    python -m pip install -e '.[dev]'
    python -m build

- name: Check Build
  run: |
    cd ./dist
    python -m pytest ../

--- End updated file ---

Please create a pull request that applies this change to the repository 'easyscience/EasyReflectometryLib'.

This pull request was created as a result of the following prompt from Copilot chat.

The CI job is failing because pip is running under the system Python (3.9.13) instead of the Python installed by actions/setup-python (3.11/3.12). Change the workflow to ensure all pip/tox/pytest invocations use the same interpreter that actions/setup-python selects by invoking them via python -m . Also add a short debug step to verify the interpreter and pip being used.

Files to change:

  • .github/workflows/python-ci.yml

Required changes to .github/workflows/python-ci.yml:

  1. After each actions/setup-python@v5 step, add a debug step that prints python --version, which python, python -c "import sys; print(sys.executable)", python -m pip --version, pip --version (non-fatal), and PATH.

  2. Replace every bare pip install invocation with python -m pip install to ensure pip runs under the selected interpreter. Specifically replace:

    • pip install -e '.[dev]'
    • pip install tox tox-gh-actions coverage
      with
    • python -m pip install -e '.[dev]'
    • python -m pip install tox tox-gh-actions coverage
  3. Run tox and pytest via the selected interpreter:

    • Replace tox with python -m tox
    • Replace pytest ../ with python -m pytest ../
  4. Keep the existing python -m build as-is.

Provide the full updated .github/workflows/python-ci.yml content below (this will be committed in a PR):

--- Updated .github/workflows/python-ci.yml ---

This workflow will for a variety of Python versions

- install the code base

- lint the code base

- test the code base

- upload the test coverage to codecov

It will also

- build the package

- check the package

For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: CI using pip

on: [push, pull_request]

jobs:
Code_Consistency:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
- name: Suggestion to fix issues
if: ${{ failure() }}
run: |
echo "::notice::In project root run 'python.exe -m ruff . --fix' and commit changes to fix issues."
exit 1

Code_Testing:
strategy:
max-parallel: 4
matrix:
python-version: ['3.11', '3.12']
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, '[ci skip]')"

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
  with:
    python-version: ${{ matrix.python-version }}

- name: Check Python and pip
  run: |
    python --version
    which python || where python
    python -c "import sys; print(sys.executable)"
    python -m pip --version
    pip --version || true
    echo "PATH=$PATH"

- name: Upgrade pip
  run: |
    python -m pip install --upgrade pip

- name: Install dependencies
  run: python -m pip install -e '.[dev]'

- name: Test with tox
  run: |
    python -m pip install tox tox-gh-actions coverage
    python -m tox

- name: Upload coverage
  uses: codecov/codecov-action@v3
  with:
    name: Pytest coverage
    env_vars: OS,PYTHON,GITHUB_ACTIONS,GITHUB_ACTION,GITHUB_REF,GITHUB_REPOSITORY,GITHUB_HEAD_REF,GITHUB_RUN_ID,GITHUB_SHA,COVERAGE_FILE
  env:
    OS: ${{ matrix.os }}
    PYTHON: ${{ matrix.python-version }}

Package_Testing:

runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
  with:
    python-version: 3.11

- name: Check Python and pip
  run: |
    python --version
    which python || where python
    python -c "import sys; print(sys.executable)"
    python -m pip --version
    pip --version || true
    echo "PATH=$PATH"

- name: Install dependencies and build
  run: |
    python -m pip install -e '.[dev]'
    python -m build

- name: Check Build
  run: |
    cd ./dist
    python -m pytest ../

--- End updated file ---

Please create a pull request that applies this change to the repository 'easyscience/EasyReflectometryLib'.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@rozyczko rozyczko changed the base branch from master to develop October 18, 2025 10:05
…t invocations

Co-authored-by: rozyczko <8266281+rozyczko@users.noreply.github.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request does not contain a valid label. Please add one of the following labels: ['chore', 'fix', 'bugfix', 'bug', 'enhancement', 'feature', 'dependencies', 'documentation']

Copilot AI changed the title [WIP] Fix CI to use actions/setup-python interpreter for pip Fix CI Python interpreter issue - use python -m for all pip/tox/pytest invocations Oct 18, 2025
Copilot AI requested a review from rozyczko October 18, 2025 10:08
@rozyczko rozyczko marked this pull request as ready for review October 18, 2025 10:09
@codecov
Copy link

codecov bot commented Oct 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.89%. Comparing base (91dd99b) to head (398e58a).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #275      +/-   ##
===========================================
+ Coverage    89.61%   96.89%   +7.28%     
===========================================
  Files           44       77      +33     
  Lines         2349     6700    +4351     
  Branches       271        0     -271     
===========================================
+ Hits          2105     6492    +4387     
- Misses         195      208      +13     
+ Partials        49        0      -49     
Flag Coverage Δ
unittests 96.89% <ø> (+7.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 55 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rozyczko rozyczko changed the base branch from develop to pixi October 18, 2025 12:32
@rozyczko rozyczko merged commit b3b22f7 into pixi Oct 18, 2025
7 of 27 checks passed
@rozyczko rozyczko deleted the copilot/fix-ci-python-interpreter branch October 18, 2025 12:43
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