Skip to content

Fix reticulate conda env discovery for HPC-style conda activation #13

Fix reticulate conda env discovery for HPC-style conda activation

Fix reticulate conda env discovery for HPC-style conda activation #13

Workflow file for this run

name: R-CMD-check
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch: {}
permissions:
contents: read
jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (R ${{ matrix.config.r }})
strategy:
fail-fast: false
matrix:
config:
- { os: windows-latest, r: "release" }
- { os: macos-latest, r: "release" }
- { os: ubuntu-latest, r: "release" }
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
use-public-rspm: true
- uses: actions/setup-python@v5
with:
python-version: "3.11"
# CarbonTracker wraps codecarbon.OfflineEmissionsTracker via reticulate.
# Real users get codecarbon via setup_carbon_tracker() into a conda env
# named "r-codecarbon" (which R/zzz.R's .onLoad looks for), but that
# function refuses to run non-interactively by design, so CI can't call
# it directly. Instead: install codecarbon into the actions/setup-python
# interpreter with pip, then point reticulate at it with
# RETICULATE_PYTHON. carbon_tracker_ready()/ensure_codecarbon_available()
# only check that codecarbon is importable -- they don't care which env
# reticulate resolved to -- so this exercises the same import path real
# users hit, just via a faster/more CI-reliable route than a full conda
# bootstrap on every OS in the matrix.
#
# setuptools>=81 dropped pkg_resources, which codecarbon 2.2.2 still
# imports at module load time (ModuleNotFoundError: No module named
# 'pkg_resources'). Hit this for real setting up local dev -- pin below
# 81 until codecarbon drops the pkg_resources dependency upstream.
- name: Install codecarbon for reticulate to find
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install "setuptools<81" codecarbon
echo "RETICULATE_PYTHON=$(python -c 'import sys; print(sys.executable)')" >> "$GITHUB_ENV"
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual")'