3535
3636
3737import os
38- import sys
3938import platform
40- from pathlib import Path
39+ import sys
4140from ctypes .util import find_library
41+ from pathlib import Path
4242from textwrap import dedent
4343
44- from setuptools import setup , Extension
4544from Cython .Build import cythonize
4645from Cython .Distutils .build_ext import new_build_ext as build_ext
46+ from setuptools import Extension , setup
4747
4848base_dir = Path (__file__ ).parent
4949
5656 define_macros = []
5757
5858if platform .system () == "Darwin" :
59+
5960 class fixed_build_ext (build_ext ):
6061 """Workaround for rpath bug in distutils for OSX."""
6162
@@ -68,32 +69,45 @@ def finalize_options(self):
6869 for ext in self .extensions :
6970 ext .extra_link_args .append ("-Wl,-rpath," + path )
7071 self .rpath [:] = []
71- cmdclass = {"build_ext" : fixed_build_ext }
72+
73+ cmdclass = {"build_ext" : fixed_build_ext }
7274 dyn_lib_ext = "dylib"
7375else :
74- cmdclass = {"build_ext" : build_ext }
76+ cmdclass = {"build_ext" : build_ext }
7577 dyn_lib_ext = "so"
7678
7779include_dirs = ["libzim" ]
7880library_dirs = []
7981# Check for the CPP Libzim library headers in expected directory
80- if (base_dir / "include" / "zim" / "zim.h" ).exists () and (base_dir / "lib" / f"libzim.{ dyn_lib_ext } " ).exists ():
81- print (dedent ("""\
82+ header_file = base_dir / "include" / "zim" / "zim.h"
83+ lib_file = base_dir / "lib" / f"libzim.{ dyn_lib_ext } "
84+ if header_file .exists () and lib_file .exists ():
85+ print (
86+ dedent (
87+ """\
8288 Found lizim library and headers in local directory.
8389 We will use them to compile python-libzim.
8490 Hint : If you don't want to use them (and use "system" installed one), remove them.
85- """ ))
91+ """
92+ )
93+ )
8694 include_dirs .append ("include" )
8795 library_dirs = ["lib" ]
8896else :
8997 # Check for library.
9098 if not find_library ("zim" ):
91- print (dedent ("""\
99+ print (
100+ dedent (
101+ """\
92102 "[!] The libzim library cannot be found.
93103 "Please verify that the library is correctly installed of and can be found.
94- """ ))
104+ """
105+ )
106+ )
95107 sys .exit (1 )
96- print ("Using system installed library. We are assuming CFLAGS/LDFLAGS are correctly set." )
108+ print (
109+ "Using system installed library. We are assuming CFLAGS/LDFLAGS are correctly set."
110+ )
97111
98112wrapper_extension = Extension (
99113 name = "libzim" ,
0 commit comments