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

[pip-compile] Cannot disable pip version check #1543

Closed
Arpafaucon opened this issue Dec 9, 2021 · 6 comments
Closed

[pip-compile] Cannot disable pip version check #1543

Arpafaucon opened this issue Dec 9, 2021 · 6 comments
Labels
support User support

Comments

@Arpafaucon
Copy link

Environment Versions

  1. OS Type: Ubuntu 20.04
  2. Python version: Python 3.8.10
  3. pip version: pip 21.3
  4. pip-tools version: pip-compile, version 6.4.0

Steps to replicate

  1. Setup a virtualenv with the almost latest version of pip (for me: 21.3, while 21.3.1 is released)
  2. Write a dummy setuptools-like package:
mkdir old_package
touch setup.py

content of setup.py (anything would do I believe)

from setuptools import find_namespace_packages, setup

setup(name='mypkg',
      install_requires=[],
      packages=find_namespace_packages('src'),
      package_dir={'': 'src'})
  1. run pip-compile pip-compile --verbose --pip-args "--disable-pip-version-check" old_package/setup.py

Expected result

There should not be the version check for pip (see full output in actual result)

Actual result

During the isolated build phase, pip checks its version.

❯ pip-compile --verbose --pip-args "--disable-pip-version-check" old_package/setup.py
Temporary build environment: /tmp/pep517-build-env-yyp2od51
Calling pip to install ['setuptools', 'wheel']
Collecting setuptools
  Using cached setuptools-59.5.0-py3-none-any.whl (952 kB)
Collecting wheel
  Using cached wheel-0.37.0-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel, setuptools
Successfully installed setuptools wheel
ERROR: WARNING: You are using pip version 21.3; however, version 21.3.1 is available.
ERROR: You should consider upgrading via the '/home/xxx/dev/wdc/python/env/bin/python3 -m pip install --upgrade pip' command.
Got build requires: ['wheel']
Calling pip to install ['wheel']
Collecting wheel
  Using cached wheel-0.37.0-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.37.0
ERROR: WARNING: You are using pip version 21.3; however, version 21.3.1 is available.
ERROR: You should consider upgrading via the '/home/xxx/dev/wdc/python/env/bin/python3 -m pip install --upgrade pip' command.
Installed dynamic build dependencies
Trying to build metadata in /tmp/tmp5vq2k9nb
Using indexes:
  https://pypi.org/simple

                          ROUND 1                           
Current constraints:

Finding the best candidates:

Finding secondary dependencies:
------------------------------------------------------------
Result of round 1: stable, done

#
# This file is autogenerated by pip-compile with python 3.8
# To update, run:
#
#    pip-compile --pip-args='--disable-pip-version-check' old_package/setup.py
#
@AndydeCleyre
Copy link
Contributor

AndydeCleyre commented Feb 10, 2022

At first look, I think this is happening behind a call to meta.load(), where meta comes from the pep517 module.

Utimately, we get here in the meta module:

def build(source_dir='.', dest=None, system=None):
    system = system or load_system(source_dir)
    dest = os.path.join(source_dir, dest or 'dist')
    mkdir_p(dest)
    validate_system(system)
    hooks = Pep517HookCaller(
        source_dir, system['build-backend'], system.get('backend-path')
    )

    with hooks.subprocess_runner(quiet_subprocess_runner):
        with BuildEnvironment() as env:
            env.pip_install(system['requires'])
            _prep_meta(hooks, env, dest)

And down there at env.pip_install(....):

    def pip_install(self, reqs):
        """Install dependencies into this env by calling pip in a subprocess"""
        if not reqs:
            return
        log.info('Calling pip to install %s', reqs)
        cmd = [
            sys.executable, '-m', 'pip', 'install', '--ignore-installed',
            '--prefix', self.path] + list(reqs)
        check_call(
            cmd,
            stdout=LoggerWrapper(log, logging.INFO),
            stderr=LoggerWrapper(log, logging.ERROR),
        )

I don't see an obvious way to carry the arguments through this code path, and I'm not sure it's what we want.

If you think this is specifically about the warning, maybe https://github.com/pypa/pep517 would accept a change to prevent it.

If we really do want to modify this pip call, I need to get some sleep and look again.

@atugushev
Copy link
Member

PIP_DISABLE_PIP_VERSION_CHECK=1 would work in this case.

@atugushev atugushev added the support User support label Feb 20, 2022
@Jorricks
Copy link

Isn't it --pip-args=--disable-pip-version-check?

@AndydeCleyre
Copy link
Contributor

@Jorricks This is hitting the code paths in my previous comment, which are outside of pip-tools, where we cannot directly control the arguments passed to those pip invocations.

It might be possible to check for that argument, and then set PIP_DISABLE_PIP_VERSION_CHECK=1 for the environment from within the code, but I'm not sure the complexity is worth it, when the user can set that in their environment and be done with it.

@AndydeCleyre
Copy link
Contributor

I'm inclined to close this, with the best solution for "deep" setting of this option being to set the environment variable.

Unless there are objections, I'll close this one soon.

Thanks!

@AndydeCleyre
Copy link
Contributor

That particular code path (in pep517) might be avoided when using #1629, so feel free to give that a try as well.

I am going to close this now, but please write back if I'm making a mistake. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support User support
Projects
None yet
Development

No branches or pull requests

4 participants