FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/static_submodules-test.c at trunk · python-emscripten/python · GitHub
python-emscripten
python
Repository navigation
Code
Issues
1
(1)
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
static_submodules-test.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (31 loc) · 1.14 KB
Breadcrumbs
python
/
static_submodules-test.c
Copy path
File metadata and controls
42 lines (31 loc) · 1.14 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include
<Python.h>
#include
<stdio.h>
PyMODINIT_FUNC
inittestmod_testsubmod
(
void
);
/*proto*/
int
main
(
void
) {
// Trace modules loading
//setenv("PYTHONVERBOSE", "1", 0);
// Load additional modules installed relative to current directory
setenv
(
"PYTHONPATH"
,
"."
,
0
);
Py_InitializeEx
(
0
);
//inittestmod_testsubmod();
static
struct
_inittab
builtins
[]
=
{
{
"testmod.testsubmod"
,
inittestmod_testsubmod
},
{
NULL
,
NULL
}
};
PyImport_ExtendInittab
(
builtins
);
PyRun_SimpleString
(
"import testmod.testsubmod; testmod.testsubmod.myputs()"
);
Py_Finalize
();
}
/*
cat <<'EOF' > testmod/testsubmod.pyx
cdef extern from "stdio.h":
int puts(const char *s);
def myputs():
puts("\n\nHELLOOOOOOOOOO\n\n");
EOF
cython testmod/testsubmod.pyx
sed -i -e 's|Py_InitModule4("\([^"]\+\)"|Py_InitModule4("testmod.\1"|' \
-e 's|^__Pyx_PyMODINIT_FUNC init|__Pyx_PyMODINIT_FUNC inittestmod_|' testmod/testsubmod.c
gcc -I../../Include -I.. testmod/testsubmod.c main.c ../libpython2.7.a -lm -ldl -lutil && ./a.out
See also https://mdqinc.com/blog/2011/08/statically-linking-python-with-cython-generated-modules-and-packages/
*/
Back
|
FazBrowse Home
|
New Git URL