Comments (8)
Amazing! Thanks so much for the update on this @cnuernber!
from libpython-clj.
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.
Relevant pr here
from libpython-clj.
@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.
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.
Is there a solution to get the require-python working yet?
from libpython-clj.
@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.
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)
- Cannot run the example in the tutorial in Cider with JDK 17 HOT 8
- process hanging in embeded mode on exception HOT 2
- from-import does not support "string"
- newbie: I get: `dir already refers to: #'clojure.repl/dir in namespace: user` HOT 2
- Newbie: Lein Clojure Windows Anaconda VSCode Cava REPL Returns (NoClassDefFoundError) HOT 5
- Create Python Module then Import Module and Call Function Inside Clojure? HOT 4
- Fix ubuntu version in dockerfiles HOT 6
- Consider releasing returned values from instance fns
- JDK-20 support HOT 3
- builtins/eval throws 'frame does not exist' HOT 2
- Unable to require libraries from within docker using conda HOT 6
- Failed to find a valid python library on MS-Windows with the official python distributions
- Extend CI coverage to all the mainstream architectures
- require-python missing functions with annotation HOT 3
- Make polyglot development easier by allow require-python to be path-informed HOT 1
- Data transformation pipelines? HOT 1
- NSWindow main thread error when trying to setup Gymnasium (openapi gym) HOT 5
- JVM crashes when requiring `libpython-clj2.require` on 64bit Raspberry Pi 4 HOT 1
- error of unhashable type HOT 15
- Ways to reduce probability of memory leaks? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libpython-clj.