Working with private channels using third-party tools¶
In order to access private channels via third-party tools (such as pip, Twine, or R), you must have a user token. This can be done through the conda repo tool or by creating channel-specific, read-only/read-write tokens via UI.
Python packages¶
Uploading¶
Twine is a popular tool for uploading Python packages to PyPI-like repositories. Run the following command to upload Python packages:
twine upload --repository-url http://<DOMAIN>/api/repo/<CHANNEL>
<PACKAGE> -u <TOKEN> -p x-auth-token
Example
twine upload --repository-url
http://demo-repo.com/api/repo/my-pip-channel six-1.13.0-py2.py3-none-any.whl -u 46e98d3dbf2378bb26e2107867652ee734eb098ea5b96f35 -p x-auth-token
If the token is incorrect, you will receive a 401 error message.
Please refer to the Twine package documentation to learn how to configure your username and password via the configuration file or environment variables.
Installing¶
Similar to pip, Anaconda Server supports user authentication using Basic Authentication. The following is the proper format for installing pip packages:
pip install --trusted-host <DOMAIN> --index-url
http://<TOKEN>:x-auth-token@<DOMAIN>/api/repo/<CHANNEL>/simple <PACKAGE>
Note
x-auth-token
is not a placeholder, but is used as the actual password for Basic Authentication.
Example
pip install --trusted-host demo-repo.com --index-url
http://46e98d3dbf2378bb26e2107867652ee734eb098ea5b96f35:x-auth-token@demo-repo.com/api/repo/alex-pip/simple six
Make sure to add a trusted host.
Please refer to the pip documentation to learn how to configure the index URL via the configuration file or environment variables.
R packages¶
Uploading¶
Since there is no standard tool for uploading R packages, you can use either the UI or API directly. Run the following command to upload R packages:
curl -v -F filetype=cran_source_package -F content=@<FILENAME>
http://<DOMAIN>/api/repo/<CHANNEL> -H"X-Auth: <TOKEN>"
Where <TOKEN>
is the x-auth-token
.
Example
curl -v -F filetype=cran_source_package -F content=@abc_2.1.tar.gz
http://demo-repo.com/api/repo/alex-pip -H"X-Auth: 46e98d3dbf2378bb26e2107867652ee734eb098ea5b96f35"
Please use cran_source_package
for source packages and cran_binary_package
for binary R packages.
Installing¶
You can use your domain as a repository URL in the install.packages
function by injecting a token into the path:
http://<DOMAIN>/api/repo/t/<TOKEN>/<CHANNEL>/cran
This may look something like the following:
http://demo-repo.com/api/repo/t/46e98d3dbf2378bb26e2107867652ee734eb098ea5b96f35/alex-pip/cran
Example
> install.packages("abc", repos="http://demo-repo.com/api/t/46e98d3dbf2378bb26e2107867652ee734eb098ea5b96f35/repo/alex-pip/cran")