python-poetry / python-poetry/poetry
poetry not trying secondary source if default source is offline
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption).
- OS version and name: macOS version 12.4 (Monterey)
- Poetry version: 1.1.14
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/jamesrobb/15b51866bab62fade3ade8668cd2a343
Issue
I've been trying to setup poetry such that it tries to retrieve packages from a private server first, and should that fail, it uses the public PyPi server as a backup. This is how my sources are configured:
[[tool.poetry.source]]
name = "foo"
url = "https://foo.bar/simple/"
default = true
secondary = false
[[tool.poetry.source]]
name = 'pypi-public'
url = 'https://pypi.python.org/simple'
default = false
secondary = true
To test this I tried to install a common python package (pandas), but I get an error that a connection cannot be established to foo.bar:
$ poetry add pandas
ConnectionError
HTTPSConnectionPool(host='foo.bar', port=443): Max retries exceeded with url: /simple/pandas/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x10266dfc0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
at /opt/homebrew/Cellar/poetry/1.1.14/libexec/lib/python3.10/site-packages/requests/adapters.py:565 in send
561│ if isinstance(e.reason, _SSLError):
562│ # This branch is for urllib3 v1.22 and later.
563│ raise SSLError(e, request=request)
564│
→ 565│ raise ConnectionError(e, request=request)
566│
567│ except ClosedPoolError as e:
568│ raise ConnectionError(e, request=request)
The fact that it can't establish a connection to foo.bar of course makes sense, but what I don't understand why it isn't even trying to use the public PyPi source I specified as secondary.
Is this an actual bug or am I misunderstanding the intended behavior of poetry? I would think (intuitively) that poetry would try use a secondary source if the default is unavailable (.e.g, it's down for maintenance).
How can I go about configuring poetry to behave in the way I had hoped it to? (trying my private source first, and then falling back to the public PyPi source).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue using the provided source configuration and the offline foo.bar endpoint, then inspect Poetry's package source selection and connection-error handling. Done means a failed default source allows resolution from the configured secondary PyPI source, with tests covering the fallback behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100