Setting up Package Manager involves configuring sources and repositories. A source contains packages from a specific location, for example a public repository or local files. A repository then subscribes to one or more sources to expose the packages to clients.
If you have additional security challenges, we recommend viewing the Security and Compliance section on the left-hand side, including topics like Server Security, Auditing, and Package Blocking.
The right sidebar contains quick start guides for configuring various types of sources. Follow the ones that are best suited for your use case(s):
Once you have configured the server, share the URL to the web interface with your users. Users can set up R, Python, or RStudio Desktop to use Package Manager by following the instructions included in each repository's Setup page.
Tip
Posit Workbench can be configured to use Package Manager without requiring user setup. For more information, see the configuration instructions.
A common use case for Package Manager is making CRAN packages available in environments with restricted internet access.
To make the CRAN packages available:
Ensure that Package Manager has the appropriate metadata using the sync command. Package Manager pulls CRAN packages and metadata from the Posit Package Service.
Create a repository and subscribe it to the built-in source named cran.
Terminal
# Create a repository:$ rspmcreaterepo--name=cran--description='Access CRAN packages'# Subscribe the repository to the cran source:$ rspmsubscribe--repo=cran--source=cran
# Initiate a sync:$ rspmsync--type=cran
After running the sync command, future updates will automatically occur on a daily schedule by default. You do not need to manually run the sync command again after this. To learn more about how to customize the sync schedule, see the Synchronizing with the Posit Package Service section.
After completing these steps, the cran repository is available in the web interface.
If you prefer to make CRAN packages available for only specific dates, you can use a cran-snapshot source. For example:
Terminal
# Initiate a sync:$ rspmsync--type=cran
# List available snapshot dates (increase the count to see more options)$ rspmlistcransnapshots--count=25# Create source from desired date:$ rspmcreatesource--name=cran-by-date--type=cran-snapshot--snapshot=2020-07-09
# Create a repository:$ rspmcreaterepo--name=cran--description='Access CRAN packages by date'# Subscribe a repository to the cran-snapshot source:$ rspmsubscribe--repo=cran--source=cran-by-date
After completing these steps, the cran repository is available in the web interface.
To add an additional snapshot to the repository, use the update command:
Terminal
# Update source to add a new snapshot$ rspmupdate--source=cran-by-date--snapshot=2020-10-06--commit
If you prefer to make only a subset of CRAN packages available, you can use a curated-cran source. You can also specify which CRAN snapshot date to use.
Terminal
# Ensure you have CRAN metadata:$ rspmsync--type=cran
# Create the curated-cran source from a specific starting date:$ rspmcreatesource--name=subset--type=curated-cran--snapshot=2020-07-06
# Specify the top-level packages you want to add:$ rspmadd--packages=ggplot2,shiny--source=subset
Tip
To use the most recent snapshot available, omit the --snapshot flag.
The output will contain information on all the packages that will be added. The proposal can be saved to a CSV file using the csv-out flag. The required dependencies for the named packages are automatically discovered and included. Optionally, use the --include-suggests flag to also discover and add suggested packages.
Output
This action will add the following packages:
Name Version Path License Needs Compilation Dependency
BH 1.66.0-1 BSL-1.0 no true
crayon 1.3.4 MIT + file LICENSE no true
digest 0.6.15 GPL (>= 2) yes true
htmltools 0.3.6 GPL (>= 2) no true
httpuv 1.4.3 GPL (>= 2) | file LICENSE yes true
ISLR 1.2 GPL-2 no false
jsonlite 1.5 MIT + file LICENSE yes true
later 0.7.3 GPL (>= 2) yes true
... ... ... ... ...
To commit the changes, repeat the command, adding the --commit flag.
Terminal
# Commit the top-level packages you want to add:$ rspmadd--packages=ggplot2,shiny--source=subset--snapshot=2020-07-06--commit
Finally, be sure to subscribe a repository to the source to make the packages available to users:
Terminal
# Create a repository:$ rspmcreaterepo--name=cran--description='Access curated CRAN packages by date'# Subscribe a repository to the curated-cran source:$ rspmsubscribe--repo=cran--source=subset
To update the source to a later snapshot date, use the update command:
Note
In order to ensure consistency, the entire source is updated at once, not individual packages.
Terminal
# Update packages in a curated-cran source:$ rspmupdate--source=subset--snapshot=2020-10-07
A preview of the changes is presented:
Output
This action will add or archive the following packages:
Name Version Path License Needs Compilation Dependency Action
backports 1.1.10 GPL-2 | GPL-3 yes true add
callr 3.4.4 MIT + file LICENSE no true add
glue 1.4.2 MIT + file LICENSE yes true add
jsonlite 1.7.1 MIT + file LICENSE yes true add
Rcpp 1.0.5 GPL (>= 2) yes true add
rlang 0.4.7 GPL-3 yes true add
tibble 3.0.3 MIT + file LICENSE yes true add
vctrs 0.3.4 GPL-3 yes true add
withr 2.3.0 GPL (>= 2) no true add
backports 1.1.8 GPL-2 | GPL-3 yes archive
callr 3.4.3 MIT + file LICENSE no archive
glue 1.4.1 MIT + file LICENSE yes archive
jsonlite 1.7.0 MIT + file LICENSE yes archive
...
To commit the changes, repeat the command, adding the --commit flag:
Terminal
# Update packages in a curated-cran source:$ rspmupdate--source=subset--snapshot=2020-10-07--commit
Tip
Curated CRAN repositories also support adding a large number of packages that are specified in a file. To do this, create a file containing one package name per line. For example, /tmp/packages.csv:
/tmp/packages.csv
plumber
shiny
ISLR
Then use the add command, this time using the --file-in flag:
If you prefer to make only a subset of PyPI packages available, you can use a curated-pypi source. You can also specify which PyPI snapshot date to use:
Terminal
# Ensure you have PyPI metadata:$ rspmsync--type=pypi
# Create the curated-pypi source:$ rspmcreatesource--name=pypi-subset--type=curated-pypi
Now that the source has been created, it is time to include only the packages and versions you want from PyPI. Curated PyPI sources support uploading requirements.txt files to define what packages get included. As an example, let's look at a simple requirements.txt file definition:
requirements.txt
shiny
tensorflow >= 2.4.0
numpy == 1.24.2
This fetches and installs:
All available versions of shiny
All versions of tensorflow greater than or equal to 2.4.0
Only numpy version 1.24.2
With the requirements.txt file defined above, we can now add the packages to the source:
Terminal
# Do a dry-run to visualize the changes to the source before doing them$ rspmupdate--source=pypi-subset--file-in=/path/to/requirements.txt--snapshot=2023-03-24
A preview of the changes is presented:
Output
Packages from 'requirements.txt' to update source 'pypi-subset' at PyPI snapshot date '2023-03-24':
Name Version
numpy 1.24.2
shiny 0.1, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.6, 0.2.7, 0.2.8, 0.2.9, 0.2.10
tensorflow 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.6.0, 2.6.0rc0, 2.6.0rc1, 2.6.1, 2.6.0rc2, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.7.0, 2.7.0rc0, 2.7.0rc1, 2.7.1, 2.7.2, 2.7.3, 2.7.4, 2.8.0, 2.8.0rc0, 2.8.0rc1, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.9.0, 2.9.0rc0, 2.9.0rc1, 2.9.1, 2.9.0rc2, 2.9.2, 2.9.3, 2.10.0, 2.10.0rc0, 2.10.0rc1, 2.10.1, 2.10.0rc2, 2.10.0rc3, 2.11.0, 2.11.0rc0, 2.11.0rc1, 2.11.1, 2.11.0rc2, 2.12.0, 2.12.0rc0, 2.12.0rc1
If the output above looks correct, execute this command again with the --commit flag to update the source with the new set of packages.
To commit the changes, repeat the command, adding the --commit flag:
Terminal
# Now commit the changes to the source:$ rspmupdate--source=pypi-subset--file-in=/path/to/requirements.txt--snapshot=2023-03-24--commit
The finalized contents of the source are then printed:
Doing rspm update on a Curated PyPI source will overwrite the source with only the packages defined in your requirements.txt file. However, previous snapshots of the source are still available with a pinned repo URL.
Finally, be sure to subscribe a repository to the source to make the packages available to users:
Terminal
# Create a repository:$ rspmcreaterepo--name=pypi--type=python--description='Access curated PyPI packages'# Subscribe a repository to the curated-pypi source:$ rspmsubscribe--repo=pypi--source=pypi-subset
To update the source to a different snapshot date, use the update command again:
Terminal
# Update packages in a curated-pypi source:$ rspmupdate--source=pypi-subset--file-in=/path/to/requirements.txt--snapshot=2023-03-17--commit
Tip
This allows you to set the Curated PyPI source to any date where a PyPI snapshot has been taken on our servers. If you are trying to pin to a version of a package that doesn't exist on PyPI anymore, try pinning to a date when it existed.
For more information on Curated PyPI in Package Manager, see the Curated PyPI Sources section of the documentation.
Many teams have their own internally developed packages they want to make available. If your internal packages are tracked in Git, refer to the Building and serving R packages stored in Git section to build and publish them automatically.
If your internal packages are already built, they can be added to a Local source:
Create the bundled source version of each package:
Terminal
# Build the source package, package_1.0.tar.gz$ RCMDbuild/path/to/package
Copy the resulting .tar.gz file(s) to the Package Manager server and add them to a local source:
Terminal
# Create a local source:$ rspmcreatesource--name=internal-src--type=local# Add each local package tar file to the source:# The tar file must be rwx by the user running the CLI and the account running# Package Manager (rstudio-pm by default)$ rspmadd--source=internal-src--path='/path/to/package_1.0.tar.gz'# Create a repository:$ rspmcreaterepo--name=internal--description='Stable releases of our internal packages'# Subscribe the repository to the source:$ rspmsubscribe--repo=internal--source=internal-src
When using these methods, all packages will share the same --replace value if the flag is provided. Make sure it is okay for all of the packages to be overwritten before running these commands.
Package Manager automatically supports multiple versions of each package. When you are ready to add a new release of a package, run the add command again:
Package Manager ensures that version 2.0 becomes the default for new installations.
Note
Previous package versions are retained in the repository's archive to be accessed through earlier snapshots.
Many internal packages also depend on public packages. To ensure that all the necessary dependencies are available, the recommended option is to create a repository that subscribes to both a local source and a source containing the public packages like CRAN or a curated source.
The previous configuration uses a local source and requires manual steps to add and update packages. If your organization uses Git to store internal R packages, then you can automate this process using a Git source.
# Create a Git source:$ rspmcreatesource--type=git--name=internal-src
# Create a Git builder, configured to surface tagged commits:$ rspmcreategit-builder--url=https://bitbucket.example.com/r-pkg.git--source=internal-src--build-trigger=tags
# Check the status and learn more about the build:$ rspmlistgit-builds--source=internal-src--name=r-pkg
# Read the build logs using the ID from the previous# command output or from the "Activity" log in the UI:$ rspmlogs--transaction-id=[ID]# Create a repository and subscribe it to the source:$ rspmcreaterepo--name=git--description='Stable releases of our internal packages'$ rspmsubscribe--source=internal-src--repo=git
Packages can be built using Git endpoints accessed via HTTP(s) or SSH URLs: https://github.com/user/repo.git vs. git@github.com:user/repo.git.
Note
For Git systems with non-standard ports, Package Manager also supports an SSH schema that can be used to specify the port. In practice this looks like: ssh://git@github.com:22/rstudio/rstudio.git. See the SSH Protocol section of Git on the Server - The Protocols for more information.
If the Git URL uses SSH, then it requires an SSH key for authentication. In this case, import the key before using the create git-builder command.
SSH keys are not required to use a passphrase, but a secure key with passphrase is recommended.
Terminal
# Import the SSH key:# passphrase file should just be text file with passphrase for key (avoid leaving in bash history):$ rspmimportssh-key--name=read-r-pkg--path=/path/to/ssh/key--passphrase-path=/path/to/passphrase/file
# Optionally, remove the key from disk:$ rm/path/to/ssh/key
# Create the Git builder$ rspmcreategit-builder--url=user@bitbucket.example.com/r-pkg.git--source=internal-src--build-trigger=tags--ssh-key=read-r-pkg
Along with PyPI mirroring support, Package Manager also supports adding internally-built Python packages. This guide will walk through how to get started with Twine and start uploading your local Python packages to Package Manager.
Similiar to the local source for R packages, Package Manager has a local-python source type that can be used for uploading your local Python packages. To create this source, run the following command:
Terminal
# Create a local Python source:$ rspmcreatesource--name=local-python-src--type=local-python
Source 'local-python-src': Type: Local Python
You can then create a python repo and subscribe the local-python source to it:
Terminal
# Create a Python repository:$ rspmcreaterepo--name=local-python-repo--type=python--description='Access local Python packages'Repository: local-python-repo - Access local Python packages - Python# Subscribe the repository to the local Python source:$ rspm subscribe --repo=local-python-repo --source=local-python-srcRepository: local-python-repoSources:--local-python-src (Local Python)
Once the source and repository have been created, an authentication token needs to be generated to allow a user to upload Python packages to the source. To create the token, run the command on the server:
Terminal
$ rspmcreatetoken--description="Local Python token"--sources=local-python-src--expires=30d
Generated an access token. Be sure to record this token immediately since you will not be able to retrieve it later.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwYWNrYWdlbWFuYWdlciIsImV4cCI6MTY1ODU4MjA3OCwianRpIjoiYmM5ZTg1NGYtNGNlNy00Zjc4LTlhMmMtZDliYzRlYTQ0NGVkIiwiaWF0IjoxNjU1OTkwMDc4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjQyNDIvIiwic2NvcGVzIjp7InNvdXJjZXMiOiIzYTI4NjFhYi0xNWYwLTRjM2MtODZlMy0xNjNkMTY0ZDE0ZDYifX0.BWJXLworo44Nvfrh5a2hm_NIqgUoXTLjQlxyy7uaSWk
Note
The remote authentication configuration option needs to be enabled to generate and use API tokens. To learn more about the configuration option, see APITokenAuth.
Twine is a tool that can be used to upload Python packages that have been built locally. To learn more about its full feature set, you can read the Twine documentation.
Note
Other Python upload tools like Poetry and Flit should work since Package Manager's API attempts to maintain compatibility with the PyPI Warehouse upload endpoint. However, Twine is the officially recommended and documented method of uploading Python packages to Package Manager.
First, you'll want to make sure Twine is downloaded and available to use on the system that will be uploading packages. To do this, run:
Terminal
$ pipinstalltwine
Now that Twine is installed, it can be used to remotely upload packages. There are a few approaches to using Twine for uploading to custom repositories. To get up and running quickly, we'll look at using Twine's environment variables. The three that are necessary are:
TWINE_REPOSITORY_URL
TWINE_USERNAME
TWINE_PASSWORD
The TWINE_REPOSITORY_URL environment variable is the address that is used to upload to Package Manager remotely, ending with the endpoint /upload/pypi/{source-name}. Since we are using token authentication, TWINE_USERNAME will always be set to __token__. Finally, TWINE_PASSWORD is set to the token that was generated above. To put this all together, the following is an example of what the variables could be set to:
Package Manager can serve Bioconductor packages from two types of repositories:
Bioconductor repositories provide multiple versions of Bioconductor side by side and serve as a Bioconductor mirror. Packages are installed from these repositories using the BiocManager package. This is the most common way to make Bioconductor packages available.
R repositories provide a single version of Bioconductor in a CRAN-like repository. Packages are installed from these repositories using install.packages. Unlike Bioconductor repositories, R repositories allow CRAN, Local, and Git packages to be served alongside Bioconductor packages in the same repository.
The appropriate repository type to use depends on how your organization uses Bioconductor.
To create a Bioconductor repository, run the following commands:
Note
All Bioconductor versions will be synced and automatically added to the repository.
Terminal
# Create a Bioconductor repository named 'bioconductor':$ rspmcreaterepo--type=bioconductor--name=bioconductor
Repository: bioconductor - Bioconductor# Initiate a Bioconductor sync:$ rspmsync--type=bioconductor
...Initiated Bioconductor synchronization for bioc-3.11-bioc. Depending on how much data has been previously synchronized, this could take a while. Actions will appear in the Package Manager UI as they are completed.Initiated Bioconductor synchronization for bioc-3.11-data/annotation. Depending on how much data has been previously synchronized, this could take a while. Actions will appear in the Package Manager UI as they are completed....Bioconductor synchronization complete.
After running the sync command, future updates will automatically occur on a daily schedule by default. You do not need to manually run the sync command again after this. To learn more about how to customize the sync schedule, see the Synchronizing with the Posit Package Service section.
We also recommend creating a repository that provides compatible CRAN snapshots for past Bioconductor releases. To provide CRAN snapshots, create a repository that subscribes only to CRAN:
Terminal
# Check if an existing repository already subscribes to CRAN only:$ rspmlist
...cran - R - cran (CRAN)# If not, run the following commands:# Create a repository named 'cran':$ rspmcreaterepo--name=cran--description='Access CRAN packages'# Subscribe the repository to the CRAN source:$ rspmsubscribe--repo=cran--source=cran
# Initiate a CRAN sync:$ rspmsync--type=cran
The Bioconductor repository should now be available in the web interface and ready to use. If a CRAN repository was created, the Setup page for the Bioconductor repository will provide instructions for configuring an appropriate CRAN snapshot in the Using a CRAN Snapshot section.
Alternatively, you can serve a single version of Bioconductor in an R repository.
First, list the available Bioconductor versions and create a Bioconductor source for the desired version:
Terminal
# List available Bioconductor versions:$ rspmlistbioconductorversions
Available Bioconductor versions:3.123.113.10...# Create a source for Bioconductor 3.11:$ rspmcreatesource--type=bioconductor--version=3.11
Source 'bioc-3.11': Type: Bioconductor
Then, create an R repository, subscribe it to the source, and sync the source:
Terminal
# Create a repository for Bioconductor 3.11 named 'bioconductor-3.11':$ rspmcreaterepo--name=bioconductor-3.11--description='Access Bioconductor 3.11 packages'# Subscribe the repository to the Bioconductor source:$ rspmsubscribe--repo=bioconductor-3.11--source=bioc-3.11
# Initiate a sync for the Bioconductor source:$ rspmsync--type=bioconductor--source=bioc-3.11
Initiated Bioconductor synchronization for bioc-3.11-bioc. Depending on how much data has been previously synchronized, this could take a while. Actions will appear in the Package Manager UI as they are completed.Initiated Bioconductor synchronization for bioc-3.11-data/annotation. Depending on how much data has been previously synchronized, this could take a while. Actions will appear in the Package Manager UI as they are completed....Bioconductor synchronization for bioc-3.11 complete.
For past Bioconductor releases, we also recommend serving CRAN packages from this repository that are compatible with the Bioconductor version. To add the appropriate CRAN packages:
Find the last date that the Bioconductor release was current. This is usually the date of the next Bioconductor release, which can be found here.
Find a CRAN snapshot that coincides with this date using the list cran snapshots command.
Create a CRAN snapshot source and add it to the repository.
For example, to add CRAN packages for Bioconductor 3.11 (current until October 28, 2020):
Terminal
# Ensure CRAN metadata is available:$ rspmsync--type=cran
# List available CRAN snapshots:$ rspmlistcransnapshots
...2020-10-292020-10-282020-10-27# Create a CRAN snapshot source for October 28, 2020:$ rspmcreatesource--type=cran-snapshot--snapshot=2020-10-28--name=cran-2020-10-28
# Subscribe the CRAN snapshot source:$ rspmsubscribe--repo=bioconductor-3.11--source=cran-2020-10-28
Repository: bioconductor-3.11Sources:--bioc-3.11 (Bioconductor)--cran-2020-10-28 (CRAN Snapshot)
While Package Manager provides pre-built binaries for CRAN source packages, users may want to upload their own binaries to speed up install times, reduce the need for build-time dependencies, and improve reproducibility across environments.
R binaries target specific R versions, operating systems, CPU architectures, and system dependency versions. Package Manager will handle multiple binaries for a single package and will automatically detect the R version and CPU architecture from the DESCRIPTION file.
You can add your own pre-compiled binary packages to local sources. After adding a source package, you can supplement the source with additional binary packages:
Create pre-compiled binary packages for the R version and distributions you need. See Adding Local and Git Binaries for more information about R binary packages.
Terminal
# Build the source package, package_1.0.tar.gz$ RCMDbuild/path/to/package
# Build the binary package, package_1.0-binary.tar.gz (Linux) or package_1.0.zip (Windows)$ RCMDINSTALL--buildpackage_1.0.tar.gz
Install the source and binary packages:
Terminal
# Create a local source:$ rspmcreatesource--name=internal-src
# Add the local package tar file to the source:$ rspmadd--source=internal-src--path='/path/to/package_1.0.tar.gz'# List available binary distributions$ rspmlistdistributions
Binary distributions: bionic ... windows# Add the precompiled binary packages to the source:$ rspm add binary --source=internal-src --distribution=bionic--path='/path/to/package-binary.tar.gz'$ rspmaddbinary--source=internal-src--distribution=windows--path='/path/to/package-binary.zip'
Subscribe the source to a new (or existing) repository:
Terminal
# Create a repository:$ rspmcreaterepo--name=internal--description='Stable releases of our internal packages with binaries'# Subscribe the repository to the source:$ rspmsubscribe--repo=internal--source=internal-src
You can add your own precompiled binary packages to Git sources. After building a Git package, you can supplement the source with additional binary packages. See Building and serving R packages stored in Git for an example.
Note
Git sources automatically assign unique versions to each source package when building packages based on commits to a branch. The automatic version includes a suffix that is based on the current timestamp, which makes it difficult to upload precompiled binary packages for the Git source. When you wish to upload binary packages for a Git source, we recommend configuring the Git builder to use tags. See Commits vs Tags for more details.
Create the Git package
Terminal
# Create a Git source:$ rspmcreatesource--type=git--name=internal-src
# Create a Git builder, configured to surface tagged commits:$ rspmcreategit-builder--url=https://bitbucket.example.com/r-pkg.git--source=internal-src--build-trigger=tags
# Create a repository and subscribe it to the source:$ rspmcreaterepo--name=git--description='Stable releases of our internal packages'$ rspmsubscribe--source=internal-src--repo=git
Create precompiled binary packages for the R version and distributions you need. See Adding Local and Git Binaries for more information about R binary packages.
Terminal
# Build the source package, package_1.0.tar.gz$ RCMDbuild/path/to/package
# Build the binary package, package_1.0-binary.tar.gz (Linux) or package_1.0.zip (Windows)$ RCMDINSTALL--buildpackage_1.0.tar.gz
Install the binary packages:
Terminal
# List available binary distributions$ rspmlistdistributions
Binary distributions: bionic ... windows# Add the precompiled binary packages to the Git source:$ rspm add binary --source=internal-src --distribution=bionic--path='/path/to/package-binary.tar.gz'$ rspmaddbinary--source=internal-src--distribution=windows--path='/path/to/package-binary.zip'
use the CLI to generate a token with access to the correct sources:
Terminal
$ rspmcreatetoken--description="user A"--sources=local-src--expires=30d
Generated an access token. Be sure to record this token immediately since you will not be able to retrieve it later.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwYWNrYWdlbWFuYWdlciIsImV4cCI6MTY1ODU4MjA3OCwianRpIjoiYmM5ZTg1NGYtNGNlNy00Zjc4LTlhMmMtZDliYzRlYTQ0NGVkIiwiaWF0IjoxNjU1OTkwMDc4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjQyNDIvIiwic2NvcGVzIjp7InNvdXJjZXMiOiIzYTI4NjFhYi0xNWYwLTRjM2MtODZlMy0xNjNkMTY0ZDE0ZDYifX0.BWJXLworo44Nvfrh5a2hm_NIqgUoXTLjQlxyy7uaSWk
On the remote machine, export the correct environment variables and download the CLI:
$Env:PACKAGEMANAGER_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwYWNrYWdlbWFuYWdlciIsImV4cCI6MTY1ODU4MjA3OCwianRpIjoiYmM5ZTg1NGYtNGNlNy00Zjc4LTlhMmMtZDliYzRlYTQ0NGVkIiwiaWF0IjoxNjU1OTkwMDc4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjQyNDIvIiwic2NvcGVzIjp7InNvdXJjZXMiOiIzYTI4NjFhYi0xNWYwLTRjM2MtODZlMy0xNjNkMTY0ZDE0ZDYifX0.BWJXLworo44Nvfrh5a2hm_NIqgUoXTLjQlxyy7uaSWk"$Env:PACKAGEMANAGER_ADDRESS="https://my-rspm-server.org:4443"# Download the CLI$urlCLI="$Env:PACKAGEMANAGER_ADDRESS/__api__/download?os=windows"$outputCLI="rspm.exe"$wc=New-ObjectSystem.Net.WebClient$wc.Headers['Authorization']="Bearer $Env:PACKAGEMANAGER_TOKEN"$wc.DownloadFile($urlCLI,$outputCLI)# Alternatively, on Windows 10 (v1803+), you can download the CLI with curlcurl -OutFilerspm.exe-Headers@{Authorization="Bearer $Env:PACKAGEMANAGER_TOKEN"}"$Env:PACKAGEMANAGER_ADDRESS/__api__/download?os=windows"
After the environment variables are set, the remote machine can use CLI commands that support remote use:
Another common use case for Package Manager is making PyPI (the Python Package Index) packages available in environments with restricted internet access.
To make the PyPI packages available:
Ensure that Package Manager has the appropriate metadata using the sync command. Package Manager pulls PyPI packages and metadata from the Posit Package Service.
Create a repository and subscribe it to the built-in source named pypi.
Terminal
# Create a Python repository:$ rspmcreaterepo--name=pypi--type=python--description='Access PyPI packages'Repository: pypi - Python# Subscribe the repository to the PyPI source:$ rspm subscribe --repo=pypi --source=pypiRepository: pypiSources:--pypi (Python)# Initiate a PyPI sync:$ rspm sync --type=pypiInitiated PyPI synchronization for pypi. Depending on how much data has been previously synchronized, this could take a while. Actions will appear in the Package Manager UI as they are completed.Snapshots for pypi: 0 / 34 [----------------------------------------------------------------------------------------------------------------------------------]Packages in pypi snapshot: 14127 / 231734 [======>-------------------------------------------------------------------------------------------------------] 5m9
After running the sync command, future updates will automatically occur on a daily schedule by default. You do not need to manually run the sync command again after this. To learn more about how to customize the sync schedule, see the Synchronizing with the Posit Package Service section.
Tip
Configure additional storage before enabling PyPI packages to handle the large metadata and package downloads.
For more information on Package Manager's PyPI support, see the PyPI Mirror section of the documentation.