Skip to content

Commit e72eeda

Browse files
committed
Adding back in java library path shenanigans
1 parent 8760054 commit e72eeda

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:url "http://www.eclipse.org/legal/epl-v10.html"}
66
:dependencies [[org.clojure/clojure "1.10.2" :scope "provided"]
77
[camel-snake-kebab "0.4.0"]
8-
[cnuernber/dtype-next "6.07"]
8+
[cnuernber/dtype-next "6.08"]
99
[net.java.dev.jna/jna "5.7.0"]
1010
[org.clojure/data.json "1.0.0"]]
1111
:profiles {:dev {:dependencies [[criterium "0.4.5"]

scripts/conda-repl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ source activate pyclj
77
export LD_LIBRARY_PATH="$(python3-config --prefix)/lib"
88

99
lein update-in :dependencies conj \[nrepl\ \"0.6.0\"\]\
10-
-- update-in :plugins conj \[cider/cider-nrepl\ \"0.22.4\"\]\
10+
-- update-in :plugins conj \[cider/cider-nrepl\ \"0.25.5\"\]\
1111
-- repl :headless :host localhost
12-

scripts/py38-repl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22

33
lein update-in :dependencies conj \[nrepl\ \"0.6.0\"\]\
4-
-- update-in :plugins conj \[cider/cider-nrepl\ \"0.22.4\"\]\
4+
-- update-in :plugins conj \[cider/cider-nrepl\ \"0.25.5\"\]\
55
-- repl :headless :host localhost
6-

src/libpython_clj2/python.clj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ user> (py/py. np linspace 2 3 :num 10)
7272
(= 1 (py-ffi/Py_IsInitialized)))
7373
(let [info (py-info/detect-startup-info options)
7474
_ (log/infof "Startup info %s" info)
75+
_ (when-let [lib-path (:java-library-path-addendum
76+
options (:java-library-path-addendum info))]
77+
(log/infof "Prefixing java library path: %s" lib-path)
78+
(py-ffi/append-java-library-path! lib-path))
7579
libname (->> (concat (when library-path [library-path]) (:libnames info))
7680
(dechunk-map identity)
7781
(filter #(try
@@ -86,7 +90,10 @@ user> (py/py. np linspace 2 3 :num 10)
8690
libname (:python-home info)
8791
(assoc options
8892
:program-name (:program-name options (:executable info))
89-
:python-home (:python-home options (:python-home info))))
93+
:python-home (:python-home options (:python-home info))
94+
:java-library-path-addendum (:java-library-path-addendum
95+
options
96+
(:java-library-path-addendum info))))
9097

9198
(when-not (nil? windows-anaconda-activate-bat)
9299
(win/setup-windows-conda! windows-anaconda-activate-bat

src/libpython_clj2/python/ffi.clj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,16 @@ Each call must be matched with PyGILState_Release"}
531531
@format-exc-pyfn*)
532532

533533

534+
(defn append-java-library-path!
535+
[new-search-path]
536+
(let [existing-paths (-> (System/getProperty "java.library.path")
537+
(s/split #":"))]
538+
(when-not (contains? (set existing-paths) new-search-path)
539+
(let [new-path-str (s/join ":" (concat [new-search-path]
540+
existing-paths))]
541+
(System/setProperty "java.library.path" new-path-str)))))
542+
543+
534544
(defn initialize!
535545
[libpath python-home & [{:keys [signals? program-name python-home]
536546
:or {signals? true

src/libpython_clj2/python/info.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ print(json.dumps(
7373

7474

7575
(defn java-library-path-addendum
76-
[system-info & [{:keys [python-home]}]]
76+
[python-home]
7777
(when python-home
7878
(-> (Paths/get python-home
7979
(into-array String ["lib"]))
@@ -87,7 +87,7 @@ print(json.dumps(
8787
(log/info "Detecting startup info"))
8888
(let [system-info (find-python-info options)
8989
python-home (find-python-home system-info options)
90-
java-lib-path (java-library-path-addendum system-info options)
90+
java-lib-path (java-library-path-addendum python-home)
9191
[ver-maj ver-med _ver-min] (:version system-info)
9292
lib-version (format "%s.%s" ver-maj ver-med)
9393
libname (or library-path

0 commit comments

Comments
 (0)