Skip to content

Allow "true" values for pip.conf negative options (no-cache-dir and no-compile) #5011

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

Open
CharlesB2 opened this issue Feb 2, 2018 · 8 comments
Labels
C: configuration Configuration management and loading state: needs discussion This needs some more discussion type: enhancement Improvements to functionality

Comments

@CharlesB2
Copy link

CharlesB2 commented Feb 2, 2018

  • Pip version: 9.0.1
  • Python version: 3.5.2
  • Operating system: Ubuntu 16.04 LTS

Description:

Trying to disable cache dir, I see in the docs that I need to set falsy values to no-cache-dir, which is counter intuitive: no-cache-dir is false, it's a double negation, and it's difficult to figure out that it actually disables the cache dir.

Trying to set it to true gives the error below.

What I've run:

In pip.conf, if I set no-cache-dir to true, in the intent of disabling cache dir:

[global]
no-cache-dir = true

and then running e.g. pip list gives:

[...]
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/pip/__init__.py", line 233, in main
    return command.main(cmd_args)
  File "/usr/local/lib/python3.5/dist-packages/pip/basecommand.py", line 251, in main
    timeout=min(5, options.timeout)) as session:
  File "/usr/local/lib/python3.5/dist-packages/pip/basecommand.py", line 69, in _build_session
    if options.cache_dir else None
  File "/usr/lib/python3.5/posixpath.py", line 89, in join
    genericpath._check_arg_types('join', a, *p)
  File "/usr/lib/python3.5/genericpath.py", line 143, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'int'
@CharlesB2 CharlesB2 changed the title Allow "true" values no-cache-dir and no-compile pip.conf options Allow "true" values for pip.conf negative options (no-cache-dir and no-compile) Feb 2, 2018
@pradyunsg pradyunsg added C: configuration Configuration management and loading type: enhancement Improvements to functionality labels May 10, 2018
@pradyunsg
Copy link
Member

I think it'll be better to put in effort to switch to a better format for the configuration -- #3809.

That said, if someone puts up a PR for this, I'll be happy to review it. :)

@pradyunsg pradyunsg added the resolution: deferred till PR Further discussion will happen when a PR is made label May 10, 2018
@pradyunsg
Copy link
Member

I've labelled this issue as an "deferred PR".

This label is essentially for indicating that further discussion related to this issue should be deferred until someone comes around to make a PR. This does not mean that the said PR would be accepted - it has not been determined whether this is a useful change to pip and that decision has been deferred until the PR is made.

KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Feb 13, 2020
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Feb 17, 2020
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Feb 20, 2020
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Feb 26, 2020
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Feb 27, 2020
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Mar 3, 2020
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Mar 10, 2020
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Mar 11, 2020
@pradyunsg
Copy link
Member

#7735 is a PR attempting to fix this.

@pradyunsg pradyunsg added state: needs discussion This needs some more discussion and removed resolution: deferred till PR Further discussion will happen when a PR is made labels Mar 15, 2020
@pradyunsg
Copy link
Member

pradyunsg commented Mar 15, 2020

FWIW, I do think we should fix this -- sharp edges that cut me in a PC case aren't fun when I'm working with it, and even though I'll learn to avoid those edges; it doesn't mean I don't have to consider them when working in the same PC case later.

But, as @pfmoore noted in #7736, the main concerns here are:

  • complexity of implementation
  • proper transition plan for users, to minimize the disruption for end users.

To minimize implementation complexity, I think all the special handling should be done in a post-processing step, as a new self-contained method added to ConfigOptionParser, that is called just before returning in ConfigOptionParser.get_default_values.

I think we may be able to make the transition work, with the new --unstable-feature option serving as the tool for transition:

  • in pip YY.N:

    • Add a --unstable-feature better-negative-configuration-options
    • When that unstable feature is enabled, have nicer values / more consistency in how we handle configuration options in general.
  • in pip YY.N (or pip YY.N+1)

    • Print an easily-silenced "Hey, this is changing in the future, try that out and let us know if you like the new behavior", printed when users are setting the options whose behavior would change under the newer mechanism.
  • in pip YY.N+2 (or pip YY.N+3)

    • Switch to newer, nicer behavior
    • Drop --unstable-feature better-negative-configuration-options (error out on use)

@pradyunsg
Copy link
Member

Thinking about this a bit more, it actually makes more sense to fix this as part of a broader transition (eg: to new configuration file format, new option parsing mechanism etc), since that transition would also follow a similar (if not the same) "transition plan", with additional benefits for both users and maintainers.

@pfmoore
Copy link
Member

pfmoore commented Mar 15, 2020

it actually makes more sense to fix this as part of a broader transition

+1 IMO changes in this area will be sufficiently disruptive (they directly affect user's experience with pip) that we should do as much as we can in one single change. As a result, I take the view that we should treat this as an unfortunate wart with our optparse-based command line handling (which we know we want to change at some point) and fix it at the same time as we switch away from that implementation.

KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Mar 17, 2020
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Mar 19, 2020
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Jun 11, 2020
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Jan 12, 2021
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Feb 1, 2021
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Feb 16, 2021
KOLANICH added a commit to KOLANICH-tools/pip that referenced this issue Feb 19, 2021
@twhittock-disguise
Copy link

It seems some (as yet unknown) nvidia AI tools are setting the no-cache-dir option globally, effectively disabling caching for everyone on a system. Since it's done silently by installing some tools, it's difficult to detect. When an attempt is made to fix caching locally, it is not possible due to this bug.

Is it possible to add some mechanism to remove an option rather than setting its value? For example a new 'undefined' option for true/false options which removes the argument completely from the option parser. It seems unlikely that a new config file format is going to be rolled out since it's been the status since 2020...

The current workaround is to audit pip caching semi-regularly, and if it is suddenly disabled then pip config debug should tell the user which line to delete in the global config.

Clearly this is a problem with the tool installers which are so rudely altering the global config, but some workaround for local environments would be a real blessing.

@pradyunsg
Copy link
Member

Is it possible to add some mechanism to remove an option rather than setting its value?

@twhittock-disguise We do have pip config unset <section>.<option> that you can run instead of relying on doing that work manually.

Also... FYI @warsaw who might want to know about this friction around Python packaging on their stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: configuration Configuration management and loading state: needs discussion This needs some more discussion type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants