3

I'm working on packaging a Python project into a Flatpak and one of the tough parts of the process is that you need to specify everything that'll be downloaded in advance of the build because the builder will fetch only those files and then start the build without any network access.

This was simple enough: I wrote a script to spider through my dependencies and generate a list of packages to download in advance, and the builder now just happily goes through the list doing pip3 install --prefix=/app --no-deps . for each .tar.gz file there.

However, the build fails because even though --no-deps is specified, it's still trying to access the network to resolve dependencies. Here's the output from traitlets for example:

$ mkdir /tmp/test-stuff
$ cd /tmp/test-stuff
$ wget https://files.pythonhosted.org/packages/b8/24/e6dfe45ecfc4c2b0d6774565e631dc1b9e50de2c3536625d377963d56cae/traitlets-5.0.5.tar.gz
$ tar xzf traitlets-5.0.5.tar.gz
$ cd traitlets-5.0.5

[disable my network connection]

$ pip3 install --prefix=/app --no-deps .

Processing /tmp/test-stuff/traitlets-5.0.5
  DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
   pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /tmp/test-stuff/.venv/bin/python /tmp/pip-standalone-pip-fi7402mr/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-t15e0kws/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel
       cwd: None
  Complete output (7 lines):
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f4a69b37490>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/setuptools/
  WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f4a698dbcd0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/setuptools/
  WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f4a698db040>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/setuptools/
  WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f4a698db280>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/setuptools/
  WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f4a698db490>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/setuptools/
  ERROR: Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: none)
  ERROR: No matching distribution found for setuptools>=40.8.0
  ----------------------------------------
WARNING: Discarding file:///tmp/test-stuff/traitlets-5.0.5. Command errored out with exit status 1: /tmp/test-stuff/.venv/bin/python /tmp/pip-standalone-pip-fi7402mr/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-t15e0kws/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel Check the logs for full command output.
ERROR: Command errored out with exit status 1: /tmp/test-stuff/.venv/bin/python /tmp/pip-standalone-pip-fi7402mr/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-t15e0kws/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel Check the logs for full command output.

So my question is: how can I get pip to install something without trying to fetch dependencies, since --no-deps doesn't appear to be doing that?

Daniel Quinn
  • 6,010
  • 6
  • 38
  • 61

0 Answers0