Commit 521ea5aa authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾 Committed by GitHub

setup.py: generate pcap.c during setup (#16)

Use Cython as a prerequirement to generate pcap.c during the pip
installation for compatibility with the Python version of the user.
parent d22fde73
...@@ -19,6 +19,7 @@ Additionally, IGMPv2 and MLDv1 are implemented alongside with PIM-DM to detect i ...@@ -19,6 +19,7 @@ Additionally, IGMPv2 and MLDv1 are implemented alongside with PIM-DM to detect i
- pip (to install all dependencies) - pip (to install all dependencies)
- libpcap-dev - libpcap-dev
- python3-dev - python3-dev
- Cython (it can be installed with pip)
# Installation # Installation
......
This diff is collapsed.
import sys import sys
from setuptools import setup, find_packages, Extension from setuptools import setup, find_packages, Extension
try:
from Cython.Build import cythonize
except ModuleNotFoundError:
raise SystemExit("Cython is required. You can install it with pip.")
# we only support Python 3 version >= 3.3 # we only support Python 3 version >= 3.3
if len(sys.argv) >= 2 and sys.argv[1] == "install" and sys.version_info < (3, 3): if len(sys.argv) >= 2 and sys.argv[1] == "install" and sys.version_info < (3, 3):
raise SystemExit("Python 3.3 or higher is required") raise SystemExit("Python 3.3 or higher is required")
...@@ -26,11 +32,10 @@ setup( ...@@ -26,11 +32,10 @@ setup(
'igmp==1.0.4', 'igmp==1.0.4',
], ],
packages=find_packages(exclude=["docs"]), packages=find_packages(exclude=["docs"]),
ext_modules = [Extension( ext_modules = cythonize([
name="pcap_wrapper", Extension("pcap_wrapper", ["pcap.pyx"],
sources = ["pcap.c"], libraries=["pcap"]),
libraries=["pcap"], ], language_level=3),
)],
entry_points={ entry_points={
"console_scripts": [ "console_scripts": [
"pim-dm = pimdm.Run:main", "pim-dm = pimdm.Run:main",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment