Docker 为什么插值键是';asctime&x27;不是有效的选项名称?

Docker 为什么插值键是';asctime&x27;不是有效的选项名称?,docker,pytest,gitlab-ci,python-logging,Docker,Pytest,Gitlab Ci,Python Logging,我有一个带有 [tool:pytest] doctest_encoding = utf-8 log_cli = 0 log_cli_level = INFO log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) log_cli_date_format=%Y-%m-%d %H:%M:%S 我得到以下错误消息 $ pip install .[all] Processing /some/

我有一个带有

[tool:pytest]
doctest_encoding = utf-8
log_cli = 0
log_cli_level = INFO
log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)
log_cli_date_format=%Y-%m-%d %H:%M:%S
我得到以下错误消息

$ pip install .[all]
Processing /some/repo
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-599014dc/setup.py", line 72, in <module>
        setup(**config)
      File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
        _install_setup_requires(attrs)
      File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 137, in _install_setup_requires
        dist.parse_config_files(ignore_option_errors=True)
      File "/usr/local/lib/python3.7/site-packages/setuptools/dist.py", line 695, in parse_config_files
        self._parse_config_files(filenames=filenames)
      File "/usr/local/lib/python3.7/site-packages/setuptools/dist.py", line 599, in _parse_config_files
        val = self._try_str(parser.get(section, opt))
      File "/usr/local/lib/python3.7/configparser.py", line 799, in get
        d)
      File "/usr/local/lib/python3.7/configparser.py", line 394, in before_get
        self._interpolate_some(parser, option, L, value, section, defaults, 1)
      File "/usr/local/lib/python3.7/configparser.py", line 434, in _interpolate_some
        option, section, rawval, var) from None
    configparser.InterpolationMissingOptionError: Bad value substitution: option 'log_cli_format' in section 'tool:pytest' contains an interpolation key 'asctime' which is not a valid option name. Raw value: '%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)'
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-599014dc/
ERROR: Job failed: exit code 1
它也可以在Gitlab上运行的Docker容器中工作。在我的机器上(Ubuntu 18.04)这两个功能都可以使用


为什么会发生这种情况?我如何修复它?

您遇到了
pip
s,您可能会发现
pytest
s很有趣。简而言之,
pytest
只接受百分比样式的日志格式,而
distutils
将其视为插值。解决方法是将
[tool:pytest]
部分从
setup.cfg
提取到
pytest.ini
log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)
log_cli_date_format=%Y-%m-%d %H:%M:%S