Code Monkey home page Code Monkey logo

Comments (8)

metasoarous avatar metasoarous commented on July 19, 2024 2

Amazing! Thanks so much for the update on this @cnuernber!

from libpython-clj.

gigasquid avatar gigasquid commented on July 19, 2024 1

Here is a minimal project to reproduce https://github.com/gigasquid/libpython-clj-uberjar-test

and the error

08:27 $ java -jar target/libpython-clj-uberjar-test-0.1.0-SNAPSHOT-standalone.jar
Feb 25, 2020 8:27:35 AM clojure.tools.logging$eval136$fn__139 invoke
INFO: Executing python initialize with options:{:python-executable nil, :program-name nil, :python-home nil, :library-path nil}
Feb 25, 2020 8:27:35 AM clojure.tools.logging$eval136$fn__139 invoke
INFO: Detecting startup-info for Python executable: 
Feb 25, 2020 8:27:35 AM clojure.tools.logging$eval136$fn__139 invoke
INFO: Startup info detected: {:python-home "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7", :lib-version "3.7", :libname "python3.7m", :java-library-path-addendum "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib"}
Feb 25, 2020 8:27:35 AM clojure.tools.logging$eval136$fn__139 invoke
INFO: Setting java library path: /usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib:/Users/cmeier/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Feb 25, 2020 8:27:35 AM clojure.tools.logging$eval136$fn__139 invoke
INFO: Reference thread starting
Feb 25, 2020 8:27:35 AM clojure.tools.logging$eval136$fn__139 invoke
INFO: Library python3.7m found at [:java-library-path "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib"]
Feb 25, 2020 8:27:35 AM clojure.tools.logging$eval136$fn__139 invoke
INFO: Library c found at [:system "c"]
Exception in thread "main" java.lang.ExceptionInInitializerError
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at clojure.lang.RT.classForName(RT.java:2207)
	at clojure.lang.RT.classForName(RT.java:2216)
	at clojure.lang.RT.loadClassForName(RT.java:2235)
	at clojure.lang.RT.load(RT.java:453)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.core$require.doInvoke(core.clj:6007)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at libpython_clj_uberjar_test.core$loading__6706__auto____171.invoke(core.clj:1)
	at libpython_clj_uberjar_test.core__init.load(Unknown Source)
	at libpython_clj_uberjar_test.core__init.<clinit>(Unknown Source)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at clojure.lang.RT.classForName(RT.java:2207)
	at clojure.lang.RT.classForName(RT.java:2216)
	at clojure.lang.RT.loadClassForName(RT.java:2235)
	at clojure.lang.RT.load(RT.java:453)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.lang.Var.invoke(Var.java:384)
	at clojure.lang.Util.loadWithClass(Util.java:250)
	at libpython_clj_uberjar_test.core.<clinit>(Unknown Source)
Caused by: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.MultiFn
	at libpython_clj.require__init.load(Unknown Source)
	at libpython_clj.require__init.<clinit>(Unknown Source)
	... 42 more

from libpython-clj.

joinr avatar joinr commented on July 19, 2024 1

Relevant pr here

from libpython-clj.

cnuernber avatar cnuernber commented on July 19, 2024 1

@gigasquid @metasoarous @joinr @zendevil - There is now static code generation so you can generate AOT-safe clojure namespaces once and then require them as needed. They do not need python even at require time but only at runtime when the actual var is called the first time.

from libpython-clj.

metasoarous avatar metasoarous commented on July 19, 2024

Just wanted to chime in that I had to jump through the hoops in the libpython-clj-uberjar-test repo to get libpython-clj to AOT compile for use in Clojupyter, but was ultimately able to get it working. Hope to be able to make this public soon for people's reference.

Interested to hear whether folks think there's a way to fix this directly in libpython-clj.

Thanks!

from libpython-clj.

zendevil avatar zendevil commented on July 19, 2024

Is there a solution to get the require-python working yet?

from libpython-clj.

joinr avatar joinr commented on July 19, 2024

@zendevil Did you try using a shim class like in my PR files here? That should get an AOT'd uberjar working by essentially avoiding AOT compiling all the python interop stuff, and late-binding everything as you would in the REPL. So there isn't any deep AOT compilation of the classes, rather a tiny one that loads clojure enough to resolve the namespace (clj file) that it can invoke, and provides an entry point to do this (basically bypass most of the AOT machinery). I do not know what @metasoarous ended up doing with his situation with Clojupyter though.

from libpython-clj.

metasoarous avatar metasoarous commented on July 19, 2024

I more or less cribbed your solution exactly @joinr. Again, thanks for forging that trail!

@zendevil If you want to look at another example in context, please see https://github.com/pol-is/analysis

from libpython-clj.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.