aboutsummaryrefslogtreecommitdiff
path: root/python/PyStemmer/python-3.7-compatibility.patch
blob: aeebafd725d737fb489933fa1b75bb7106e0ef03 (plain)
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
From b29ce2109f49c0b82517fa9d3e2bbacc1f8b34ec Mon Sep 17 00:00:00 2001
From: konstantin <kslavnov@gmail.com>
Date: Sun, 30 Sep 2018 20:30:07 +0300
Subject: [PATCH] Fix installation for python 3.7

Changes list:
- Use setuptools instead of distutils to handle `setup_requires` in `setup()`.
- Require Cython package for setup and always build `.pyx` to `.c`. It also requires `python-dev` to be installed (see `.travis.yml`).
---
 setup.py    | 27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)
 
diff --git a/setup.py b/setup.py
index 5fa89f5..fc53b69 100644
--- a/setup.py
+++ b/setup.py
@@ -1,13 +1,13 @@
 #!/usr/bin/env python
 
-from distutils.core import setup, Extension
+from setuptools import setup, Extension
 import os.path
 
-try:
+
+def build_ext(*args, **kwargs):
     from Cython.Distutils import build_ext
-    have_pyrex = 1
-except:
-    have_pyrex = 0
+    return build_ext(*args, **kwargs)
+
 
 # Directory which libstemmer sources are unpacked in.
 library_dir = 'libstemmer_c'
@@ -39,16 +39,8 @@
 # Set the include path to include libstemmer.
 include_dirs = ('src', os.path.join(library_dir, 'include'))
 
-if have_pyrex:
-    # Add the pyrex sources, and a special rule so distutils knows how to
-    # use them.
-    src_files.append('src/Stemmer.pyx')
-    cmdclass = {'build_ext': build_ext}
-else:
-    # Add just the C sources.
-    src_files.append('src/Stemmer.c')
-    cmdclass = {}
-      
+src_files.append('src/Stemmer.pyx')
+
 long_description = r"""
 
 Stemming algorithms
@@ -125,9 +117,8 @@
       "Topic :: Text Processing :: Indexing",
       "Topic :: Text Processing :: Linguistic",
       ],
-
+      setup_requires=['Cython>=0.28.5,<1.0'],
       ext_modules = [Extension('Stemmer', src_files,
                                include_dirs = include_dirs)],
-      cmdclass = cmdclass
+      cmdclass = {'build_ext': build_ext}
      )
-