Commit b3a3cd07 authored by Thomas Gambier's avatar Thomas Gambier

setup.py: fix for sdist

We don't want to run cython just for preparing sources.
parent 79369637
import sys import sys
from setuptools import setup, find_packages, Extension from setuptools import setup, find_packages, Extension
from distutils.command.build import build as build_orig
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")
class build(build_orig):
def finalize_options(self):
super().finalize_options()
if 'sdist' in sys.argv:
return
try:
from Cython.Build import cythonize
except ModuleNotFoundError:
raise SystemExit("Cython is required. You can install it with pip.")
self.distribution.ext_modules = cythonize(self.distribution.ext_modules,
language_level=3)
setup( setup(
name="pim-dm", name="pim-dm",
...@@ -23,6 +32,7 @@ setup( ...@@ -23,6 +32,7 @@ setup(
author="Pedro Oliveira", author="Pedro Oliveira",
author_email="pedro.francisco.oliveira@tecnico.ulisboa.pt", author_email="pedro.francisco.oliveira@tecnico.ulisboa.pt",
license="MIT", license="MIT",
cmdclass={"build": build},
install_requires=[ install_requires=[
'PrettyTable', 'PrettyTable',
'netifaces', 'netifaces',
...@@ -32,10 +42,11 @@ setup( ...@@ -32,10 +42,11 @@ setup(
'igmp==1.0.4', 'igmp==1.0.4',
], ],
packages=find_packages(exclude=["docs"]), packages=find_packages(exclude=["docs"]),
ext_modules = cythonize([ ext_modules = [Extension(
Extension("pcap_wrapper", ["pcap.pyx"], name="pcap_wrapper",
libraries=["pcap"]), sources = ["pcap.pyx"],
], language_level=3), libraries=["pcap"],
)],
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