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.
Before you start
Section titled “Before you start”- 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.
Add CloudRepo as an explicit source
Section titled “Add CloudRepo as an explicit source”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/:
[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:
poetry add acme-utils acme-shared-lib --source cloudrepoIf 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.
Give Poetry the credential
Section titled “Give Poetry the credential”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:
export POETRY_HTTP_BASIC_CLOUDREPO_USERNAME="$CLOUDREPO_USERNAME"export POETRY_HTTP_BASIC_CLOUDREPO_PASSWORD="$CLOUDREPO_TOKEN"poetry installAt 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:
export POETRY_HTTP_BASIC_CLOUDREPO_USERNAME="you@example.com"read -rs POETRY_HTTP_BASIC_CLOUDREPO_PASSWORD && export POETRY_HTTP_BASIC_CLOUDREPO_PASSWORDDo 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.
Publish
Section titled “Publish”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:
export POETRY_REPOSITORIES_CLOUDREPO_URL=https://your-org.mycloudrepo.io/repositories/your-repoexport POETRY_HTTP_BASIC_CLOUDREPO_USERNAME="$CLOUDREPO_USERNAME"export POETRY_HTTP_BASIC_CLOUDREPO_PASSWORD="$CLOUDREPO_TOKEN"poetry buildpoetry publish --repository cloudrepoExpected: 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.
Install through a proxy repository
Section titled “Install through a proxy repository”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/:
[[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:
poetry add requestsExpected: 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
Section titled “A Python group”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.
When Poetry answers 401, 403, 404 or 409
Section titled “When Poetry answers 401, 403, 404 or 409”Authorization error accessing. Poetry printsSource (cloudrepo): Authorization error accessingand the index URL for both401and403. For a401, 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 a403, the token does not reach this repository. A token only reaches the repositories ticked when it was created.doesn't match any versions. Poetry printsBecause ... 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 answers404, not403.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.