Skip to content

Commit ed2398c

Browse files
committed
Add initial Python example, remove cargo config
1 parent 7eab5ed commit ed2398c

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

python/build.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
PFOLDER=~/github/python-cmake-buildsystem/Python-3.9.17
2+
PINCLUDES="-I${PFOLDER}/Include -I${PFOLDER}/../.build/bin"
3+
PLIBS=${PFOLDER}/../.build/lib
4+
P=${PLIBS}/libpython3.9.a
5+
6+
#set -x
7+
gcc -O2 -static -o python_tinykvm \
8+
-I. ${PINCLUDES} \
9+
-L${PLIBS} \
10+
python.c \
11+
-lpython3.9 \
12+
-lcrypto \
13+
-lm -lpthread -ldl -lutil -lrt
14+
15+
export PYTHONPATH="$PFOLDER/../.build/lib/python3.9"
16+
export PYTHONHOME="$PWD"
17+
18+
./python_tinykvm

python/python.c

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#define PY_SSIZE_T_CLEAN
2+
#include <Python.h>
3+
#include "../kvm_api.h"
4+
5+
int main(int argc, char** argv)
6+
{
7+
Py_Initialize();
8+
PyRun_SimpleString("print('Hello Python World')");
9+
10+
if (IS_LINUX_MAIN()) {
11+
Py_Finalize();
12+
return 0;
13+
}
14+
15+
while (true) {
16+
struct backend_request req;
17+
wait_for_requests_paused(&req);
18+
19+
backend_response_str(200, "text/plain", "Hello Python World\n");
20+
}
21+
Py_Finalize();
22+
}

rust/static/.cargo/config

-2
This file was deleted.

0 commit comments

Comments
 (0)