Fork me on GitHub

I believe I have asked this before but couldn't seem to find it from digging up the zulip logs. May I ask what ways are there to run python scripts from Clojure (backend)? I understand I can use or some java interop (?) (I recall someone might have mentioned there a new api to do so?), as well as graalvm and lib-pythonclj . I want to send quite a lot of (database) data to the python scripts, would passing the python script a large json work out alright? Would preferably like to keep it as a python script so that my friends working pick up Clojure and do interop


you could do something like, save the database data to a file (JSON maybe?) and then kick off a python script (from clojure or manually while testing) to read that JSON in and do whatever it needs to do

Franco Gasperino20:03:48

agree with cshep - use the file system as an async queue between applications.


Mmmm, I guess that does seem to be the best way :thinking_face: given the constraints. Just 2 questions - How should I call python from clojure - is there a better way than ? Would the step of saving as a file be necessary - would sending the entire json in the call be better?

Drew Verlee16:03:52

swap! just calls compare-and-set! until it's accepted right?


well, and repeating calls to your provided function each time, too.


I know you said no lein/boot... is there another way to run a clojure program / clojure server process?


clojure is a java library, all you used to need is the java vm + a jar with clojure in it (plus your source), now you need a dep manager because clojure.jar no longer comes with all its deps


that's why deps.edn / the clj cli tool came out


similarly clojurescript is a java library (using clojure) that outputs js


you can still run clojure without a dep manager, if you get a valid classpath

(ins)justin@abjection:~$ CLJCP=$(clj -Spath)
(ins)justin@abjection:~$ echo $CLJCP
(ins)justin@abjection:~$ java -cp $CLJCP clojure.main
Clojure 1.10.1
user=> (+ 1 1)


of course I used the package manager to get those deps into the .m2 cache


@U3ES97LAC When @U01SUNLPN58 said “clojure clj” he meant the Clojure CLI — not Leiningen or Boot. And, yes, it is another way to “run a clojure program / clojure server process”. We use the Clojure CLI at work — with 112K lines of Clojure — we don’t use Leiningen, and we don’t use Boot. Although we did in the past (`lein` from 2011-2015, boot from 2015-2018, CLI/`deps.edn` since 2018).