Skip to content

Commit

Permalink
Merge pull request #1273 from Xarthisius/issue_1272
Browse files Browse the repository at this point in the history
Update the location of R packagemanager
  • Loading branch information
manics authored May 24, 2023
2 parents d3c7441 + 7bf02d8 commit 7112d17
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/source/howto/languages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ by adding a :ref:`install.R<install.R>` file to your repo. RStudio and IRKernel
installed by default for all R versions.

If you request R 4.1 or later, or specify a snapshot date newer than
``2022-01-01``, `packagemanager.rstudio.com <https://packagemanager.rstudio.com/client/#/>`_
``2022-01-01``, `packagemanager.posit.co <https://packagemanager.posit.co/client/#/>`_
will be used to provide much faster installations via `binary packages <https://www.rstudio.com/blog/package-manager-v1-1-no-interruptions/>`_.
For *some* packages, this might require you install underlying system libraries
using :ref:`apt.txt` - look at the page for the CRAN package you are interested in at
`packagemanager.rstudio.com <https://packagemanager.rstudio.com/client/#/>`_ to find
`packagemanager.posit.co <https://packagemanager.posit.co/client/#/>`_ to find
a list.

For older R versions with an older snapshot date, `MRAN <https://mran.microsoft.com/>`_
Expand Down
18 changes: 9 additions & 9 deletions repo2docker/buildpacks/r.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class RBuildPack(PythonBuildPack):
Where 'year', 'month' and 'date' refer to a specific
date whose CRAN snapshot we will use to fetch packages.
Uses https://packagemanager.rstudio.com, or MRAN if no snapshot
is found on packagemanager.rstudio.com
Uses https://packagemanager.posit.co, or MRAN if no snapshot
is found on packagemanager.posit.co
2. A `DESCRIPTION` file signaling an R package
Expand Down Expand Up @@ -204,7 +204,7 @@ def get_packages(self):
def get_rspm_snapshot_url(self, snapshot_date, max_days_prior=7):
for i in range(max_days_prior):
snapshots = requests.post(
"https://packagemanager.rstudio.com/__api__/url",
"https://packagemanager.posit.co/__api__/url",
# Ask for midnight UTC snapshot
json={
"repo": "all",
Expand All @@ -216,11 +216,11 @@ def get_rspm_snapshot_url(self, snapshot_date, max_days_prior=7):
# Construct a snapshot URL that will give us binary packages for Ubuntu Bionic (18.04)
if "upsi" in snapshots:
return (
"https://packagemanager.rstudio.com/all/__linux__/bionic/"
"https://packagemanager.posit.co/all/__linux__/bionic/"
+ snapshots["upsi"]
)
raise ValueError(
"No snapshot found for {} or {} days prior in packagemanager.rstudio.com".format(
"No snapshot found for {} or {} days prior in packagemanager.posit.co".format(
snapshot_date.strftime("%Y-%m-%d"), max_days_prior
)
)
Expand All @@ -229,7 +229,7 @@ def get_rspm_snapshot_url(self, snapshot_date, max_days_prior=7):
def get_mran_snapshot_url(self, snapshot_date, max_days_prior=7):
for i in range(max_days_prior):
try_date = snapshot_date - datetime.timedelta(days=i)
# Fall back to MRAN if packagemanager.rstudio.com doesn't have it
# Fall back to MRAN if packagemanager.posit.co doesn't have it
url = f"https://mran.microsoft.com/snapshot/{try_date.isoformat()}"
r = requests.head(url)
if r.ok:
Expand Down Expand Up @@ -258,11 +258,11 @@ def get_devtools_snapshot_url(self):
devtools is part of our 'core' base install, so we should have some
control over what version we install here.
"""
# Picked from https://packagemanager.rstudio.com/client/#/repos/1/overview
# Picked from https://packagemanager.posit.co/client/#/repos/1/overview
# Hardcoded rather than dynamically determined from a date to avoid extra API calls
# Plus, we can always use packagemanager.rstudio.com here as we always install the
# Plus, we can always use packagemanager.posit.co here as we always install the
# necessary apt packages.
return "https://packagemanager.rstudio.com/all/__linux__/bionic/2022-01-04+Y3JhbiwyOjQ1MjYyMTU7NzlBRkJEMzg"
return "https://packagemanager.posit.co/all/__linux__/bionic/2022-01-04+Y3JhbiwyOjQ1MjYyMTU7NzlBRkJEMzg"

@lru_cache()
def get_build_scripts(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/r/r4.0-rspm/verify
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ if (!(version$major == "4" && as.double(version$minor) >= 0 && as.double(version
}

# The date we have chosen should give us an rspm mirror
if (!(startsWith(options()$repos["CRAN"], "https://packagemanager.rstudio.com"))) {
if (!(startsWith(options()$repos["CRAN"], "https://packagemanager.posit.co"))) {
quit("yes", 1)
}
}
6 changes: 3 additions & 3 deletions tests/unit/test_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_version_completion(tmpdir):
tmpdir.chdir()

with open("runtime.txt", "w") as f:
f.write(f"r-3.6-2019-01-01")
f.write("r-3.6-2019-01-01")

r = buildpacks.RBuildPack()
assert r.r_version == "3.6.3"
Expand All @@ -52,7 +52,7 @@ def test_mran_date(tmpdir, runtime, expected):

def test_snapshot_rspm_date():
test_dates = {
# Even though there is no snapshot specified in the interface at https://packagemanager.rstudio.com/client/#/repos/1/overview
# Even though there is no snapshot specified in the interface at https://packagemanager.posit.co/client/#/repos/1/overview
# For 2021 Oct 22, the API still returns a valid URL that one can install
# packages from - probably some server side magic that repeats our client side logic.
# No snapshot for this date from
Expand All @@ -65,7 +65,7 @@ def test_snapshot_rspm_date():
for requested, expected in test_dates.items():
snapshot_url = r.get_rspm_snapshot_url(requested)
assert snapshot_url.startswith(
"https://packagemanager.rstudio.com/all/__linux__/bionic/"
"https://packagemanager.posit.co/all/__linux__/bionic/"
+ expected.strftime("%Y-%m-%d")
)

Expand Down

0 comments on commit 7112d17

Please sign in to comment.