![](/img/trans.png)
[英]Tox installing external libraries in tox env not from requirements.txt
[英]Define timeout when tox is installing requirements
我有一个 gitlab ci 管道,它基本上在环境中做一些事情(安装 python 和其他包)然后它只是运行tox
以运行一些测试。
stages:
- check
before_script:
# 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
check:
stage: check
image: gitlab.*****.com:****/*****
environment: prod
services:
- name: docker:19.03.8-dind #20.10.7
alias: docker
only:
- master
script:
- |
echo "
machine gitlab.*****.com
login gitlab-ci-token
password $CI_JOB_TOKEN
" > ~/.netrc
- tox
这是我的tox.ini
:
[tox]
envlist =
{python3.9}
[testenv]
passenv = *
setenv =
AIRFLOW_HOME = /airflow_home
deps=
pytest
-r{toxinidir}/requirements.txt
commands=
pytest
问题是当tox
构建环境并安装requirements.txt
中指定的包时,它返回ReadTimeOutError
。
我试图删除tox
并简单地运行pip install -r requirem.nets --default-timeout=200
并且它有效。
所以问题似乎是超时。 我想定义一个timeout
,但我不想丢弃毒物。
我该怎么做?
tox 在后台使用 pip,因此您可以使用相同的选项,最好作为环境变量。
因此,在https://pip.pypa.io/en/stable/topics/configuration/#environment-variables 之后,您需要将--default-timeout
转换为PIP_DEFAULT_TIMEOUT
变量。
您可以通过在 CI 中设置它然后在tox.ini
中使用passenv
指令来使用此变量,或者您可以通过setenv
指令直接在tox.ini
中设置它。
tox的相关文档:
您可以更改默认install_command
:
install_command = pip install {opts} --default-timeout=200 {packages}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.