posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.86k stars 91 forks source link

Look for Python envs maintained by renv during automatic runtime discovery #2937

Open juliasilge opened 7 months ago

juliasilge commented 7 months ago

Surfaced in our private beta here: https://github.com/posit-dev/positron-beta/discussions/153

The renv R package not only can manage R environments (version of R, R package versions) but also Python project dependencies: https://rstudio.github.io/renv/articles/python.html

We should look the the standard renv.lock file for a workspace to see if there is a Python env specified, and we should treat it approximately the same as a local venv.

juliasilge commented 7 months ago

The standard spot for a virtualenv is ./renv/python/virtualenvs/.

Here is what an renv.lock looks like (it's JSON in the root of the directory):

{
  "R": {
    "Version": "4.3.2",
    "Repositories": [
      {
        "Name": "CRAN",
        "URL": "https://packagemanager.posit.co/cran/latest"
      }
    ]
  },
  "Python": {
    "Version": "3.11.5",
    "Type": "virtualenv",
    "Name": "./renv/python/virtualenvs/renv-python-3.11"
  },
  "Packages": {
    "DBI": {
      "Package": "DBI",
      "Version": "1.2.2",
      "Source": "Repository",
      "Repository": "CRAN",
      "Requirements": [
        "R",
        "methods"
      ],
      "Hash": "164809cd72e1d5160b4cb3aa57f510fe"
    },
    "MASS": {
      "Package": "MASS",
      "Version": "7.3-60.0.1",
      "Source": "Repository",
      "Repository": "CRAN",
      "Requirements": [
        "R",
        "grDevices",
        "graphics",
        "methods",
        "stats",
        "utils"
      ],
      "Hash": "b765b28387acc8ec9e9c1530713cb19c"
    }
    "LOTS MORE R PACKAGES HERE!"
  }
}