Skip to content

Poetry Repositories

Poetry installs from a CloudRepo Python repository and publishes to it. CloudRepo serves the same simple index and the same upload API that pip and twine use, so Poetry needs the repository’s address and a credential. To install public packages through a CloudRepo proxy repository of PyPI instead, see Install through a proxy repository.

  • A Python repository. If you have none, see Creating a Repository.
  • A repository token that reaches it, with Download and publish packages if you will publish. See Repository Tokens: Create One and Authenticate. The username is the email address of the account that created the token, and the password is the token.
  • Poetry, installed from Poetry’s own instructions.

Used on this page only, never saved. Never enter a token or password here.

Name CloudRepo as an explicit source, and pin each private package to it. Poetry asks an explicit source only for the packages pinned to it, so each private package comes from CloudRepo and nothing else, and every other package comes from PyPI. List every package in [project] dependencies, the table that poetry init writes, and pin each private one under [tool.poetry.dependencies]. The source URL ends in /simple/:

pyproject.toml
[project]
name = "my-service"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = [
"requests (>=2.31.0,<3.0.0)", # public: from PyPI
"acme-shared-lib (>=1.2.0,<2.0.0)", # private: from CloudRepo alone
"acme-utils (>=1.0.0,<2.0.0)", # a private dependency of acme-shared-lib
]
[tool.poetry.dependencies]
acme-shared-lib = { source = "cloudrepo" }
acme-utils = { source = "cloudrepo" }
[[tool.poetry.source]]
name = "cloudrepo"
url = "https://your-org.mycloudrepo.io/repositories/your-repo/simple/"
priority = "explicit"

List and pin every private package, including private packages that your private packages depend on. A pin alone is ignored. Once [project] dependencies lists any package, Poetry only reads a [tool.poetry.dependencies] entry for packages in that list. It prints no warning, and poetry check still prints All set!. If another package needs a private package that is pinned but not listed, Poetry looks it up on PyPI, just like any dependency with no source. Anyone can publish a package on PyPI under your private package’s name. Do not use priority = "supplemental" for private packages either. Poetry only asks a supplemental source when no primary source has a matching version, and someone publishing under your package’s name on PyPI can pick a version that satisfies the constraint.

poetry add installs right away. If it hits a private dependency before you have named its source, it installs that package from PyPI. To add a private package from the command line, list every private package it needs in one command, each with the source:

Terminal
poetry add acme-utils acme-shared-lib --source cloudrepo

If you instead add only acme-shared-lib, with poetry add acme-shared-lib --source cloudrepo, while acme-utils has no source yet, Poetry installs whatever package PyPI holds under the name acme-utils. CloudRepo is never asked for it.

When a private package starts to need another private package, add that one too, with poetry add and --source cloudrepo or by listing and pinning it by hand, before you run poetry update or poetry lock --regenerate. Otherwise Poetry takes it from PyPI.

Poetry reads the credential for a source from two environment variables. Their names use the source name in upper case, so a source called cloudrepo uses these. Set both from your secret store, shown here as CLOUDREPO_USERNAME and CLOUDREPO_TOKEN:

Terminal
export POETRY_HTTP_BASIC_CLOUDREPO_USERNAME="$CLOUDREPO_USERNAME"
export POETRY_HTTP_BASIC_CLOUDREPO_PASSWORD="$CLOUDREPO_TOKEN"
poetry install

At a terminal, you can type the token instead. The last line waits for you to paste the token and press Enter, and shows nothing. This is the pair the Connect page of a Python repository shows, with your email address filled in:

Terminal
export POETRY_HTTP_BASIC_CLOUDREPO_USERNAME="you@example.com"
read -rs POETRY_HTTP_BASIC_CLOUDREPO_PASSWORD && export POETRY_HTTP_BASIC_CLOUDREPO_PASSWORD

Do not use poetry config http-basic.cloudrepo. If you pass the token as an argument, it sits on the command line where a process listing shows it. Without the argument, Poetry prompts for the token, and on a machine with no keyring it prints Using a plaintext file to store credentials and writes the token to auth.toml in Poetry’s configuration directory.

Build, then publish to the repository URL without /simple/. Poetry reads the address from a third variable named for the repository, so nothing is written to Poetry’s configuration, and the credential is the same pair as above:

Terminal
export POETRY_REPOSITORIES_CLOUDREPO_URL=https://your-org.mycloudrepo.io/repositories/your-repo
export POETRY_HTTP_BASIC_CLOUDREPO_USERNAME="$CLOUDREPO_USERNAME"
export POETRY_HTTP_BASIC_CLOUDREPO_PASSWORD="$CLOUDREPO_TOKEN"
poetry build
poetry publish --repository cloudrepo

Expected: Poetry prints Publishing and the project name, then Uploading and the file name for the source distribution and the wheel, and exits without an error. The files are then in the repository, and the admin portal lists them.

A proxy repository of PyPI gives your builds one CloudRepo address for the public packages on pypi.org. See Proxy Repositories to create one. You cannot upload to a proxy, so your own packages stay in a hosted repository: for those, use the source in Add CloudRepo as an explicit source.

Make the proxy Poetry’s primary source. The URL ends in /simple/:

pyproject.toml
[[tool.poetry.source]]
name = "cloudrepo"
url = "https://your-org.mycloudrepo.io/repositories/your-repo/simple/"
priority = "primary"

The credential is the one in Give Poetry the credential. The source is called cloudrepo, so the two variables are the same. The token must reach the proxy repository, and a Download packages token is enough to install.

Then add a package. A primary source needs no --source:

Terminal
poetry add requests

Expected: Poetry adds requests to pyproject.toml, installs it and exits without an error. poetry.lock then names your proxy’s address.

The Connect page of the proxy repository shows these blocks with your names filled in. See View Connection Settings.

A Python group is in early access: one address in front of hosted and proxy Python repositories. Set Poetry up as you do for a proxy. Use the group’s address with /simple/ added as the url, the same credential and the same poetry add. The Connect page of the group shows the blocks with your names filled in, and says what a token for the group can read.

  • Authorization error accessing. Poetry prints Source (cloudrepo): Authorization error accessing and the index URL for both 401 and 403. For a 401, the credential was refused or never sent. The username must be the email address of the account that created the token (__token__ is refused, since that is a pypi.org convention that CloudRepo does not use), and the password must be the token itself. An expired or revoked token fails the same way. Also check that the variable names match the source name in upper case. For a 403, the token does not reach this repository. A token only reaches the repositories ticked when it was created.
  • doesn't match any versions. Poetry prints Because ... depends on <package> (<version>) which doesn't match any versions, version solving failed. The repository does not hold that name and version, or the URL is wrong, or the dependency names no source and Poetry looked on PyPI. A proxy repository that the token does not reach also answers 404, not 403.
  • HTTP Error 409: Conflict, on publish. The repository has Overwrite Protection on, and a file at that path already exists. Poetry prints the explanation CloudRepo sends with it after the status. Upload a new version, or turn Overwrite Protection off for that repository: see Python Repositories.

More: Repository tokens, for every client’s credential; Python Repositories, for pip and twine and the Python repository settings; uv Repositories, for uv.

View as Markdown