What would be the simplest way to differentiate my...
# general
h
What would be the simplest way to differentiate my requirements based on Linux distro version? This as a feature isn’t supported in pip, unfortunately. I have a package with different C components for two different distros of Linux so would like to add a platform check (via a plugin) that would enable me to point the resolver at a different package name specific to that distro.
b
I'm not sure. If pip doesn't support it, pex and thus pants likely doesn't support it well either. You might need to create multiple lockfiles and then juggle between them, maybe with
if
statements in your BUILD files too. (If required, the BUILD files can use
env(...)
to read env vars https://www.pantsbuild.org/stable/reference/build-file-symbols/env, including those set in `.pants.bootstrap`: https://www.pantsbuild.org/stable/docs/using-pants/key-concepts/options#pantsbootstrap-file)
h
Okay that sounds doable then if I can set an env var in .pants.bootstrap based on the platform. May still be slightly messy hot swapping requirements files as we only use the one currently. Might there be a way to add an additional requirement in the same way? e.g.
if distro==a: add req-a; else add req-b
c
This isn't exactly what you asked but as a practical matter if it's "just" one native library that varies, the solution I often see taken is to include it in the wheel itself such as with https://github.com/pypa/auditwheel by way of https://cibuildwheel.pypa.io/en/stable/
h
Interesting I’ll take a look into those, thanks