Define timeout when tox is installing requirements


I have a gitlab ci pipeline which basically do some stuff on the enviornment ( install python and other packages) then it simply run tox in order to run some tests.

  - check

    # here you can run any commands before the pipelines start
    - apt-get -qq update && apt-get -qq install -y python3.9
    - apt-get install -y libpq-dev &&  apt-get install -y python3.9-dev
    - apt-get install -y build-essential && apt-get install -y gcc && apt-get install -y postgresql
    - apt-get install -y  postgresql-contrib && apt-get install -y  ffmpeg libsm6 libxext6
    - apt-get install -y git
    - pip install tox

  stage: check
  image: gitlab.*****.com:****/*****
  environment: prod
    - name: docker:19.03.8-dind #20.10.7
      alias: docker
    - master
    - |
      echo "
      machine gitlab.*****.com
      login gitlab-ci-token
      password $CI_JOB_TOKEN
      " > ~/.netrc 
    - tox

This is my tox.ini:

envlist =

passenv = *
setenv =
    AIRFLOW_HOME = /airflow_home

The problem is that when tox is building the env and installing the packages specified in the requirements.txt it returns a ReadTimeOutError.

I’ve tried to delete tox and simply run a pip install -r requiremenets --default-timeout=200 and it worked.
So the problem seems to be a timeout.
I’d like to define a timeout but i don’t want to discard tox.

How can i do it?

Asked By: Marco Fumagalli



tox is using pip under the hood, so you can use the same options, preferable as environment variables.

So, following you need to convert --default-timeout into the PIP_DEFAULT_TIMEOUT variable.

You can use this variable either by setting it in CI and then use the passenv directive in your tox.ini, or you can set it directly in tox.ini via the setenv directive.

Relevant documentation for tox:

Answered By: Jürgen Gmach

You can change default install_command:

install_command = pip install {opts} --default-timeout=200 {packages}
Answered By: phd
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.