Support to build Python module without pkg-config
authorKentaro Hayashi <kenhys@xdump.org>
Wed, 28 Oct 2020 11:52:15 +0000 (20:52 +0900)
committerPeter Michael Green <plugwash@raspbian.org>
Sun, 13 Dec 2020 09:25:55 +0000 (09:25 +0000)
Gbp-Pq: Name support-python-module-in-place.patch

python/setup.py

index 1e9bf074398c164c062cde6330d259aaf2ffeb14..3967c8949e7846965091bfabba7773fe0ac4ba8e 100755 (executable)
@@ -65,17 +65,19 @@ class build_ext(_build_ext):
 
   def build_extension(self, ext):
     pkg_config_path = None
-    if not is_sentencepiece_installed():
-      subprocess.run(['./build_bundled.sh', version()], check=True)
-      pkg_config_path = './bundled/lib/pkgconfig:./bundled/lib64/pkgconfig'
+    #if not is_sentencepiece_installed():
+    #  subprocess.run(['./build_bundled.sh', version()], check=True)
+    #  pkg_config_path = './bundled/lib/pkgconfig:./bundled/lib64/pkgconfig'
 
     cflags = ['-std=c++11']
     # Fix compile on some versions of Mac OSX
     # See: https://github.com/neulab/xnmt/issues/199
     if sys.platform == 'darwin':
       cflags.append('-mmacosx-version-min=10.9')
-    cflags = cflags + run_pkg_config('cflags', pkg_config_path)
-    libs = run_pkg_config('libs', pkg_config_path)
+    cflags = 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 -lsentencepiece -lsentencepiece_train" % arch]
     print('## cflags={}'.format(' '.join(cflags)))
     print('## libs={}'.format(' '.join(libs)))
     ext.extra_compile_args = cflags