Thought this would be of interest to this group.
It’s been a feature speculated for a while by “faking” most of the marker environment.
I can’t see how it would work for some pathological sdists, but maybe in practice those aren’t important.
Relevant caveats from the docs.
However, uv does support resolving for alternate platforms and Python versions via the
--platform
and--python-version
command line arguments.For example, if you’re running uv on macOS, but want to resolve for Linux, you can run
uv pip compile --platform=linux requirements.in
to produce amanylinux2014
-compatible resolution.Similarly, if you’re running uv on Python 3.9, but want to resolve for Python 3.8, you can run
uv pip compile --python-version=3.8 requirements.in
to produce a Python 3.8-compatible resolution.The
--platform
and--python-version
arguments can be combined to produce a resolution for a specific platform and Python version, enabling users to generate multiple lockfiles for different environments from a single machine.N.B. Python’s environment markers expose far more information about the current machine than can be expressed by a simple
--platform
argument. For example, theplatform_version
marker on macOS includes the time at which the kernel was built, which can (in theory) be encoded in package requirements. uv’s resolver makes a best-effort attempt to generate a resolution that is compatible with any machine running on the target--platform
, which should be sufficient for most use cases, but may lose fidelity for complex package and platform combinations.