Skip to content

Commit d581c95

Browse files
committed
fix cython import
1 parent becc57e commit d581c95

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

setup.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import setuptools
2+
import os
23
from distutils.extension import Extension
34

45
import numpy as np
5-
from Cython.Build import cythonize
6+
7+
def is_source_release(path):
8+
return os.path.exists(os.path.join(path, "PKG-INFO"))
69

710
def setup_package():
11+
root = os.path.abspath(os.path.dirname(__file__))
812

913
long_description = "pkuseg-python"
1014

@@ -26,10 +30,15 @@ def setup_package():
2630
include_dirs=[np.get_include()],
2731
),
2832
]
33+
34+
if not is_source_release(root):
35+
from Cython.Build import cythonize
36+
extensions = cythonize(extensions, annotate=True)
37+
2938

3039
setuptools.setup(
3140
name="pkuseg",
32-
version="0.0.22",
41+
version="0.0.25",
3342
author="Lanco",
3443
author_email="luoruixuan97@pku.edu.cn",
3544
description="A small package for Chinese word segmentation",
@@ -43,9 +52,9 @@ def setup_package():
4352
"License :: Other/Proprietary License",
4453
"Operating System :: OS Independent",
4554
],
46-
install_requires=["numpy>=1.16.0"],
55+
install_requires=["cython", "numpy>=1.16.0"],
4756
setup_requires=["cython", "numpy>=1.16.0"],
48-
ext_modules=cythonize(extensions, annotate=True),
57+
ext_modules=extensions,
4958
zip_safe=False,
5059
)
5160

0 commit comments

Comments
 (0)