我试图将我的Python软件包从setuptools
切换到Poetry。由于我使用Tox来组织测试套件(带有短毛绒),因此我也必须调整tox.ini
。重现该问题的Tox的最低配置如下所示:
[tox]
envlist = mypy,isort
isolated_build = true
skip_missing_interpreters = False
[testenv:mypy]
allowlist_externals = poetry
commands =
poetry install -v
[testenv:isort]
allowlist_externals = poetry
commands =
poetry install -v
如果我使用tox -e mypy,isort
执行测试套件,则两个测试将成功执行。但是,如果我并行执行测试(以减少执行时间),则两个测试套件之一将失败,因为它找不到pyproject.toml
:
$ tox --parallel auto --parallel-live -e isort,mypy
isort inst-nodeps: /path/to/package/.tox/.tmp/package/5/mypackage-0.17.0.tar.gz
mypy inst-nodeps: /path/to/package/.tox/.tmp/package/6/mypackage-0.17.0.tar.gz
mypy installed: appdirs==1.4.4,attrs==19.3.0,backcall==0.2.0,beautifulsoup4==4.9.1,black==19.10b0,bleach==3.1.5,certifi==2020.6.20,cffi==1.14.1,cfgv==3.2.0,chardet==3.0.4,click==7.1.2,colorama==0.4.3,coverage==5.2.1,cryptography==3.0,decorator==4.4.2,distlib==0.3.1,docutils==0.16,mypackage @ file:///path/to/package/.tox/.tmp/package/6/mypackage-0.17.0.tar.gz,fancycompleter==0.9.1,filelock==3.0.12,fire==0.3.1,flake8==3.8.3,hypothesis==5.23.11,identify==1.4.25,idna==2.10,iniconfig==1.0.1,ipython==7.17.0,ipython-genutils==0.2.0,isort==5.3.2,jedi==0.17.2,jeepney==0.4.3,keyring==21.3.0,lxml==4.5.2,mccabe==0.6.1,more-itertools==8.4.0,mypy==0.782,mypy-extensions==0.4.3,nodeenv==1.4.0,packaging==20.4,parso==0.7.1,pathspec==0.8.0,pdbpp==0.10.2,pexpect==4.8.0,pickleshare==0.7.5,pkginfo==1.5.0.1,pluggy==0.13.1,pre-commit==2.6.0,prompt-toolkit==3.0.5,ptyprocess==0.6.0,py==1.9.0,pycodestyle==2.6.0,pycparser==2.20,pyflakes==2.2.0,Pygments==2.6.1,pyparsing==2.4.7,pyrepl==0.9.0,pytest==6.0.1,pytest-cov==2.10.0,PyYAML==5.3.1,readme-renderer==26.0,regex==2020.7.14,requests==2.24.0,requests-toolbelt==0.9.1,rfc3986==1.4.0,SecretStorage==3.1.2,six==1.15.0,sortedcontainers==2.2.2,soupsieve==1.9.6,termcolor==1.1.0,toml==0.10.1,tox==3.19.0,tqdm==4.48.2,traitlets==4.3.3,twine==3.2.0,typed-ast==1.4.1,typing-extensions==3.7.4.2,urllib3==1.25.10,virtualenv==20.0.30,wcwidth==0.2.5,webencodings==0.5.1,wmctrl==0.3
isort installed: appdirs==1.4.4,attrs==19.3.0,backcall==0.2.0,beautifulsoup4==4.9.1,black==19.10b0,bleach==3.1.5,certifi==2020.6.20,cffi==1.14.1,cfgv==3.2.0,chardet==3.0.4,click==7.1.2,colorama==0.4.3,coverage==5.2.1,cryptography==3.0,decorator==4.4.2,distlib==0.3.1,docutils==0.16,mypackage @ file:///path/to/package/.tox/.tmp/package/5/mypackage-0.17.0.tar.gz,fancycompleter==0.9.1,filelock==3.0.12,fire==0.3.1,flake8==3.8.3,hypothesis==5.23.11,identify==1.4.25,idna==2.10,iniconfig==1.0.1,ipython==7.17.0,ipython-genutils==0.2.0,isort==5.3.2,jedi==0.17.2,jeepney==0.4.3,keyring==21.3.0,lxml==4.5.2,mccabe==0.6.1,more-itertools==8.4.0,mypy==0.782,mypy-extensions==0.4.3,nodeenv==1.4.0,packaging==20.4,parso==0.7.1,pathspec==0.8.0,pdbpp==0.10.2,pexpect==4.8.0,pickleshare==0.7.5,pkginfo==1.5.0.1,pluggy==0.13.1,pre-commit==2.6.0,prompt-toolkit==3.0.5,ptyprocess==0.6.0,py==1.9.0,pycodestyle==2.6.0,pycparser==2.20,pyflakes==2.2.0,Pygments==2.6.1,pyparsing==2.4.7,pyrepl==0.9.0,pytest==6.0.1,pytest-cov==2.10.0,PyYAML==5.3.1,readme-renderer==26.0,regex==2020.7.14,requests==2.24.0,requests-toolbelt==0.9.1,rfc3986==1.4.0,SecretStorage==3.1.2,six==1.15.0,sortedcontainers==2.2.2,soupsieve==1.9.6,termcolor==1.1.0,toml==0.10.1,tox==3.19.0,tqdm==4.48.2,traitlets==4.3.3,twine==3.2.0,typed-ast==1.4.1,typing-extensions==3.7.4.2,urllib3==1.25.10,virtualenv==20.0.30,wcwidth==0.2.5,webencodings==0.5.1,wmctrl==0.3
mypy run-test-pre: PYTHONHASHSEED='398349780'
isort run-test-pre: PYTHONHASHSEED='1461327045'
mypy run-test: commands[0] | poetry install -v
isort run-test: commands[0] | poetry install -v
Using virtualenv: /path/to/package/.tox/mypy
Using virtualenv: /path/to/package/.tox/isort
Installing dependencies from lock file
Installing dependencies from lock file
No dependencies to install or update
- Skipping pycparser (2.20) Already installed
- Skipping cffi (1.14.1) Already installed
- Skipping pyparsing (2.4.7) Already installed
- Skipping six (1.15.0) Already installed
- Skipping certifi (2020.6.20) Already installed
- Skipping chardet (3.0.4) Already installed
- Skipping cryptography (3.0) Already installed
No dependencies to install or update
- Skipping idna (2.10) Already installed
- Skipping jeepney (0.4.3) Already installed
- Skipping pycparser (2.20) Already installed
- Skipping packaging (20.4) Already installed
- Skipping cffi (1.14.1) Already installed
- Skipping urllib3 (1.25.10) Already installed
- Skipping pyparsing (2.4.7) Already installed
- Skipping webencodings (0.5.1) Already installed
- Skipping six (1.15.0) Already installed
- Skipping appdirs (1.4.4) Already installed
- Skipping certifi (2020.6.20) Already installed
- Skipping atomicwrites (1.4.0) Not needed for the current environment
- Skipping chardet (3.0.4) Already installed
- Skipping attrs (19.3.0) Already installed
- Skipping cryptography (3.0) Already installed
- Skipping bleach (3.1.5) Already installed
- Skipping idna (2.10) Already installed
- Skipping colorama (0.4.3) Already installed
- Skipping jeepney (0.4.3) Already installed
- Skipping decorator (4.4.2) Already installed
- Skipping packaging (20.4) Already installed
- Skipping distlib (0.3.1) Already installed
- Skipping urllib3 (1.25.10) Already installed
- Skipping docutils (0.16) Already installed
- Skipping webencodings (0.5.1) Already installed
- Skipping filelock (3.0.12) Already installed
- Skipping appdirs (1.4.4) Already installed
- Skipping iniconfig (1.0.1) Already installed
- Skipping atomicwrites (1.4.0) Not needed for the current environment
- Skipping ipython-genutils (0.2.0) Already installed
- Skipping attrs (19.3.0) Already installed
- Skipping more-itertools (8.4.0) Already installed
- Skipping bleach (3.1.5) Already installed
- Skipping parso (0.7.1) Already installed
- Skipping colorama (0.4.3) Already installed
- Skipping pluggy (0.13.1) Already installed
- Skipping decorator (4.4.2) Already installed
- Skipping ptyprocess (0.6.0) Already installed
- Skipping distlib (0.3.1) Already installed
- Skipping py (1.9.0) Already installed
- Skipping docutils (0.16) Already installed
- Skipping pygments (2.6.1) Already installed
- Skipping filelock (3.0.12) Already installed
- Skipping pyreadline (2.1) Not needed for the current environment
- Skipping iniconfig (1.0.1) Already installed
- Skipping pyrepl (0.9.0) Already installed
- Skipping ipython-genutils (0.2.0) Already installed
- Skipping pywin32-ctypes (0.2.0) Not needed for the current environment
- Skipping more-itertools (8.4.0) Already installed
- Skipping requests (2.24.0) Already installed
- Skipping parso (0.7.1) Already installed
- Skipping secretstorage (3.1.2) Already installed
- Skipping pluggy (0.13.1) Already installed
- Skipping toml (0.10.1) Already installed
- Skipping ptyprocess (0.6.0) Already installed
- Skipping wcwidth (0.2.5) Already installed
- Skipping py (1.9.0) Already installed
- Skipping appnope (0.1.0) Not needed for the current environment
- Skipping pygments (2.6.1) Already installed
- Skipping backcall (0.2.0) Already installed
- Skipping pyreadline (2.1) Not needed for the current environment
- Skipping cfgv (3.2.0) Already installed
- Skipping pyrepl (0.9.0) Already installed
- Skipping click (7.1.2) Already installed
- Skipping pywin32-ctypes (0.2.0) Not needed for the current environment
- Skipping coverage (5.2.1) Already installed
- Skipping requests (2.24.0) Already installed
- Skipping fancycompleter (0.9.1) Already installed
- Skipping secretstorage (3.1.2) Already installed
- Skipping identify (1.4.25) Already installed
- Skipping toml (0.10.1) Already installed
- Skipping jedi (0.17.2) Already installed
- Skipping wcwidth (0.2.5) Already installed
- Skipping keyring (21.3.0) Already installed
- Skipping appnope (0.1.0) Not needed for the current environment
- Skipping mccabe (0.6.1) Already installed
- Skipping backcall (0.2.0) Already installed
- Skipping mypy-extensions (0.4.3) Already installed
- Skipping cfgv (3.2.0) Already installed
- Skipping nodeenv (1.4.0) Already installed
- Skipping click (7.1.2) Already installed
- Skipping pathspec (0.8.0) Already installed
- Skipping coverage (5.2.1) Already installed
- Skipping pexpect (4.8.0) Already installed
- Skipping fancycompleter (0.9.1) Already installed
- Skipping pickleshare (0.7.5) Already installed
- Skipping identify (1.4.25) Already installed
- Skipping pkginfo (1.5.0.1) Already installed
- Skipping jedi (0.17.2) Already installed
- Skipping prompt-toolkit (3.0.5) Already installed
- Skipping keyring (21.3.0) Already installed
- Skipping pycodestyle (2.6.0) Already installed
- Skipping mccabe (0.6.1) Already installed
- Skipping pyflakes (2.2.0) Already installed
- Skipping mypy-extensions (0.4.3) Already installed
- Skipping pytest (6.0.1) Already installed
- Skipping nodeenv (1.4.0) Already installed
- Skipping pyyaml (5.3.1) Already installed
- Skipping pathspec (0.8.0) Already installed
- Skipping readme-renderer (26.0) Already installed
- Skipping pexpect (4.8.0) Already installed
- Skipping regex (2020.7.14) Already installed
- Skipping pickleshare (0.7.5) Already installed
- Skipping requests-toolbelt (0.9.1) Already installed
- Skipping pkginfo (1.5.0.1) Already installed
- Skipping rfc3986 (1.4.0) Already installed
- Skipping prompt-toolkit (3.0.5) Already installed
- Skipping sortedcontainers (2.2.2) Already installed
- Skipping pycodestyle (2.6.0) Already installed
- Skipping soupsieve (1.9.6) Already installed
- Skipping pyflakes (2.2.0) Already installed
- Skipping termcolor (1.1.0) Already installed
- Skipping pytest (6.0.1) Already installed
- Skipping tqdm (4.48.2) Already installed
- Skipping pyyaml (5.3.1) Already installed
- Skipping traitlets (4.3.3) Already installed
- Skipping readme-renderer (26.0) Already installed
- Skipping typed-ast (1.4.1) Already installed
- Skipping regex (2020.7.14) Already installed
- Skipping typing-extensions (3.7.4.2) Already installed
- Skipping requests-toolbelt (0.9.1) Already installed
- Skipping virtualenv (20.0.30) Already installed
- Skipping rfc3986 (1.4.0) Already installed
- Skipping wmctrl (0.3) Already installed
- Skipping sortedcontainers (2.2.2) Already installed
- Skipping beautifulsoup4 (4.9.1) Already installed
- Skipping soupsieve (1.9.6) Already installed
- Skipping black (19.10b0) Already installed
- Skipping termcolor (1.1.0) Already installed
- Skipping fire (0.3.1) Already installed
- Skipping tqdm (4.48.2) Already installed
- Skipping flake8 (3.8.3) Already installed
- Skipping traitlets (4.3.3) Already installed
- Skipping hypothesis (5.23.11) Already installed
- Skipping typed-ast (1.4.1) Already installed
- Skipping ipython (7.17.0) Already installed
- Skipping typing-extensions (3.7.4.2) Already installed
- Skipping isort (5.3.2) Already installed
- Skipping virtualenv (20.0.30) Already installed
- Skipping lxml (4.5.2) Already installed
- Skipping wmctrl (0.3) Already installed
- Skipping mypy (0.782) Already installed
- Skipping beautifulsoup4 (4.9.1) Already installed
- Skipping pdbpp (0.10.2) Already installed
- Skipping black (19.10b0) Already installed
- Skipping pre-commit (2.6.0) Already installed
- Skipping fire (0.3.1) Already installed
- Skipping pytest-cov (2.10.0) Already installed
- Skipping flake8 (3.8.3) Already installed
- Skipping tox (3.19.0) Already installed
- Skipping hypothesis (5.23.11) Already installed
- Skipping twine (3.2.0) Already installed
- Skipping ipython (7.17.0) Already installed
- Skipping isort (5.3.2) Already installed
- Skipping lxml (4.5.2) Already installed
- Skipping mypy (0.782) Already installed
- Skipping pdbpp (0.10.2) Already installed
- Skipping pre-commit (2.6.0) Already installed
- Skipping pytest-cov (2.10.0) Already installed
- Skipping tox (3.19.0) Already installed
- Skipping twine (3.2.0) Already installed
- Installing mypackage (0.17.0)
- Installing mypackage (0.17.0)
[FileNotFoundError]
[Errno 2] No such file or directory: '/path/to/package/pyproject.toml'
Traceback (most recent call last):
File "$HOME/.miniconda3/envs/my-conda-env/lib/python3.8/site-packages/clikit/console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "$HOME/.miniconda3/envs/my-conda-env/lib/python3.8/site-packages/clikit/api/command/command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "$HOME/.miniconda3/envs/my-conda-env/lib/python3.8/site-packages/clikit/api/command/command.py", line 171, in _do_handle
return getattr(handler, handler_method)(args, io, self)
File "$HOME/.miniconda3/envs/my-conda-env/lib/python3.8/site-packages/cleo/commands/command.py", line 92, in wrap_handle
return self.handle()
File "$HOME/.miniconda3/envs/my-conda-env/lib/python3.8/site-packages/poetry/console/commands/install.py", line 94, in handle
builder.build()
File "$HOME/.miniconda3/envs/my-conda-env/lib/python3.8/site-packages/poetry/masonry/builders/editable.py", line 17, in build
return self._setup_build()
File "$HOME/.miniconda3/envs/my-conda-env/lib/python3.8/site-packages/poetry/masonry/builders/editable.py", line 37, in _setup_build
shutil.move(
File "$HOME/.miniconda3/envs/my-conda-env/lib/python3.8/shutil.py", line 794, in move
copy_function(src, real_dst)
File "$HOME/.miniconda3/envs/my-conda-env/lib/python3.8/shutil.py", line 426, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "$HOME/.miniconda3/envs/my-conda-env/lib/python3.8/shutil.py", line 259, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
ERROR: InvocationError for command $HOME/.miniconda3/envs/my-conda-env/bin/poetry install -v (exited with code 1)
ERROR: invocation failed (exit code 1)
✖ FAIL isort in 9.228 seconds
✔ OK mypy in 10.079 seconds
___________________________________ summary ____________________________________
ERROR: isort: parallel child exit code 1
mypy: commands succeeded
在堆栈跟踪中{em>上方中明确指出了错误:[Errno 2] No such file or directory: '/path/to/package/pyproject.toml'
。显然,pyproject.toml
必须存在,否则mypy
测试失败。
如何实现在Tox中使用诗歌但可以并行运行测试环境?