Is it possible to build a pex that includes an sdi...
# general
p
Is it possible to build a pex that includes an sdist for one package instead of a wheel? The package I'm fighting with is
python-ldap
. The wheel ends up with the
linux_x86_64
platform tag (not with
manylinux*
because it links against
libldap
which is not one of the allowed libs for
manylinux*
. For
python-ldap
that is problematic because every distro and distro version seems to have a different version of
libldap
, so I can't reuse the pex anywhere except on the distro version I used to build it. So, it would be great if I could create a pex that includes an sdist instead of a wheel whenever the platform tag is too generic. That would require pex to build the wheel when the pex is first used instead of when building the pex. Is that possible? More details in 🧵.
✅ 1
To test this outside of pants, I did
pex python-ldap --interpreter-constraint 'CPython==3.7.*' -o ldap.pex
on an ubuntu 20.04 host, and then ran
./ldap.pex -c 'import ldap'
on that host and on an old CentOS 7 host. On the CentOS 7 host, it gives a big
ImportError: libldap-2.5.so.0: cannot open shared object file: No such file or directory
because the
libldap
versions are different making the pex very unportable.
Another method might be to build the wheel on each of the target distros+versions (which sounds painful), and then somehow embed all of the built wheels in my pex. But, I can't find any way to change the platform tag so that pip or pex+pip can figure out which wheel to use.
f
I don't believe pex supports it given this comment: https://github.com/pex-tool/pex/issues/645#issuecomment-458681114 > The main design goal of pex is to create a hermetic pre-built executable. As such, including sdists inside the pex that are platform-specific and require building on each platform like pendulum would violate this goal and is an intentional non-feature of built pexes.
This issue is not really a Pants issue, but rather a Pex issue.
p
Yes. Bummer. I looked for a comment like that. Thanks for verifying. I suppose I could put a question like this in #C046T6TA4 next time. Thank you for helping look that up.
Now I'm looking into using
docker_environment
to build a smaller
pex_binary
that only has
python-ldap
in it so that I can have multiple distro-specific pexes alongside one general purpose PEX that excludes that dep (
extra_build_args=["--exclude", "python-ldap"]
).