Uploading and installing standard Python packages#

To work with standard Python packages, you must use the corresponding subdomain https://pypi.anaconda.org. To install standard Python packages from the user travis, for example, use the repository URL https://pypi.anaconda.org/travis.

Uploading standard Python packages#

We can test standard Python package uploading with a small public example package saved in the anaconda-client repository.

Use Anaconda Prompt (Terminal on macOS/Linux) to perform the following steps:

  1. Begin by cloning the repository from the command line:

    # Replace <PACKAGE> with the package name
    git clone git@github.com:Anaconda-Platform/anaconda-client.git
    cd anaconda-client/<PACKAGE>/pypi/
    
  2. You can now create your standard Python package with the setup.py script:

    python setup.py sdist
    
  3. 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>, where <USERNAME> is your username and <PACKAGE> is the package name.

Installing standard Python packages#

The best way to install a standard Python package is using pip. For the following command, we use the package we authored in the examples above. Open Anaconda Prompt (Terminal on macOS/Linux) and run the following command:

# Replace <USERNAME> with your username
pip install --extra-index-url https://pypi.anaconda.org/<USERNAME>/simple pypi-test-package

Installing private standard Python packages#

The best way to manage access or make standard Python packages and other packages private is to create organizations or groups, which allow you to set separate permissions per package.

You can also control access with the token system. All Anaconda.org URLs can be appended with /t/$TOKEN to access private packages.

Open Anaconda Prompt (Terminal on macOS/Linux) and run the following command:

# Replace <TOKEN_NAME> with the name of the token you created
# Replace <USERNAME> with your username
# Replace <SIMPLE_TEST_PACKAGE> with the actual test-package name
TOKEN=$(anaconda auth --create --name <TOKEN_NAME>)
pip install --index-url https://pypi.anaconda.org/t/$TOKEN/<USERNAME>/<SIMPLE_TEST_PACKAGE>

Working with standard Python wheel files#

When Anaconda Client uploads a wheel file, it uses the standard Python compliant package name format. This replaces any underscores (_) and periods (.) with dashes (-). If you need to add a wheel file to an already-existing conda package and that package name contains underscores or periods, specify the package name with the --package or -p flag.

# Replace <PACKAGE> with the package name
# Replace </PATH/TO/WHEEL_FILE> with the wheel file and the file path
anaconda upload --package <PACKAGE> </PATH/TO/WHEEL_FILE>

Finding help for uploading packages#

You can obtain a complete list of upload options, including:

  • Package channel.

  • Label.

  • Availability to other users.

  • Metadata.

To list the options, run the following in Anaconda Prompt (Terminal on macOS/Linux):

anaconda upload -h