Poetry: Fix warning about sources
All notes in this series:
- Poetry: Fixing dubious ownership error
- Poetry: build.py example
- Poetry: Automatically generate package version from git commit
- Poetry: Fix warning about sources
- Poetry: Running Black and isort with pre-commit hooks
- Poetry: Fixing permission error when upgrading dulwich
- NiceGUI with Click, Poetry, auto-reload and classes
- Poetry: Offline installation of packages
- Run Poetry command as systemd service
- GitLab CI and poetry-dynamic-versioning
- Poetry: install alpha builds
- Upgrade version of pkginfo used by Poetry
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. ↩︎