Experimental. This may change, see https://github.com/roaldarbol/rpix/issues/108.
Add Python to the project's environment, and point reticulate at it, so
Python and its packages are in the same environment and pixi.lock as R
and its packages.
It adds
python(atpython_version, if given),r-reticulate, and for Python 3.15 or laterlibpython: conda-forge has Python's shared library, which reticulate loads, apart from Python since 3.15.It sets
RETICULATE_PYTHONto the environment's Python, inpixi.toml's[activation.env], so R started withpixi runuses it, and so does R started by an IDE, through the project's.Rprofile(pixi_activate()). Without it, reticulate uses a Python of its own.It adds
micromamba, and pointsRETICULATE_CONDAto it: reticulate activates a conda environment again with a conda program before it uses its Python, and a Pixi project doesn't have one (https://github.com/rstudio/reticulate/issues/1650).
Add Python packages with pixi_add(): pixi_add("conda::numpy") from
conda-forge, or pixi_add("pypi::pydytuesday") from PyPI. reticulate's
py_require() doesn't install into the project's Python.
Restart R afterwards, so reticulate finds the environment's Python. The
Windows settings are written only if the project has win-64: if you add
it later, run use_pixi_python() again.