FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-for-android/cythonizer.py at python3 · BetaMatrix/python-for-android · GitHub
BetaMatrix
/
python-for-android
Public
forked from
kivy/python-for-android
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-for-android
/
cythonizer.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
54 lines (48 loc) · 3.41 KB
Breadcrumbs
python-for-android
/
cythonizer.py
Copy path
File metadata and controls
54 lines (48 loc) · 3.41 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
43
44
45
46
47
48
49
50
51
52
53
54
import
os
,
sys
class
cythonizer
():
def
__init__
(
self
,
android_ndk
=
os
.
environ
[
"ANDROIDNDK"
],
android_api
=
os
.
environ
[
"ANDROIDAPI"
],
python_for_android
=
os
.
path
.
join
(
os
.
path
.
split
(
os
.
path
.
realpath
(
__file__
))[
0
])
):
self
.
android_ndk
=
android_ndk
self
.
android_api
=
android_api
self
.
py_for_a
=
python_for_android
for
path
in
[
self
.
android_ndk
,
self
.
py_for_a
]:
if
not
os
.
path
.
isdir
(
path
):
print
"!! Haven't found path:"
,
repr
(
path
)
sys
.
exit
()
self
.
gcc
=
"%s/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc"
%
(
self
.
android_ndk
)
self
.
sysroot
=
"%s/platforms/android-%s/arch-arm"
%
(
self
.
android_ndk
,
self
.
android_api
)
self
.
a_incl
=
"-I%s/platforms/android-%s/arch-arm/usr/include"
%
(
self
.
android_ndk
,
self
.
android_api
)
self
.
p_incl
=
"-I%s/build/python-install/include/python2.7"
%
(
self
.
py_for_a
)
self
.
libs
=
"-L%s/build/libs"
%
(
self
.
py_for_a
)
self
.
p_libs
=
"-L%s/build/python-install/lib"
%
(
self
.
py_for_a
)
self
.
a_libs
=
"-L%s/platforms/android-%s/arch-arm/usr/lib"
%
(
self
.
android_ndk
,
self
.
android_api
)
def
make_o
(
self
,
c_file
,
o_file
):
command
=
"""%s -mandroid -fomit-frame-pointer -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC --sysroot %s %s %s -c database.c -o database.o"""
%
(
self
.
gcc
,
self
.
sysroot
,
self
.
a_incl
,
self
.
p_incl
)
print
command
def
make_so
(
self
,
o_file
,
so_file
=
None
):
if
so_file
==
None
:
so_file
=
os
.
path
.
splitext
(
os
.
path
.
realpath
(
o_file
))[
0
]
+
".so"
command
=
"""%s -shared -O3 -mandroid -fomit-frame-pointer --sysroot %s -lm -lGLESv2 -lpython2.7 %s %s %s %s -o %s """
%
(
self
.
gcc
,
self
.
sysroot
,
self
.
libs
,
self
.
p_libs
,
self
.
a_libs
,
o_file
,
so_file
)
print
command
def
make
(
self
,
py_pyx
):
for
root
,
dirs
,
files
in
os
.
walk
(
directory
):
for
file
in
files
:
if
file
.
endswith
(
'.py'
)
or
file
.
endswith
(
'.pyx'
):
print
file
self
.
make_o
(
py_pyx
)
self
.
make_so
(
py_pyx
)
if
__name__
==
"__main__"
:
c
=
cythonizer
()
c
.
make
(
"test.py"
)
Back
|
FazBrowse Home
|
New Git URL