有关 rsyscall 背后的概念和动机的更多细节,请阅读[[file:docs/conceptual.org][概念介绍]]。
请注意,rsyscall 的 Python API 使用了一些较新的 Python 3 特性:async/await 和类型注解。
如果你之前没有接触过这些,请先快速浏览[[file:docs/background.org][背景教程]]。
但如果你想要尝试,可以使用 Nix:
#+begin_src bash
git clone https://github.com/catern/rsyscall
cd rsyscall/python
nix-shell
python
#+end_src
或者你可以在虚拟环境中手动构建:
#+begin_src bash
git clone https://github.com/catern/rsyscall
cd rsyscall
python3 -m venv venv
. venv/bin/activate
pip install -U pip
cd c
autoreconf -fvi
./configure --prefix=$PWD/../venv
make install
cd ..
export LD_LIBRARY_PATH=$PWD/venv/lib
export PKG_CONFIG_PATH=$PWD/venv/lib/pkgconfig
pip install -e python/
python
#+end_src
In [2]: import rsyscall
In [3]: t = await rsyscall.local_process.fork()
In [4]: await t.stdout.write(await t.ptr("Hello world!\n"))
Hello world!
#+end_example