FIX: undesired python version used for reticulate when working with radian#508
FIX: undesired python version used for reticulate when working with radian#508code-instable wants to merge 3 commits intoropensci:mainfrom
Conversation
(+) function: set_radian_python_version_override
(~) generate_wrapped_pkgs
(+) added `py_conf` and `flag_py_conf` as arguments
(+) added string format '%s' bellow the packages
TODO: remove whitespaces and empty line when there is no py_conf
|
The PR is still in draft, is that because you want to continue to work on it, or did you forget to set it to ready? In any case, could you fix the unit tests please? |
|
The PR is still in draft because I want to know whether things have to change, and if it is a good approach as well I am not good with unit test, so I don't really know what to change, I will take a look at it Also I don't know how to trim the added white spaces when there is no pyconf, helping me on this would be much appreciated |
|
Ok let’s forget the unit tests then: the overall approach seems good. Put the PR in ready for review, and I will thouroughly test it. If it’s fine, I’ll merge and fix the tests and the whitespace issue myself. |
|
the radian package has been promoted to a top package 3 days ago. I may have to try if this resolved by itself the issue, which means the code provided is now breaking when it comes to the unstable branch |
|
Have you had a chance to check whether this is still an issue? |
|
There is still the need to change something, I will do it later, as radian moved from a python package to a regular package Which also breaks compatibility with different releases of nixpkgs (Should it be taken into account ?) |
problem
When using Radian IDE, which default used python version may differ from the selected one, reticulate will force the use of the python version used for radian instead of the one provided by
RETICULATE_PYTHON. The proposed solution is to fetch the radian matching the desired python version for reticulate.the rix configuration (minimal)
here is an almost minimal setup to reproduce the error:
rix( date = "2025-04-11", r_pkgs = c("reticulate"), git_pkgs = list(list(package_name = "somebm", repo_url = "https://github.com/cran/somebm", commit = "03584b24dee8081f08a0cde456edcc8419aba494")), py_conf = list( py_version = "3.13", py_pkgs = c("numpy") ), ide = "radian", project_path = ".", overwrite = FALSE, print = TRUE, message_type = "simple" )the following code is then executed inside the nix environment
collision between radian's python version and reticulate's python version
When entering
nix-shellwhile usingradianIDE,reticulateautomatically falls back to the python version used byradian, as we can see in the following example:(note that
RETICULATE_PYTHONswitches from the correct desired version to radian's one on loading thereticulatepackage)only when using radian
However, it still works perfectly fine when using
Rscript:proposed solution
The proposed solution is to match radian's python version with the python version from the user-defined config within the override of
radianWrapper:the code produces the following
default.nix:running the
nix-shellnow produces the desired result as "forced by the current process":(notice that the
RETICULATE_PYTHONdoes not change here)if no
py_confis provided, then we do not add the python version override:note that I don't know how to properly remove the added newline when there is no
py_confwithout using a if/else statement, so any suggestion is much appreciatedsuggested edits
(+) function: set_radian_python_version_override
(~) generate_wrapped_pkgs
py_confandflag_py_confas argumentsTODO: remove whitespaces and empty line when there is no py_conf
(I don't know how to do)
potential edge case
the desired python version is much older than the one used for radian