由于Poetry中的requiremtns.txt个文件很难阅读,所以我try 编写一个简单的脚本来创建requiremtns.txt个文件,同时在它旁边创建一个更易于阅读的文件.一个Fitting Porey命令是:
~$ poetry show
好的……所以我启动我的子流程来执行以下代码:
if __name__ == '__main__':
PROJECT_DIR = Path(__file__).parent
# CMD
package_list = subprocess.run(['poetry', 'show'], cwd=PROJECT_DIR, encoding='utf_8', capture_output=True)
# Powershell
# package_list = subprocess.run(['powershell.exe', '-Command', 'poetry', 'show'], cwd=PROJECT_DIR, encoding='utf_8', capture_output=True)
print(package_list.stdout)
唯一的问题是,我得到了这个"删减"的内容:
alabaster 0.7.16 A light, configurable Sphin...
argon2-cffi 23.1.0 Argon2 for Python
argon2-cffi-bindings 21.2.0 Low-level CFFI bindings for...
asgiref 3.7.2 ASGI specs, helper code, an...
attrs 23.2.0 Classes Without Boilerplate
autopep8 2.0.4 A tool that automatically f...
babel 2.14.0 Internationalization utilities
certifi 2023.11.17 Python package for providin...
cffi 1.16.0 Foreign Function Interface ...
charset-normalizer 3.3.2 The Real First Universal Ch...
colorama 0.4.6 Cross-platform colored term...
concurrent-log-handler 0.9.25 RotatingFileHandler replace...
cryptography 41.0.7 cryptography is a package w...
django 5.0.1 A high-level Python web fra...
django-cors-headers 4.3.1 django-cors-headers is a Dj...
django-cprofile-middleware 1.0.5 Easily add cProfile profili...
django-rest-knox 4.2.0 Authentication for django r...
django-silk 5.1.0 Silky smooth profiling for ...
django-stubs 4.2.7 Mypy stubs for Django
django-stubs-ext 4.2.7 Monkey-patching and extensi...
djangorestframework 3.14.0 Web APIs for Django, made e...
djangorestframework-dataclasses 1.3.1 A dataclasses serializer fo...
djangorestframework-stubs 3.14.5 PEP-484 stubs for django-re...
docutils 0.20.1 Docutils -- Python Document...
drf-spectacular 0.27.1 Sane and flexible OpenAPI 3...
正如您所看到的,我已经try 使用PowerShell,因为我认为这是一个CMD问题,但结果保持不变.我还try 将stdout
直接重新路由到一个文件中.还是老样子.我也try 了无缓冲版本(bufsize=0
),仍然是一样的…
Now the question:我需要做什么,才能获得"完整"文本,就像你在终端输入poetry show
得到的一样?
更新
我现在已经在Ubuntu操作系统上try 过了.结果是相同的,因此这是特定于NOT个Windows的.