File: support-python-module-in-place.patch

package info (click to toggle)
sentencepiece 0.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 53,912 kB
  • sloc: cpp: 190,245; python: 1,776; xml: 231; perl: 198; sh: 58; pascal: 50; makefile: 23
file content (46 lines) | stat: -rw-r--r-- 1,803 bytes parent folder | download
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
From: Kentaro Hayashi <kenhys@xdump.org>
Date: Fri, 5 Sep 2025 20:08:19 +0900
Subject: Support to build Python module without pkg-config

From: Kentaro Hayashi <kenhys@gmail.com>
Date: Fri, 23 Feb 2024 20:27:25 +0900
Subject: Support to build Python module without pkg-config
---
 python/setup.py | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/python/setup.py b/python/setup.py
index da68e71..84f5e92 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -85,15 +85,21 @@ class build_ext(_build_ext):
   """Override build_extension to run cmake."""
 
   def build_extension(self, ext):
-    cflags, libs = get_cflags_and_libs('../build/root')
-
-    if len(libs) == 0:
-      if is_sentencepiece_installed():
-        cflags = cflags + run_pkg_config('cflags')
-        libs = run_pkg_config('libs')
-      else:
-        subprocess.check_call(['./build_bundled.sh', __version__])
-        cflags, libs = get_cflags_and_libs('./build/root')
+    # cflags, libs = get_cflags_and_libs('../build/root')
+    # if len(libs) == 0:
+    #   cflags, libs = get_cflags_and_libs('./bundled/root')
+
+    # if len(libs) == 0:
+    #   if is_sentencepiece_installed():
+    #     cflags = cflags + run_pkg_config('cflags')
+    #     libs = run_pkg_config('libs')
+    #   else:
+    #     subprocess.check_call(['./build_bundled.sh', __version__])
+    #     cflags, libs = get_cflags_and_libs('./bundled/root')
+    cflags = ['-I../src']
+    cmd = "dpkg-architecture -q DEB_BUILD_GNU_TYPE"
+    arch = subprocess.check_output(cmd, shell=True).decode("utf-8").strip().split()[0]
+    libs = ["-L../obj-%s/src" % arch, "-lsentencepiece", "-lsentencepiece_train"]
 
     # Fix compile on some versions of Mac OSX
     # See: https://github.com/neulab/xnmt/issues/199