From d581c95e3ddec3f236ebe74fd626b6e1cfe112ee Mon Sep 17 00:00:00 2001 From: luoruixuan <1500012842@pku.edu.cn> Date: Sun, 21 Jun 2020 16:52:55 +0800 Subject: [PATCH] fix cython import --- setup.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index c124772..bfbb832 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,14 @@ import setuptools +import os from distutils.extension import Extension import numpy as np -from Cython.Build import cythonize + +def is_source_release(path): + return os.path.exists(os.path.join(path, "PKG-INFO")) def setup_package(): + root = os.path.abspath(os.path.dirname(__file__)) long_description = "pkuseg-python" @@ -26,10 +30,15 @@ def setup_package(): include_dirs=[np.get_include()], ), ] + + if not is_source_release(root): + from Cython.Build import cythonize + extensions = cythonize(extensions, annotate=True) + setuptools.setup( name="pkuseg", - version="0.0.22", + version="0.0.25", author="Lanco", author_email="luoruixuan97@pku.edu.cn", description="A small package for Chinese word segmentation", @@ -43,9 +52,9 @@ def setup_package(): "License :: Other/Proprietary License", "Operating System :: OS Independent", ], - install_requires=["numpy>=1.16.0"], + install_requires=["cython", "numpy>=1.16.0"], setup_requires=["cython", "numpy>=1.16.0"], - ext_modules=cythonize(extensions, annotate=True), + ext_modules=extensions, zip_safe=False, )