What is the recommended way to put compiled code i...
# general
g
What is the recommended way to put compiled code in a pex using pants, take for example: psycopg2
f
if you use
psycopg2-binary
you can just add it as a requirement like anything else
g
Psycopg specifically recommends not using binary in production, but instead compiling from source.
Also, in my particular case, I'm trying to put turbulette in my pex, which has a dependency 4 layers deep on the compiled versiion of psycopg, and I've been unable to add in the binary version.
f
then i think the only way is to build psycopg in something resembling the target platform
what's your target platform?
g
Everything
😄 2
f
then you'll need to build wheels for everything
g
So, I plan on just using my CI pipeline to do the building, but how do I get this into pants to start with?
Or do I just need the build and runtime deps on my host system prior to running pants?
f
same way as normal, you just add
psycopg2
as a dep, but you'll have to install the system deps on the host
yeah
g
In which case, I would build a docker image with the buildtime deps, and let pants / pex gather my runtime deps.
f
under the hood, pex calls pip (which it vendors in), which calls setup.py
g
Sound about right?
f
yep
g
Not ideal, but I'll work with it. Thanks!
f
welcome to compiled code and python
g
I love Python as a language, but it is so difficult to package and distribute code.
f
for pure python stuff it's pretty easy
but you have to keep an eye on your dependency chain
for linux images you should use these as bases: https://github.com/pypa/manylinux
you can go with the 2014 series these days pretty safely
these contain old versions of linux system libs, so things should be forward compatible