-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy2pyd.py
42 lines (32 loc) · 1.13 KB
/
py2pyd.py
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
#========================================
# author: changlong.zang
# mail: [email protected]
# date: Sat, 19 Sep 2015, 09:53:47
#========================================
import sys, re, os
import distutils.core, distutils.extension
import Cython.Build
#--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
def py2pyd(path):
'''
'''
os.chdir(path)
file_list = os.listdir(path)
for f in file_list:
if os.path.isdir(f):
continue
if not re.search('.py$', f):
continue
if re.match('setup.py', f):
continue
if re.match('__init__.py', f):
continue
if re.search('_rc.py', f):
continue
extensions = [distutils.extension.Extension(os.path.splitext(f)[0], [f], include_dirs=[])]
distutils.core.setup(name='pytopyd', ext_modules=Cython.Build.cythonize(extensions))
cpp_file = '{0}.c'.format(os.path.splitext(f)[0])
os.path.isfile(cpp_file) and os.remove(cpp_file)
if __name__ == '__main__':
path = os.getcwd()
py2pyd(path)