Support linehaul data in user agent
Description
Linehaul is a feature by PyPI that allows querying statistics about the used platforms through BigQuery (https://github.com/pypi/linehaul-cloud-function). Clients query the host environment and attach this information as a JSON blob in the User Agent header. This information is extremely valuable to understand usage across platforms, Python versions, CI and what components can or can't assume to present on a target system. https://github.com/pypi/linehaul-cloud-function/blob/main/linehaul/ua/datastructures.py provides an overview over the datastructure. Both pip and uv send linehaul data, but it would be valuable to increase the coverage.
Use case/motivation
No response
Related issues
https://github.com/pypa/hatch/issues/1816
Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [x] I agree to follow the Python Software Foundation's Code of Conduct
I clicked both but don't immediately see what needs doing. Can you please give a TL;DR of what should be changed?
This is the pip code for implementing linehaul, it shows how to build the user agent with the linehaul JSON dump: https://github.com/pypa/pip/blob/2e4cf333e1c878696d08f7b43668e73e13fd81ed/src/pip/_internal/network/session.py#L108-L207
There's also uv implementation of just the linehaul part of the user agent, naturally less relevant as it's in Rust: https://github.com/astral-sh/uv/blob/e96354a6dd00d8362bb33388ca0466cef9517e08/crates/uv-client/src/linehaul.rs#L1-L147
We can definitely get this out in our next patch release for 1.16.2, 1.16.1 was focused on immediate regression fixes.