How to Build a Custom Anaconda Installer for R
A frequent question on the Anaconda Community mailing list is how to package R with conda for distribution. Depending on the use case, one option may be to use conda to move environments. This requires that conda has been previously installed on the system. Another option is conda constructor, a utility for packaging a complete conda installation with Python and R packages.
Constructor is the same utility we use to build Anaconda Distribution and Miniconda installers. It’s a multi-platform installer which means you can build an installer for Windows, Linux and macOS. It also supports a number of options to control how the installer is built. These options are documented on the GitHub constructor repository.
Constructor v3.0 requires conda 4.7.10 or higher. Check the version of conda and update if needed.
(base)$ conda --version Conda 4.7.5 (base)$ conda upgrade conda
Install constructor and check the version:
(base)$ conda install constructor (base) $ constructor --version constructor 3.0.0
Constructor uses a YAML file to configure the build. The default file name for the configuration file is
construct.yaml. The only mandatory elements are the name and version, but to create an environment you will also need to specify the channels and the packages to be installed. This is an example file that creates an installer with just python and conda:
name: myBase version: 0.1 channels: - https://repo.anaconda.com/pkgs/main/ specs: - python - conda
To build this installer
(base)$ constructor .
If you run this command in macOS, constructor will create an installer named
By default, the installer uses name-version-OS as the naming convention when a name is not specified.
If you want to create a .pkg installer named
myBase_Belong_To_Us, add the
installer_filename keys to the
installer_filename: myBase_Belong_To_Us.pkg installer_type: pkg [osx]
The keys available to customize the installer are listed on the constructor GitHub repository.
Custom R Installer Tutorial
The R installer tutorial covers how to build installers for Windows, Linux and macOS. The tutorial includes
construct.yaml files for each operating system because there are OS-specific options. The installer includes conda, R and a base set of R packages. It also includes a sample Jupyter Notebook to work with R. If users want to add additional R or Python packages to the installation, they can use conda.
If you want to build your own installers, try out the tutorial on GitHub.