pypa / wheel

The official binary distribution format for Python
MIT License
505 stars 151 forks source link

[FeatureRequest] add wheel info subcommand #639

Open yjqg6666 opened 1 month ago

yjqg6666 commented 1 month ago

Add wheel info [./path/to/file.whl / package name from pypi] to show wheel package metadata.

agronholm commented 2 weeks ago

I could be persuaded to add such a command to be used with local wheel files, but what would it actually show? This request is kind of light on details.

yjqg6666 commented 2 weeks ago

For example, mitmproxy package, wheel info requires mitmproxy could show the "Requires-Dist:" values of the unpacked file mitmproxy-11.0.0.dist-info/METADATA via wheel unpack mitmproxy-<latest-version>-py3-none-any.whl, the metadata files should be download automatically and unpacked somewhere, or query the remote server like pypi.org if such an API could be provided. wheel info all could show all the content of the unpacked METADATA file.

agronholm commented 2 weeks ago

What is the practical use case for this? Just so you know, I'm not going to make wheel do any networking operations.

yjqg6666 commented 2 weeks ago

The package manager tools for OS, like apt/yum/dnf/pkg, have the similar feature. apt/yum/pkg info .

agronholm commented 2 weeks ago

pip show <package> already does this for installed packages, and there are online tools like libraries.io that let you see the dependencies of any package on the PyPI. I'm asking what practical need you have for wheel to show this information on a wheel file that hasn't been installed?

yjqg6666 commented 2 weeks ago

What is the practical use case for this? Just so you know, I'm not going to make wheel do any networking operations.

Like check the dependencies before installing it for porting the package to BSD OS.

If no networking operations, local files are ok.

pip show will not show the version ranges of dependencies.

yjqg6666 commented 2 weeks ago

$ pip show mitmproxy

Requires: aioquic, asgiref, Brotli, certifi, cryptography, flask, h11, h2, hyperframe, kaitaistruct, ldap3, mitmproxy-rs, msgpack, passlib, protobuf, publicsuffix2, pyOpenSSL, pyparsing, pyperclip, ruamel.yaml, sortedcontainers, tornado, urwid, wsproto, zstandard

$ cat METADATA

... Requires-Dist: aioquic <=1.2.0,>=1.1.0 Requires-Dist: asgiref <=3.8.1,>=3.2.10 Requires-Dist: Brotli <=1.1.0,>=1.0 Requires-Dist: certifi >=2019.9.11 Requires-Dist: cryptography <43.1,>=42.0 Requires-Dist: flask <=3.0.3,>=3.0 Requires-Dist: h11 <=0.14.0,>=0.11 Requires-Dist: h2 <=4.1.0,>=4.1 Requires-Dist: hyperframe <=6.0.1,>=6.0 Requires-Dist: kaitaistruct <=0.10,>=0.10 ...

Submit an issue to pip project?

agronholm commented 2 weeks ago

Alright, I'll take this into consideration. But yes, it's strange that pip show doesn't show the versions, or even extras.

Meanwhile, could you draft a sample output for wheel info?

yjqg6666 commented 2 weeks ago

pip show <package> already does this for installed packages, and there are online tools like libraries.io that let you see the dependencies of any package on the PyPI.

Thanks for the info.

yjqg6666 commented 2 weeks ago

$ cat METADATA

Name: mitmproxy Version: 11.0.0 Summary: An interactive, SSL/TLS-capable intercepting proxy for HTTP/1, HTTP/2, and WebSockets. Author-email: Aldo Cortesi aldo@corte.si Project-URL: Homepage, https://mitmproxy.org Project-URL: Source, https://github.com/mitmproxy/mitmproxy/ Project-URL: Documentation, https://docs.mitmproxy.org/stable/ Project-URL: Issues, https://github.com/mitmproxy/mitmproxy/issues Classifier: License :: OSI Approved :: MIT License Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console :: Curses Classifier: Operating System :: MacOS Classifier: Operating System :: POSIX Classifier: Operating System :: Microsoft :: Windows Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Topic :: Software Development :: Testing Classifier: Typing :: Typed

Requires-Python: >=3.10 Requires-Dist: aioquic <=1.2.0,>=1.1.0 Requires-Dist: asgiref <=3.8.1,>=3.2.10 Requires-Dist: typing-extensions <=4.11.0,>=4.3 ; python_version < "3.11" Requires-Dist: pydivert <=2.1.0,>=2.0.3 ; sys_platform == "win32"

Provides-Extra: dev Requires-Dist: click <=8.1.7,>=7.0 ; extra == 'dev' Requires-Dist: types-pyOpenSSL <=24.1.0.20240722,>=23.3.0.0 ; extra == 'dev'

agronholm commented 2 weeks ago

So you just want it to dump the metadata to console as-is?

agronholm commented 2 weeks ago

And not show, for example, the wheel version or generator from WHEEL?

yjqg6666 commented 2 weeks ago

$ wheel info all mitmproxy-xxx.whl

the content of the metadata file.

$ wheel info name xxx.whl the value of the name field

$wheel info require xxx.whl

aioquic <=1.2.0,>=1.1.0;asgiref <=3.8.1,>=3.2.10;typing-extensions <=4.11.0,>=4.3 ;

agronholm commented 2 weeks ago

I think the output of pip show is much more user friendly – it just needs to have all the information and not omit the version ranges

yjqg6666 commented 2 weeks ago

$ wheel info urls

Homepage, https://mitmproxy.org Source, https://github.com/mitmproxy/mitmproxy/ Documentation, https://docs.mitmproxy.org/stable/ Issues, https://github.com/mitmproxy/mitmproxy/issues

agronholm commented 2 weeks ago

I don't feel like the complication of subcommands is necessary here. Or do you see a pressing need for that?

yjqg6666 commented 2 weeks ago

wheel info xx.whl to show the full content. no subcommand is simpler.

yjqg6666 commented 2 weeks ago

In this case I'd prefer wheel meta xx.whl?