Skip to content

Conversation

@LouisLau-art
Copy link

Fixes #612.

requirements-txt-fixer sorts entries by name, which causes --extra-index-url to be placed before --index-url. Pip processes these options in order, and this ordering can change behavior.

This adds a small sort special-case so --index-url is always ordered before --extra-index-url, and includes a regression test.

Test plan:

  • python -m pytest -q tests/requirements_txt_fixer_test.py

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't handle -i and -e or whatever the short option is

Comment on lines +16 to +19
_SPECIAL_ORDER = {
b'--index-url': 0,
b'--extra-index-url': 1,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's not really any reason to make this a constant -- just adds unnecessary indirection and makes the code harder to understand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

requirements-txt-fixer ordering breaks using --index-url and --extra-index-url together in requirements.txt

2 participants