Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using pip-compile --no-index doesn't exclude the --extra-index-url from being added to requirements.txt #1028

Closed
jackton1 opened this issue Jan 8, 2020 · 11 comments
Labels
cli Related to command line interface things enhancement Improvements to functionality help wanted Request help from the community

Comments

@jackton1
Copy link

jackton1 commented Jan 8, 2020

Prior to 4.x.x using pip-compile and --no-index option correctly excluded the --extra-index-url from the generated requirements.txt

This doesn't seem to work with the latest release.

Environment Versions

  1. OS Type: Mac OS
  2. Python version: Python 3.7.3
  3. pip version: pip 19.3.1
  4. pip-tools version: pip-compile, version 4.3.0

Steps to replicate

$ pip-compile --extra-index-url=https://mycustomusername:[email protected] --no-index

Expected result

In the requirements.txt
#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile --no-index --output-file requirements.txt setup.py
#

Actual result

#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile --extra-index-url=https://mycustomusername:[email protected] --no-index
#
@atugushev
Copy link
Member

atugushev commented Jan 9, 2020

Hello @jackton1

Thanks for the issue! The fact is the --no-index option has nothing to do with To update, run: header. This option controls whether pip-compile should print out --index-url or --extra-index-url to the output (below the header/commentaries).

Default behavior without --no-index option:

$ echo "" | pip-compile - -qo- --extra-index-url https://foo
#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile --extra-index-url=https://foo --output-file=- -
#
--extra-index-url https://foo

See --no-index skips --extra-index-url in the output:

$ echo "" | pip-compile - -qo- --extra-index-url https://foo --no-index
#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile --extra-index-url=https://foo --no-index --output-file=- -
#

Notice the To update, run: header, there's always --extra-index-url regardless of --no-index.

Prior to 4.x.x using pip-compile and --no-index option correctly excluded the --extra-index-url from the generated requirements.txt

That's because before 4.X --index-url and --extra-index-url were never printed to the header section.

Most likely, you need the --no-header option, which is the recommended way to hide sensitive data from the output.

Should we remove --index-url/--extra-index-url from the header if there is --no-index? I'd say no but would like to hear opinions.

@atugushev atugushev added the support User support label Jan 9, 2020
@jackton1
Copy link
Author

jackton1 commented Jan 10, 2020

Personally from the help information it mentions the index url which one could assume relates
to -I, --index-url.

 --index / --no-index            Add index URL to generated file

If this is the case using a similar option --no-extra-index could mean exclude the extra index url explicitly else this could also be another option. Since I'll like to keep the header because it includes warning that the requirements.txt was autogenerated and shouldn't be manually modified.

This could be a new option --no-extra-index or assuming the presence of --no-index also means exclude the extra-index-url from the requirements.txt header.

I prefer the former since it's clear and explicit. @atugushev

@atugushev
Copy link
Member

atugushev commented Jan 10, 2020

@jackton1

I prefer the former since it's clear and explicit

I must note that --index-url and --extra-index-url were never printed to the output before 3.7.0 regardless whether or not the --no-index was set on. Thus, this former behavior was kind of a bug.

See also #811 (comment) wich could be related.

@atugushev atugushev added enhancement Improvements to functionality needs discussion Need some more discussion and removed support User support labels Jan 10, 2020
@jackton1
Copy link
Author

jackton1 commented Jan 10, 2020

Yeah it was quite obvious that this was a bug prior to 4.x.x

I also agree that --emit-index-url would be a viable option.

I'll be keen on finding a middle ground since we recently upgraded to 4.x.x and lost the previous bug/behaviour.

@atugushev atugushev added the cli Related to command line interface things label Jan 10, 2020
@atugushev atugushev added help wanted Request help from the community and removed needs discussion Need some more discussion labels Jan 13, 2020
@atugushev
Copy link
Member

Let's fix it. See #811 (comment).

@atugushev
Copy link
Member

Here is the fix #1146. Please test and review it, any feedback is welcomed!

@jackton1
Copy link
Author

Will do. Thanks.

@AndydeCleyre
Copy link
Contributor

@jackton1

Is this resolved with the current redaction behavior?

Thanks for any update!

@jackton1
Copy link
Author

jackton1 commented Sep 25, 2021

Yes this works as expected using --no-emit-index-url but the index URL is still included with the credentials getting redacted and replaced by ***

@AndydeCleyre
Copy link
Contributor

Thanks! Do you think it's sufficient to close the issue?

@jackton1
Copy link
Author

Yes, I’ll close this. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to command line interface things enhancement Improvements to functionality help wanted Request help from the community
Projects
None yet
Development

No branches or pull requests

3 participants