Has anyone used pants to build a python app that h...
# general
n
Has anyone used pants to build a python app that has a dependency on a java jar or lib? And is this a bad idea or are there existing patterns? It seems that pants will not complain if i add a jvm dependency into my python_library's BUILD file, and it will even compile the java dependency in the event of a pants run invocation on the python app. BUT then the python app doesnt have access to the right classpath (that i guess is dynamically generated by pants?).
a
how are you trying to invoke this java? i was wondering yesterday about deeper integration of the pants python interface with other languages here: https://pantsbuild.slack.com/archives/C0D7TNJHL/p1563409756043300 but i don't know of any canonical way to do this.
pants doesn't stop you from adding a dependency to anything during BUILD file parsing, but individual tasks may validate targets in different ways
👍 1
n
I have a python app that uses a library called py4j to allow access to Java objects in the JVM. So assuming you can set the correct classpath, it lets you instantiate an instance of a class and invoke methods on it (which is exactly what im trying to do). It works fine if i build the jar, then copy it to a resource folder and depend on that resource from the BUILD file of my python app. But i wonder if there's a better way!
a
sorry for not following up! i think this is a really interesting use case -- could you please file an issue at https://github.com/pantsbuild/pants/issues/new describing what you're currently doing (you can just copy/paste the slack message you just sent above), how you arrived at that process (very briefly), and anything you might like to improve about that process (so we can investigate if there's a better way!). this can be a very very brief ticket, those were just ideas for what to put inside it. this can be really open-ended -- opening a ticket allows discussion to continue