Skip to content

Pin managed Python to a known-good version (default 3.12) - #10

Merged
jefferis merged 3 commits into
mainfrom
default-python-version
Sep 12, 2026
Merged

jefferis merged 3 commits into
mainfrom
default-python-version

Conversation

@jefferis

Copy link
Copy Markdown
Member

Why

A user recently got a fresh miniconda install on Python 3.14.7 (reticulate's uv-based auto-init grabs the newest CPython when nothing constrains it), then had to tear it all down and redo at 3.12 because key packages had no 3.14 wheels yet.

simple_python() uses the managed miniconda path, which already defaults to 3.12 in reticulate 1.46 — but that default was implicit and unpinned. This makes it explicit and controllable.

What

  • New python_version argument on simple_python(). Resolution precedence: explicit arg → options(nat.python.python_version) → a pre-set RETICULATE_MINICONDA_PYTHON_VERSION → built-in default "3.12". NA/"" means "don't pin, defer to reticulate".
  • resolve_python_version() encodes that precedence; simple_python_base() sets RETICULATE_MINICONDA_PYTHON_VERSION only for the duration of provisioning (restored via on.exit) and passes python_version to conda_create().
  • An existing env at a different version is kept, not silently rebuilt, with a warning pointing at simple_python("cleanenv").
  • CI: the provision step passes python_version= per matrix leg and asserts the provisioned interpreter matches the request; the shipped-default leg (renamed py-shipped-default) exercises the 3.12 pin.

Tests

New resolve_python_version tests cover the precedence chain and the NA/empty/bad-length cases. Full suite: 0 fail / 0 warn / 0 skip. Roxygen regenerated clean.

🤖 Generated with Claude Code

jefferis and others added 3 commits September 12, 2026 09:38
simple_python() now pins the managed miniconda environment's interpreter
rather than letting reticulate pick, which on a fresh install can be a
bleeding-edge Python (e.g. 3.14) that key packages have no wheels for yet.

- New python_version arg (NULL -> options(nat.python.python_version) ->
  pre-set RETICULATE_MINICONDA_PYTHON_VERSION -> "3.12"; NA to defer).
- resolve_python_version() encodes the precedence; set the env var only
  for the duration of provisioning (restored on exit) and pass it to
  conda_create().
- An existing env at another version is kept, not silently rebuilt, with
  a warning pointing at simple_python("cleanenv").
- CI provision step passes python_version= per matrix leg and asserts the
  provisioned interpreter matches; first leg renamed py-shipped-default.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A bare `else` on its own line parses as an error at Rscript top level
(the `if` statement is already complete on the preceding line). Use the
braced form.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
py_discover_config()$version can be a numeric_version; nzchar() tolerates
it but startsWith() errors on a non-character. Coerce to character and
guard length/NA/empty before the comparison.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 27.77778% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.27%. Comparing base (82f27a4) to head (70105de).

Files with missing lines Patch % Lines
R/env.R 27.77% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #10      +/-   ##
==========================================
- Coverage   66.66%   64.27%   -2.40%     
==========================================
  Files           6        6              
  Lines         495      529      +34     
==========================================
+ Hits          330      340      +10     
- Misses        165      189      +24     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@jefferis
jefferis merged commit 7aa8fba into main Sep 12, 2026
6 checks passed
@jefferis
jefferis deleted the default-python-version branch September 12, 2026 13:58
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.

1 participant