forked from zclongpop123/py2pyd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
py2pyd.py
45 lines (33 loc) · 1.16 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
43
44
45
#========================================
# author: Changlong.Zang
# mail: [email protected]
# time: Mon Sep 04 15:49:59 2017
#========================================
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
module_name = os.path.splitext(f)[0]
extensions = [distutils.extension.Extension(module_name, [f])]
distutils.core.setup(name=module_name, ext_modules=Cython.Build.cythonize(extensions))
for ext in ('c', 'pyc'):
f = '{0}.{1}'.format(module_name, ext)
os.path.isfile(f) and os.remove(f)
if __name__ == '__main__':
py2pyd(os.getcwd())