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
|
From: TSUCHIYA Masatoshi <tsuchiya@imc.tut.ac.jp>
Date: Mon, 26 Nov 2018 11:32:02 +0900
Subject: build python modules using shared library
Author: TSUCHIYA Masatoshi
Origin: https://bitbucket.org/tsuchm/pkg-fasttext/src/master/debian/patches/0002-build-python-modules-using-shared-library.patch
Forwarded: not-needed
---
setup.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
mode change 100644 => 100755 setup.py
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
index caf445f..aadbb44
--- a/setup.py
+++ b/setup.py
@@ -110,6 +110,15 @@ def cpp_flag(compiler):
'is needed!'
)
+def buildarch():
+ try:
+ output = subprocess.check_output('dpkg-architecture -q DEB_BUILD_GNU_TYPE', shell=True)
+ if sys.version_info >= (3,0,0):
+ output = output.decode('utf-8')
+ except subprocess.CalledProcessError:
+ sys.stderr.write('Failed to invoke dpkg-architecture\n')
+ sys.exit(1)
+ return (output.strip().split())[0]
class BuildExt(build_ext):
"""A custom build extension for adding compiler-specific options."""
@@ -146,6 +155,9 @@ class BuildExt(build_ext):
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, ['-fvisibility=hidden']):
opts.append('-fvisibility=hidden')
+ extra_link_args.append('-latomic')
+ extra_link_args.append('-L./obj-%s' % buildarch())
+ extra_link_args.append('-lfasttext')
elif ct == 'msvc':
opts.append(
'/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version()
|