3434
3535from setuptools import setup , Extension
3636from Cython .Build import cythonize
37+ from Cython .Distutils .build_ext import new_build_ext as build_ext
3738
3839GITHUB_URL = "https://github.com/openzim/python-libzim"
3940BASE_DIR = Path (__file__ ).parent
4243LIBZIM_DYLIB = 'libzim.{ext}' .format (ext = 'dylib' if platform .system () == 'Darwin' else 'so' )
4344
4445
46+ class fixed_build_ext (build_ext ):
47+ """Workaround for rpath bug in distutils for OSX."""
48+
49+ def finalize_options (self ):
50+ super ().finalize_options ()
51+ # Special treatment of rpath in case of OSX, to work around python
52+ # distutils bug 36353. This constructs proper rpath arguments for clang.
53+ # See https://bugs.python.org/issue36353
54+ if platform .system () == 'Darwin' :
55+ for path in self .rpath :
56+ for ext in self .extensions :
57+ ext .extra_link_args .append ("-Wl,-rpath," + path )
58+ self .rpath [:] = []
59+
60+
4561# Check for the CPP Libzim library headers in expected directory
4662if not (BASE_DIR / LIBZIM_INCLUDE_DIR / 'zim/zim.h' ).exists ():
4763 print (
@@ -77,7 +93,7 @@ def get_long_description():
7793setup (
7894# Basic information about libzim module
7995 name = "libzim" ,
80- version = "0.0.3" ,
96+ version = "0.0.3.post0 " ,
8197 url = GITHUB_URL ,
8298 project_urls = {
8399 'Source' : GITHUB_URL ,
@@ -96,6 +112,7 @@ def get_long_description():
96112
97113 # Content
98114 packages = ["libzim" ],
115+ cmdclass = {'build_ext' : fixed_build_ext },
99116 ext_modules = cythonize ([wrapper_extension ],
100117 compiler_directives = {"language_level" : "3" }
101118 ),
0 commit comments