pypi Packages
  • 28 Aug 2024
  • 1 Minute to read
  • Dark
    Light
  • PDF

pypi Packages

  • Dark
    Light
  • PDF

Article summary

Getting Started

  1. Log in with the Crowdbotics CLI:

    cb login
  2. Set up your pypi config files:

    cat > ~/.pypirc << EOF
    [distutils]
    index-servers =
    	crowdbotics
    
    [crowdbotics]
    repository = https://pkg.crowdbotics.com/pypi/packages/stable/+simple
    username = packages
    password = $(npx node-jq -r ".token" ~/.crowdbotics/auth.json)
    EOF
    cat > ~/.config/pip/pip.conf << 'EOF'
    [global]
    index-url = "https://packages:${PKG_PASSWORD}@pkg.crowdbotics.com/pypi/packages/stable/+simple"
    EOF
  3. Set up your environment variables:

    zsh users (default on MacOS)

    cat >> ~/.zshrc << EOF
    # Crowdbotics Packages config
    export PKG_PASSWORD=$(npx node-jq -r ".token" ~/.crowdbotics/auth.json)
    EOF
    cat >> ~/.zshrc << 'EOF'
    export TWINE_REPOSITORY_URL="https://packages:[email protected]/pypi/packages/stable"
    EOF

    bash users

    cat >> ~/.bashrc << EOF
    # Crowdbotics Packages config
    export PKG_PASSWORD=$(npx node-jq -r ".token" ~/.crowdbotics/auth.json)
    EOF
    cat >> ~/.bashrc << 'EOF'
    export TWINE_REPOSITORY_URL="https://packages:[email protected]/pypi/packages/stable"
    EOF

Publishing packages

Publishing packages with pypi is very straightforward.

  1. Create a pyproject.toml file based on this example.

  2. Name your package pkg-<your-package-name-here>.

  3. Build your project with python -m build and publish with twine upload.

A full example is available at:
https://github.com/crowdbotics/pkg-pypi-packaging-tutorial

Package visibility

In the current version of the system, all published packages are available to all users in your organization; only the package author or the organization owner can publish new versions.
Fine-grained access control settings will be available in a future release.

Existing projects

  1. On existing projects update your Pipfile sources section to look like this:

    [[source]]
    url = "https://packages:${PKG_PASSWORD}@pkg.crowdbotics.com/pypi/packages/stable/+simple"
    verify_ssl = true
    name = "pip_conf_index_global"
  2. Then run pipenv lock to update the Pipfile.lock file.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.