-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
61 lines (55 loc) · 1.94 KB
/
setup.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# @Author: Sun Xiaofan <sxf>
# @Date: 2016-11-14
# @Email: sunxfancy@gmail.com
# @Last modified by: sxf
# @Last modified time: 2016-11-15
# @License: MIT License
from setuptools import setup, find_packages
from distutils.command.build_py import build_py as _build_py
import zipfile, os
def zipdir(path, ziph):
# ziph is zipfile handle
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file))
class ZipFile(_build_py):
def run(self):
old_cur = os.getcwd()
for dir in os.listdir(os.path.join(old_cur, 'templates')):
now = os.path.join(old_cur, 'templates', dir)
if os.path.isdir(now) and dir != '.DS_Store':
os.chdir(now)
target_file = os.path.join('..', dir + '.zip')
with zipfile.ZipFile(target_file, 'w') as myzip:
zipdir('.', myzip)
print("Zip finished!")
os.chdir(old_cur)
_build_py.run(self)
setup(
name='codefactory', #名称
version='0.7.0', #版本
description="a native code builder using git, github service and cmake", #描述
keywords='codef code factory builder cmake github',
author='sunxfancy', #作者
author_email='sunxfancy@gmail.com', #作者邮箱
url='https://github.com/sunxfancy/codefactory', #作者链接
license='MIT',
packages=find_packages(exclude=['ez_setup', 'examples', 'autotest']),
zip_safe=True,
data_files=[(os.path.join('share', 'codefactory', 'templates'),
[os.path.join('templates','cpp.zip'), os.path.join('templates','cpplib.zip')])], # 原版正确的
install_requires=[ #需求的第三方模块
],
entry_points={
'console_scripts':[
'codef = codefactory.codef:cli'
]
},
cmdclass={
# 'install':ZipFile,
'zip':ZipFile,
}
)