Export to requirements.txt omits extra-index flags for non-default sources
- [x] I am on the latest Poetry version.
- [x] I have searched the issues of this repo and believe that this is not a duplicate.
- [x] If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption).
- OS version and name: Microsoft Windows 7
- Poetry version: 1.0.5
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/mrogaski/72ac083fb3a1652c176d778062571db8
Issue
If I have multiple sources defined in pyproject.toml, with one marked as default to disable accesses to the public PyPI, the export command adds and index-url flag for the default but does not add extra-index for the other sources.
The relevant code is below
Index builder:
https://github.com/python-poetry/poetry/blob/6cd3645d889f47c10425961661b8193b23f0ed79/poetry/utils/exporter.py#L107-L111
Output:
https://github.com/python-poetry/poetry/blob/6cd3645d889f47c10425961661b8193b23f0ed79/poetry/utils/exporter.py#L136-L164
Haven't had time to dig in yet, but there's definitely something bugged about the implementation as I also don't get any --extra-index-url in my exports with a similar structure.
It looks like this is the intended behavior. The only way to disable public PyPI is to set an alternate source to default, but that causes any other alternate sources to be ignored. So you can either use multiple repositories or exclude pypi.org, but not both.
I think this is problematic behavior, specifically if you are using a PyPI mirror along with private repos.
I'll close this bug report out as it works as designed, but I'll likely submit a proposal for enhancements and/or changes to the repository selection behavior separately.
I did some more experimentation and it looks like the behavior of default within poetry behaves as the name would suggest, and differs from the export behavior. So I'm reopening this.