Customizing pip settings

To customize pip settings edit the global pip.conf configuration file. Add information about a proxy server or (in air-gaped configurations) add custom Python distribution packages to a shared storage volume so that users can directly install them in their runtimes.

Before you begin, set the CPD_URL and TOKEN environment variables and make sure that the cc-home storage volume exists. For instructions, see Generating an API authorization token and Setting up a storage volume to store customizations for common core services.

You set the configuration that is used by pip in the /cc-home/_global_/config/conda/pip.conf global file. These settings apply to all Watson Studio runtimes and all users. The /cc-home/_global_/config/conda/pip.conf file is read-only. The instructions in this document show how to modify the file by using REST API commands.

After making the modifications, run python3 -m pip config debug to check if the modifications in pip.conf are applied correctly.

An update to pip.conf is activated when a runtime is started. If you want to apply the changes to the global pip.conf file, you must restart the existing runtime.

Configuring pip to use a proxy server or an internal package index

To configure pip to use a proxy server or an internal package index:
  1. Retrieve any existing pip.conf files by running this code:
    curl -vk ${CPD_URL}/zen-volumes/cc-home/v1/volumes/files/%2F_global_%2Fconfig%2Fconda%2Fpip.conf -H "Authorization: ZenApiKey ${TOKEN}" -o pip.conf
  2. To configure a proxy server, set pip.conf as follows:
    [global]
    proxy=https://<user>:<password>@<proxy name>:<port>
    To always use an internal repository server, set pip.conf as follows:
    [global]
    index-url=https://www.example.com/root/pypi/+simple/
    trusted-host=https://www.example.com
  3. Copy the pip.conf file to the shared file system by running this code:
    curl -k -X PUT \
    "${CPD_URL}/zen-volumes/cc-home/v1/volumes/files/%2F_global_%2Fconfig%2Fconda" \
    -H "Authorization: ZenApiKey ${TOKEN}" \
    -H "content-type: multipart/form-data" \
    -F upFile=@pip.conf

Add custom Python distribution packages to the cc-home storage volume

You can add a custom Python distribution package to the cc-home storage volume so that users can directly install them in their runtimes.

To add a custom Python distribution package to the cc-home storage volume:
  1. Create a Python project with a setup.py build script.
  2. Generate a distribution package.
  3. Run this code to upload the zipped archive file to /cc-home/_global_/config/conda:
    curl -k -X PUT \
    "${CPD_URL}/zen-volumes/cc-home/v1/volumes/files/%2F_global_%2Fconfig%2Fconda" \
    -H "Authorization: ZenApiKey ${TOKEN}" \
    -H "content-type: multipart/form-data" \
    -F upFile=@<package_name>