Is there a recommended way how to handle Python de...
# general
r
Is there a recommended way how to handle Python dependencies that are version specific? For example
3rdparty/python/subprocess32
can only be installed on Python 2 but not on Python 3. In a non-pants world I would approach thus using “environment markers” but that does seem to be available in Pants out of the box. https://www.python.org/dev/peps/pep-0508/#environment-markers
h
Hey @rapid-apartment-37923, did you get a reply/solution to this? Sometimes things get lost in the slack stream. If not I’ll look into this.
r
@happy-kitchen-89482 thanks for asking! No reply yet to this question. I found a workaround for the immediate problem I had when asking this question by splitting a target into two, but the general question still stands.
m
@happy-kitchen-89482 We have a similar situation, in our case with Airflow; the python plugin is for py3<= and our dev team that works with Airflow is having trouble making it play nice with pants and is actually considering touching pants itself so that it works on py3. would that be advisable?
h
I’m not sure the issue is whether pants itself runs on py3? Can you describe your use case in more detail? Pants can build/test/run python3 code, regardless of the fact that it runs on py2. @rapid-apartment-37923’s issue, if I understood it correctly, is that you want certain dependencies to only exist in the context of a specific python version.
m
Let me ask the eng to clarify the needs as well, I'm honestly not entirely sure why we would need a py3 backed pants
h
So I ran into this exact problem myself. See here for solution in the pants repo itself, and discussion around it: https://github.com/pantsbuild/pants/pull/5847
Basically, Pants itself must (currently) run on python2, but it can build/run/whatever python3 code, as the interpreter it invokes is not related to the interpreter it runs on (which you should think of as a mere implementation detail).
The only tricky bit is if the code you want to run on python3 uses Pants as a library for some reason, because that’s not guaranteed to work.