Skip to content

Commit 80e9f1a

Browse files
mgautierfrrenaud gaudin
authored andcommitted
Remove the unnecessary warning if we are not using local libzim.
There is nothing wrong to not compile python-libzim with a copy of a local libzim. It is possible to compile python-libzim with system installed libzim or libzim installed in another directory. Let's do : - If we found a local lib/header in sub-directory, use it (and tell the user about this). - If not, do a small test to find the library and be sure it is installed. - If we can found the library, assume everything else is properly configured and go one.
1 parent c89b010 commit 80e9f1a

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

setup.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,27 @@ def finalize_options(self):
6363
self.rpath[:] = []
6464

6565

66+
include_dirs = ["libzim"]
67+
library_dirs = []
6668
# Check for the CPP Libzim library headers in expected directory
67-
if not (BASE_DIR / LIBZIM_INCLUDE_DIR / "zim/zim.h").exists():
69+
if (BASE_DIR / LIBZIM_INCLUDE_DIR / "zim" / "zim.h").exists() and
70+
(BASE_DIR / LIBZIM_LIB_DIR / LIBZIM_DYLIB).exists():
6871
print(
69-
f"[!] Warning: Couldn't find zim/*.h in ./{LIBZIM_INCLUDE_DIR}!\n"
70-
f" Hint: install from source using from https://github.com/openzim/libzim\n"
71-
f" or download a prebuilt release's headers into ./include/zim/*.h\n"
72-
f" (or set CFLAGS='-I<library_path>/include')"
73-
)
74-
75-
# Check for the CPP Libzim shared library in expected directory or system paths
76-
if not ((BASE_DIR / LIBZIM_LIBRARY_DIR / LIBZIM_DYLIB).exists() or find_library("zim")):
77-
print(
78-
f"[!] Warning: Couldn't find {LIBZIM_DYLIB} in ./{LIBZIM_LIBRARY_DIR} or system"
79-
f" Hint: install from source using https://github.com/openzim/libzim\n"
80-
f" or download a prebuilt {LIBZIM_DYLIB} release into ./lib.\n"
81-
f" (or set LDFLAGS='-L<library_path>/lib/[x86_64-linux-gnu]')"
72+
f"Found lizim library and headers in local directory.\n"
73+
f"We will use them to compile python-libzim.\n"
74+
f"Hint : If you don't want to use them (and use \"system\" installed one), remove them."
8275
)
76+
include_dirs.append("include")
77+
library_dirs = ["lib"]
78+
else:
79+
# Check for library.
80+
if not find_library("zim"):
81+
print(
82+
"[!] The libzim library cannot be found.\n"
83+
"Please verify that the library is correctly installed of and can be found."
84+
)
85+
sys.exit(1)
86+
print("Using system installed library. We are assuming CFLAGS/LDFLAGS are correctly set.")
8387

8488

8589
def get_long_description():
@@ -89,9 +93,9 @@ def get_long_description():
8993
wrapper_extension = Extension(
9094
name="libzim",
9195
sources=["libzim/libzim.pyx", "libzim/libwrapper.cpp"],
92-
include_dirs=["libzim", LIBZIM_INCLUDE_DIR],
96+
include_dir=include_dirs,
9397
libraries=["zim"],
94-
library_dirs=[LIBZIM_LIBRARY_DIR],
98+
library_dirs=library_dirs,
9599
extra_compile_args=["-std=c++11", "-Wall", "-Wextra"],
96100
language="c++",
97101
define_macros=[("CYTHON_TRACE", "1"), ("CYTHON_TRACE_NOGIL", "1")]

0 commit comments

Comments
 (0)