Working with packages¶
Overview¶
All files uploaded to Anaconda.org are stored in packages. Each Anaconda.org package is visible at its own unique URL based on the name of the user who owns the package and the name of the package.
Users can create a Anaconda.org package and then upload files into it.
For more information, see package.
Note
Throughout this task, replace placeholder text like USERNAME
and PACKAGENAME
with the text specific to your project.
Namespaces¶
A namespace is the part of Anaconda.org where a user or organization
may host packages. For example, the user namespace
https://anaconda.org/travis contains packages that were uploaded
and shared by a user named travis
.
For more information, see namespace.
Using package managers¶
Anaconda.org supports two package managers, conda and PyPI. To work with conda or PyPI packages, you must use their corresponding subdomains:
- To install conda packages from the user
travis
, use the repository URLhttps://conda.anaconda.org/travis
- To install PyPI packages from the user
travis
, use the repository URLhttps://pypi.anaconda.org/travis
Conda packages¶
Uploading conda packages¶
This example shows how to build and upload a
conda package to Anaconda.org using
conda build
.
Use the terminal window or an Anaconda Prompt to perform the following steps:
Before you start, install
anaconda-client
andconda-build
:conda install anaconda-client conda-build
Choose the repository for which you would like to build the package. In this example, we use a simple public conda test package:
git clone https://github.com/Anaconda-Platform/anaconda-client cd anaconda-client/example-packages/conda/
In this directory, there are two required files, meta.yaml and build.sh.
macOS and Linux systems are Unix systems. Packages built for Unix systems require a
build.sh
file, packages built for Windows require abld.bat
file, and packages built for both Windows and Unix systems require both abuild.sh
file and abld.bat
file. All packages require ameta.yaml
file.To build the package, turn off automatic Client uploading and then run the
conda build
command:conda config --set anaconda_upload no conda build .
All packages built in this way are placed in a subdirectory of the Anaconda
conda-bld
directory.You can check where the resulting file was placed with the
--output
option:conda build . --output
You can upload the test package to Anaconda.org with the Anaconda upload command:
anaconda login anaconda upload /path/to/conda-package.tar.bz2
Note
Replace
/path/to/
with the actual path where you stored the package.
For more information on conda’s overall build framework, you may also want to read the articles Building conda packages.
Installing conda packages¶
You can install conda packages from Anaconda.org by adding channels to your conda configuration.
Use the terminal window or an Anaconda Prompt to perform the following steps:
Because conda knows how to interact with Anaconda.org, specifying the channel
sean
translates to https://anaconda.org/sean:conda config --add channels sean
You can now install public conda packages from Sean’s Anaconda.org account. Try installing the
testci
package at https://anaconda.org/sean/testci:conda install testci
You can install a package from a channel with a token and a label:
conda install -c https://conda.anaconda.org/t/token/channel/label/labelname packagename
Note
Replace
token
with the provided token,channel
with a user channel,labelname
with the label name andpackagename
with the package name you want to install.
PyPI packages¶
Uploading PyPI packages¶
We can test PyPI package uploading with a small public example package saved in the anaconda-client repository.
Use the terminal window or an Anaconda Prompt to perform the following steps:
Begin by cloning the repository from the command line:
git clone git@github.com:Anaconda-Platform/anaconda-client.git cd anaconda-client/example-packages/pypi/
You can now create your PyPI package with the
setup.py
script:python setup.py sdist
The package has now been built as a source tarball and is ready to be uploaded:
anaconda upload dist/*.tar.gz
Your package is now available at
http://anaconda.org/USERNAME/PACKAGE
.
Installing PyPI packages¶
The best way to install a PyPI package is using pip
. For the
following command, we use the package we authored in the
examples above. In your terminal window or an Anaconda Prompt, run:
pip install --extra-index-url https://pypi.anaconda.org/USERNAME/simple pypi-test-package
Installing private PyPI packages¶
The best way to manage access or make PyPI and other packages private is to create organizations or groups, which allow you to set separate permissions per package, notebook or environment.
You can also control access with the token system. All Anaconda.org URLs
can be prefixed with /t/$TOKEN
to access private packages.
In your terminal window or an Anaconda Prompt, run:
TOKEN=$(anaconda auth --create --name YOUR-TOKEN-NAME)
pip install --index-url https://pypi.anaconda.org/t/$TOKEN/USERNAME/simple-test-package
Note
Replace YOUR-TOKEN-NAME
with the name of the token you
created, USERNAME
with your username and
simple-test-package
with the actual test-package name.
Uploading packages¶
To upload package files to Anaconda.org, use the terminal window or an Anaconda Prompt and the upload command:
anaconda login anaconda upload PACKAGENAME
Anaconda.org automatically detects packages and notebooks, package or notebook types, and their versions.
Your package is now available at:
https://anaconda.org/USERNAME/PACKAGENAME
Your package also can be downloaded by anyone using Client from the terminal window or an Anaconda Prompt:
anaconda download USERNAME/PACKAGENAME
Using private packages¶
It is no longer possible to sign up for an individual paid plan with private packages. Anyone who had private packages in the past still has the ability to have those hosted privately.
By default, all packages, notebooks, and environments uploaded to Anaconda.org are accessible to anyone who has access to the repository.
Packages uploaded to your user channel on Anaconda.org can be marked as private using the Web UI:
Select the desired package.
Select the Settings tab.
Select Admin in the sidebar.
Alternatively, you can reach this page with the following URL:
https://anaconda.org/username/packagename/settings/admin
Note
Jupyter notebooks and conda environments can also be marked private using this procedure and URL.
Note
Other Anaconda.org users may access your private packages either with tokens or by logging in.
Private packages with tokens¶
Note
Replace token
with the provided token, channel
with a user channel,
labelname
with the label name, and packagename
with a package name you want to install.
To make your private packages available to be accessed with tokens:
First create an access token that includes the following scope for Client:
conda:download
Or, in the Web UI with:
Allow private downloads from conda repositories
The token is a random alphanumeric string and this is used to install a package or add a channel from which you want to install private packages.
Using the provided token, a user channel can be added to
config
from the terminal window or an Anaconda Prompt with:conda config --add channels https://conda.anaconda.org/t/token/channel
The token can also be used to install packages without first adding the channel. In the terminal window or an Anaconda Prompt, run:
conda install -c https://conda.anaconda.org/t/token/channel packagename
To install a package from a channel using token and label name:
conda install -c https://conda.anaconda.org/t/token/channel/label/labelname packagename
Private PyPI packages can also be installed in the Web UI:
https://pypi.anaconda.org/t/token/channel
Private packages with login¶
To make your private packages available to users who have logged in:
- Create an organization.
- Create a group in that organization, which may be a read-only group.
- Add to the group the users that you want to grant access to.
- Upload the package to the organization, or transfer an existing package to the organization.
After you grant them access, other users can download and install your package using the Web UI or Client.
To download a package:
In a browser, navigate to the desired channel.
If the organization name is
OrgName
and the package name isconda-package
, use these commands in the terminal window or an Anaconda Prompt:conda install anaconda-client anaconda login conda install -c OrgName conda-package
Or instead:
conda install anaconda-client anaconda login conda install -c https://conda.anaconda.org/OrgName conda-package
Removing a previous version of a package¶
To remove a previous version of one of your packages from Anaconda.org:
- Select the package name.
- Select the Files tab.
- Select the checkbox to the left of the version you want to remove.
- In the Actions menu, select Remove.
You may instead use the terminal window or an Anaconda Prompt:
Run:
anaconda remove USERNAME/PACKAGENAME/0.2
Note
Replace
USERNAME
with your username,PACKAGENAME
with the package name and0.2
with the desired version.You can now see the change on your profile page:
https://anaconda.org/USERNAME/PACKAGE
Adding a collaborator to a package¶
You can add other users that are not part of an organization to collaborate on your packages. You will need the usernames of the other users.
- From your dashboard, select the package by clicking on its name.
- To display the package settings, select the Settings option.
- To display the current collaborators, select the Collaborators option.
- Type the username of the person you want to add as a collaborator, and then click the Add button.
Note
All collaborators are given full read/write permissions to the package, even private packages.
Removing a collaborator from a package¶
To revoke package access previously granted to a collaborator:
- From your dashboard select the package by clicking on its name.
- To display the package settings, select the Settings option.
- To display the current collaborators, select the Collaborators option.
- Click the red X button next to a collaborator to revoke their access.
Transferring a package to a new owner¶
By default, when you create or add packages, they are attached to your individual profile. You can transfer ownership to another owner account you control, such as an organization profile you manage.
To transfer a package to a new owner:
From your dashboard–or the dashboard of an organization you administer–select the package for which you want to transfer ownership.
The system displays options for that package.
To display the package settings, select the Settings option.
Select the Admin option.
Under Transfer this package to a new owner, click the Transfer button.
Select the organization name for the new owner.
Click the Transfer Ownership button.
Copying a package¶
To copy a package from the channel conda-forge
to a personal channel such as jsmith
:
anaconda copy conda-forge/glueviz/0.10.4 --to-owner jsmith
conda-forge/glueviz/0.10.4
is a “spec” and can match either of two formats:
user/package/version
or user/package/version/filename
.
Previously labels were called “channels”, and the anaconda copy
command
has deprecated options from-channel
and to-channel
that expect to
operate on labels. These deprecated options should not be used. If you
attempt to run anaconda copy --from-channel conda-forge --to-channel jsmith glueviz
,
you will receive an error that Label conda-forge does not exist
.
Deleting a package¶
To delete a package from Anaconda.org, including all of its versions:
- Select the package name.
- Select the Settings option.
- In the left sidebar, select Admin.
- Click Delete.
You may instead use the terminal window or an Anaconda Prompt:
Run:
anaconda remove USERNAME/PACKAGENAME
You can now see the change on your profile page:
https://anaconda.org/USERNAME