Poetry: Fix warning about sources
In Poetry, if you have defined custom sources but have not set a default source, you will get the following warning:
As the message implies, this warning can be addressed by adding a default source.
Public PyPI §
If you need the public PyPI, add it as the default by running:
Then your pyproject.toml
will contain:
Private PyPI §
If you already have a private PyPI as a source, you need to ensure at least one of your sources has a priority
of "default"
. For example, if you have two existing sources which are "primary"
and "supplemental"
, you will get the warning.
To fix this, you could modify your pyproject.toml
to change the priority
of your "primary"
source to "default"
, then run poetry lock --no-update
1.
Bonus: Adding a private PyPI §
If you want to add a private PyPI source, you can do it similar to adding the public PyPI, except you will need to specify the URL:
This will add these lines to your pyproject.toml
:
Assuming your private PyPI requires authentication, you will need to use poetry config
to authenticate, e.g.:
The only change this should make to the
poetry.lock
file is to update thecontent-hash
, which is essentially a SHA256 checksum of the contents of thepyproject.toml
file. So, even though changing thepriority
has no impact on the contents of the generatedpoetry.lock
, it still causes the checksum to change because that is based upon thepyproject.toml
which was modified. ↩︎