You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[libpython-clj issue for Conda](https://github.com/clj-python/libpython-clj/issues/18)
17
+
18
+
19
+
20
+
## uv
21
+
22
+
When you are using the (awesome !) python package manager [uv](https://docs.astral.sh/uv/) we provide a nice integration, which allows to auto-mange
23
+
declarative python environments.
24
+
25
+
Assuming that you have 'uv' installed (it exists for Linux, Windows , Mac) you can specify and auto-setup a local python venv incl. python version by adding the following to `python.edn`
The versions specification takes the same values as in uv, so would allow ranges a swell, for examples. We suggest to use precise versions, if possible
37
+
38
+
Having this, on a call to `(py/initialize!)` a python venv will be created/updated to match the python version and the specified packages. This calls behind the scenes `uv sync` so the spec and the venv are "brought in sync".
39
+
40
+
Re-syncing can be as well called manually (while the Clojure repl runs), invoking directly `(libpython-clj2.python.uv/sync-python-setup!)`
41
+
42
+
### ux on Windows
43
+
44
+
On Windows we need to use:
45
+
`:python-executable ".venv/Scripts/python"`
46
+
47
+
as the python executable.
48
+
49
+
### Caveat
50
+
51
+
We have noticed that under Windows for some python versions `libpython-clj` does not setup the python library path correctly, resulting in python libraries not found using for example: `(py/import-module "xxx")`
52
+
53
+
This is visible by inspecting python `sys.path`, which should contain `.venv/` via `(py/run-simple-string "import sys; print(sys.path)")`,
Not sure, if the precise paths can change across python versions. They can be discovered by looking into `.venv` directory and see where precisely the "site-packages" directory is located.
0 commit comments