hiya folks! does anyone have a good resource for p...
# pex
w
hiya folks! does anyone have a good resource for pex platform strings? a little new to building pex files and while i can create them witthout specifying platforms in the appropriate environments, when i try to specify the suite of platforms i want to be compatible with i run into a whole lot of dependency hell (specified versions not available for the platform i specified). Would love a way to call a utility in my environment that would return hte appropriate pex stringn
h
It’s a tricky topic..I started documenting it at https://www.pantsbuild.org/v1.29/docs/python-platforms but didn’t finish because it’s hard to document in a way that’s correct and still understandable It’s one of my TODOs to finish that.
Would love a way to call a utility in my environment that would return hte appropriate pex stringn
What do you mean? Like a utility to run in the desired platform and get back the proper platform string to use?
w
a utility to run in the desired platform and get back the proper platform string to use?
yes!
im not entirely clear on the nuances of the abi and python types (cp, pp, jp) and the pex docs are not very helpful
h
If you haven’t yet, I recommend running Pex directly when iterating on this. While the Pex docs are really really stale (we don’t have the keys to the site anymore 😶), the error messages for invalid strings are more informative.
pipx install pex
then
pex --platform=manylinux2014_x86_64-cp-38-cp38 cryptography -o foo.pex
, for example Let me check on that utility. I think
setuptools
has a function to get all supported platform strings, iirc
I thought this would do the trick, but it doesn’t. Sad.
Copy code
$ pex packaging 
>>> [str(x) for x in tags.compatible_tags()]
It says that
x.abi
is
'none'
for everything, even though it should include values like
abi3
and
cp38
e
The utility is Pex itself. A bit hidden, but, for example, on any given machine just:
Copy code
$ curl -sSL <https://github.com/pantsbuild/pex/releases/download/v2.1.15/pex> -O
$ /path/to/python/of/interest pex --help
If you read the help for
--platform
the current platform string is noted. For example, on my machine, some of those are:
Copy code
$ for py in python{2.7,3.{6,7,8}} pypy; do $py pex --help | grep -A2 "current interpreter at"; done
                        current interpreter at /usr/bin/python2.7 the full
                        platform string is manylinux2014_x86_64-cp-27-cp27mu.
                        To find out more, try `pex --platform explain`.
                        current interpreter at /usr/bin/python3.6 the full
                        platform string is manylinux2014_x86_64-cp-36-cp36m.
                        To find out more, try `pex --platform explain`.
                        current interpreter at /usr/bin/python3.7 the full
                        platform string is manylinux2014_x86_64-cp-37-cp37m.
                        To find out more, try `pex --platform explain`.
                        current interpreter at /usr/bin/python3.8 the full
                        platform string is manylinux2014_x86_64-cp-38-cp38. To
                        find out more, try `pex --platform explain`.
                        current interpreter at /opt/pypy/bin/pypy the full
                        platform string is
                        manylinux2014_x86_64-pp-273-pypy_73. To find out more,
w
oh nice!
e
Do you have a custom wheelhouse you point Pex at with --index or --find-links?
If so there is a potential complication, if not and you just use pypi or a mirror you are good to go.
w
this was literally my first attempt to build a pex binary
so probably not
e
OK
I have the desire to break up the Pex CLI into subcommands, with the default being "build". At that point it will be easy to make this more sane and just say ~
pex platform
or
pex platform --list
but until then this is the compromise.
💯 2