forked from caizhengxin/python-libpcap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
120 lines (104 loc) · 3.31 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# -*- coding: utf-8 -*-
# @Author: JanKinCai
# @Date: 2019-11-09 10:08:53
# @Last Modified by: JanKinCai
# @Last Modified time: 2020-07-07 09:35:38
import os
import glob
from setuptools import setup, find_packages
from setuptools import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext
with open('README.rst') as f:
long_description = f.read()
def read_requirements(path):
"""
递归读取requirements
:param path: path
"""
requires = []
with open(path) as f:
install_requires = f.read().split("\n")
for ir in install_requires:
if "-r" in ir:
path = os.path.join(os.path.split(path)[0], ir.split(" ")[1])
requires.extend(read_requirements(path))
else:
ir and requires.append(ir)
return requires
# local or publish
USE_CYTHON = True if glob.glob("pylibpcap/*.pyx") else False
ext = '.pyx' if USE_CYTHON else '.c'
ext_modules = [
Extension(
"{}/{}".format(directory, file.split(".")[0]).replace("/", "."),
sources=["{}/{}".format(directory, file)],
libraries=["m"],
# include_dirs=["src"],
extra_compile_args=["-lpcap"],
extra_link_args=["-lpcap"],
)
for directory, dirs, files in os.walk("pylibpcap")
for file in files if ext in file and ".pyc" not in file
]
ext_modules = cythonize(ext_modules) if USE_CYTHON else ext_modules
setup(
name="python-libpcap",
version="0.4.0",
author="JanKinCai",
author_email="[email protected]",
maintainer="JanKinCai",
maintainer_email="[email protected]",
url="https://github.com/caizhengxin/python-libpcap",
download_url="https://github.com/caizhengxin/python-libpcap.git",
license="BSD",
description="Cython libpcap",
long_description=long_description,
keywords=[
"python-libpcap",
"pylibpcap",
"libpcap",
"pcap",
"pcapng"
"python",
"libpcap-python",
"python-pcapng",
],
zip_safe=False,
packages=find_packages(),
cmdclass={
"build_ext": build_ext
},
ext_modules=ext_modules,
install_requires=read_requirements("requirements/publish.txt"),
entry_points={
"console_scripts": [
"libpcap-merge = pylibpcap.cli:pylibpcap_merge",
"libpcap-capture = pylibpcap.cli:pylibpcap_sniff",
"libpcap-write = pylibpcap.cli:pylibpcap_write",
"libpcap-read = pylibpcap.cli:pylibpcap_read",
],
},
include_package_data=True, # MANIFEST.in
setup_requires=[
"setuptools",
"Cython",
],
project_urls={
"Documentation": "https://python-libpcap.readthedocs.io",
"Source Code": "https://github.com/caizhengxin/python-libpcap",
},
platforms="Linux",
classifiers=[
'Development Status :: 4 - Beta',
'Operating System :: OS Independent',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Programming Language :: Python :: Implementation',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Libraries'
],
)