-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
78 lines (67 loc) · 2.76 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# *_*coding:utf-8 *_*
# @Author : Reggie
# @Time : 2022/11/15 15:57
import glob
from os import path
from pathlib import Path
from Cython.Build import cythonize
from setuptools import setup, find_packages
from wheel.bdist_wheel import bdist_wheel
base = Path(__file__).parent
with open(base.joinpath("src/common_pygrpc/README.md"), encoding="utf-8") as f:
long_description = f.read()
# python setup.py sdist 打包成tar.gz的形式
# python setup.py bdist_wheel 打包成wheel格式
# 文件名:setuptools_myplugin.py
class MyPluginCommand(bdist_wheel):
"""Custom command to print a message."""
def egg2dist(self, egginfo_path, distinfo_path):
result = super().egg2dist(egginfo_path, distinfo_path)
for file in glob.glob("src/*/*pyi"):
f = Path(file)
d = Path(self.bdist_dir).joinpath(self.distribution.get_name()).joinpath(f"{f.name}")
print(f"copying {f} >>>>>>> {d}")
d.write_text(f.read_text(encoding="utf-8"), encoding="utf-8")
return result
def run(self):
super().run()
setup(
name="common_pygrpc",
version="1.0.1",
description="common python grpc service",
author="reggiepy",
author_email="reggiepy@foxmail.com",
url="https://github.com/reggiepy/common_pygrpc",
license="LICENSE",
# --------------------------------------- <<< 使用C 编译 -----------------------------------------
cmdclass={
'bdist_wheel': MyPluginCommand,
},
# --------------------------------------- 使用C 编译 >>> -----------------------------------------
package_dir={"": "src"},
# --------------------------------------- <<< 使用源码 -----------------------------------------
# # # 包含pyi文件
# package_data={"": ["src/*/*pyi"]},
# py_modules=['common_pygrpc'],
# packages=find_packages(where="src"),
# --------------------------------------- 使用源码 >>> -----------------------------------------
install_requires=["grpcio==1.50.0", "protobuf==3.20.3"],
python_requires=">=3.6",
long_description=long_description,
long_description_content_type="text/markdown",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
],
# --------------------------------------- <<< 使用C 编译 -----------------------------------------
ext_modules=cythonize(
[
"src/common_pygrpc/grpclib.py",
"src/common_pygrpc/common_pb2.py",
"src/common_pygrpc/common_pb2_grpc.py",
],
compiler_directives={"language_level": 3},
),
# --------------------------------------- 使用C 编译 >>> -----------------------------------------
)