Skip to content

Commit 8ca7a5f

Browse files
committed
Update docs
1 parent 4853d45 commit 8ca7a5f

4 files changed

Lines changed: 20 additions & 1 deletion

File tree

_docs_src/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ nav:
2424
- Auto-generating bindings: auto-gen-bindings.md
2525
- CLI Options: cli-options.md
2626
- Converting `pyobjects` to OCaml types: of-pyobject.md
27+
- Embedding Python source: embedding-python.md
2728
- Handling Tuples: tuples.md
2829
- Gotchas & Known Bugs: gotchas-bugs.md
2930
theme:

_docs_src/src/embedding-python.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Embedding Python Source Code
2+
3+
If you import modules in Python code, Python needs to be able to actually find these modules.
4+
5+
One way is to "install" the Python module you want with say, pip. E.g., `pip install whatever`.
6+
7+
If you're working on a Python module along with your OCaml code, you probably don't want to do this. Rather, you probably want to set the `PYTHONPATH` environment variable to the location of your Python modules. (You can find an example an detailed explanation of that in the [importing modules](https://github.com/mooreryan/ocaml_python_bindgen/tree/main/examples/importing_modules) example on GitHub.)
8+
9+
The third option is to embed the Python code directly into the generated OCaml module. The `--embed-python-source` CLI option lets you do this. Basically, you just provide the path to the Python module you want to embed to that option, and it will all work out for you. This way you don't have to have your user's worry about setting the `PYTHONPATH` properly.
10+
11+
To see it in action, check out the [example](https://github.com/mooreryan/ocaml_python_bindgen/tree/main/examples/embedding_python_source) on GitHub.
12+
13+

_docs_src/src/gotchas-bugs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Gotchas & Known Bugs
22

3-
Nothing to see here... O_o
3+
* You cannot bind Python properties or attributes that return `None`. So, `val f : t -> unit` will currently fail.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
# Embedding Python Source Code
22

3+
This example is pretty similar to the [quick start](https://github.com/mooreryan/ocaml_python_bindgen/tree/main/examples/quick_start) example.
4+
5+
This one shows you how to embed the Python code directly into the generated OCaml module. It will then be evaluated at run time.
6+
7+
To do this, you can use the `--embed-python-source` option. See this library's `dune` file for how to set it up.

0 commit comments

Comments
 (0)