Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why pip freeze returns some "gibberish" instead of package==VERSION?

Here is what I did:

❯ pip freeze
aiohttp @ file:///Users/aiven/Library/Caches/pypoetry/artifacts/50/32/0b/b64b02b6cefa4c089d84ab9edf6f0d960ca26cfbe57fe0e693a00912da/aiohttp-3.6.2-py3-none-any.whl
async-timeout @ file:///Users/aiven/Library/Caches/pypoetry/artifacts/0d/5d/3e/630122e534c1b25e36c3142597c4b0b2e9d3f2e0a9cea9f10ac219f9a7/async_timeout-3.0.1-py3-none-any.whl
attrs @ file:///Users/aiven/Library/Caches/pypoetry/artifacts/7f/e7/44/32ca3c400bb4d8a2f1a91d1d3f22bbaee2f4727a037aad898fbf5d36ce/attrs-20.2.0-py2.py3-none-any.whl
chardet @ file:///Users/aiven/Library/Caches/pypoetry/artifacts/c2/02/35/0d93b80c730b360c5e3d9bdc1b8d1929dbd784ffa8e3db025c14c045e4/chardet-3.0.4-py2.py3-none-any.whl
...

Version of pip:

❯ pip -V
pip 20.2.3 from /Users/aiven/projects/foobar/venv/lib/python3.8/site-packages/pip (python 3.8)

I expected something like this:

> pip freeze
foo==1.1.1
bar==0.2.1

pip freeze -h wasn't very helpful...

For context: I installed packages into virtualenv using poetry.

like image 228
aiven Avatar asked Oct 04 '20 12:10

aiven


1 Answers

This seems to come from the changes to support PEP 610. In particular refer to the Freezing an environment section. The notion of what "freezing" entails has been expanded to include preserving direct url sources for packages that were installed with direct origins.

Poetry, with 1.1.0 has introduced a new installer that now handles discovery and download of artifacts for dependencies. This is different to the behaviour in 1.0.10 which simply let pip handle discover and download of required artifacts (wheels). This means that, now packages are installed using direct URL origins. This causes pip freeze to use direct reference format as specified in PEP 508 (eg: package @ file://../package.whl). For those interested, the url in question will be saved in <package>-<version>.dist-info/direct_url.json in the virtual env's site directory.

You can get the old format output (not sure if this will change in the future), using the following command.

pip --disable-pip-version-check list --format=freeze
like image 198
abn Avatar answered Oct 05 '22 13:10

abn