0.はじめに
原因の調査などは詳しくしていないが,解決策のメモ.
1.環境
- python 3.7.7
- poetry 1.0.3
2.現象
あるgit repoをpoetryでinstallするときに以下のエラーが起きた.
名前を適当にhogeという名前のレポとする.
(.venv) bash-3.2$ poetry update
Updating dependencies
Resolving dependencies... (10.2s)
Writing lock file
Package operations: 12 installs, 0 updates, 0 removals
- Installing hoge (0.0.1 acd565a)
[EnvCommandError]
Command ['/Users/kazeto/Works/aaa/.venv/bin/pip', 'install', '--no-deps', '-U', '-e', '/Users/kazeto/Works/aaa/.venv/src/hoge'] errored with the following return code 1, and output:
Obtaining file:///Users/kazeto/Works/aaa/.venv/src/hoge
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing wheel metadata: started
Preparing wheel metadata: finished with status 'done'
Installing collected packages: hoge
Running setup.py develop for hoge
ERROR: Command errored out with exit status 1:
command: /Users/kazeto/Works/aaa/.venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"'; __file__='"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
cwd: /Users/kazeto/Works/aaa/.venv/src/hoge/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/kazeto/Works/aaa/.venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"'; __file__='"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.
ちなみにエラーログの通りログを確認しようとしてエラーが起きたコードを手で実行したところ普通に入ってしまい原因がよくわからなかった...
(.venv) bash-3.2$ /Users/kazeto/Works/aaa/.venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"'; __file__='"'"'/Users/kazeto/Works/aaa/.venv/src/hoge/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(_le__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
running develop
running egg_info
creating hoge.egg-info
writing hoge.egg-info/PKG-INFO
writing dependency_links to hoge.egg-info/dependency_links.txt
writing top-level names to hoge.egg-info/top_level.txt
writing manifest file 'hoge.egg-info/SOURCES.txt'
reading manifest file 'hoge.egg-info/SOURCES.txt'
writing manifest file 'hoge.egg-info/SOURCES.txt'
running build_ext
Creating /Users/kazeto/Works/aaa/.venv/lib/python3.7/site-packages/hoge.egg-link (link to .)
Adding hoge 0.0.1 to easy-install.pth file
Installed
そして.venvの中を見てもsetuptoolsが入っていた.
3.解決策
とりあえずinstallするgit repo(ここではhoge)のpyproject.tomlで,build-systemにsetuptoolsを追加するとinstallできるようになった.
修正前
[build-system]
requires = ["poetry>=1.00"]
build-backend = "poetry.masonry.api"
修正後
[build-system]
requires = ["poetry>=1.00", "setuptools"]
build-backend = "poetry.masonry.api"
追記
今更だがissue見つけた.
poetryのversionは違うがこれだろう.
https://github.com/python-poetry/poetry/issues/3001