Skip to content

Commit 9d924ab

Browse files
committed
Reorder a bit setup.py
1 parent 754bc7a commit 9d924ab

File tree

1 file changed

+33
-46
lines changed

1 file changed

+33
-46
lines changed

setup.py

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,8 @@
3434
from setuptools import setup, Extension
3535
from Cython.Build import cythonize
3636

37-
38-
PACKAGE_NAME = "libzim_wrapper"
39-
VERSION = "0.0.1" # pegged to be the same version as libzim since they are always released together
40-
LICENSE = "GPLv3+"
41-
DESCRIPTION = "A python-facing API for creating and interacting with ZIM files"
42-
AUTHOR = "Monadical Inc."
43-
AUTHOR_EMAIL = "[email protected]"
4437
GITHUB_URL = "https://github.com/openzim/python-libzim"
45-
4638
BASE_DIR = Path(__file__).parent
47-
BINDINGS_CYTHON_DIR = 'libzim' # the cython binding source dir (containing .pyx, .pyd, etc.)
4839
LIBZIM_INCLUDE_DIR = 'include' # the libzim C++ header src dir (containing zim/*.h)
4940
LIBZIM_LIBRARY_DIR = 'lib' # the libzim .so binary lib dir (containing libzim.so)
5041

@@ -55,7 +46,7 @@
5546
f"[!] Warning: Couldn't find zim/*.h in ./{LIBZIM_INCLUDE_DIR}!\n"
5647
f" Hint: You can install them from source from https://github.com/openzim/libzim\n"
5748
f" or download a prebuilt release's headers into ./include/zim/*.h\n"
58-
f" (or set CFLAGS='-I/tmp/libzim_linux-x86_64-{VERSION}/include')"
49+
f" (or set CFLAGS='-I<library_path>/include')"
5950
)
6051

6152
# Check for the CPP Libzim shared library in expected directory or system paths
@@ -64,12 +55,27 @@
6455
f"[!] Warning: Couldn't find libzim.so in ./{LIBZIM_LIBRARY_DIR} or system library paths!"
6556
f" Hint: You can install it from source from https://github.com/openzim/libzim\n"
6657
f" or download a prebuilt zimlib.so release into ./lib.\n"
67-
f" (or set LDFLAGS='-L/tmp/libzim_linux-x86_64-{VERSION}/lib/x86_64-linux-gnu')"
58+
f" (or set LDFLAGS='-L<library_path>/lib/x86_64-linux-gnu')"
6859
)
6960

61+
def get_long_description():
62+
return (BASE_DIR/'README.md').read_text()
63+
64+
wrapper_extension = Extension(
65+
name = "libzim_wrapper",
66+
sources = ["libzim/*.pyx", "libzim/lib.cxx"],
67+
include_dirs=["libzim", LIBZIM_INCLUDE_DIR],
68+
libraries=['zim'],
69+
library_dirs=[LIBZIM_LIBRARY_DIR],
70+
extra_compile_args=["-std=c++11", "-Wall", "-Wextra"],
71+
language="c++",
72+
)
73+
74+
7075
setup(
71-
name=PACKAGE_NAME,
72-
version=VERSION,
76+
# Basic information about libzim module
77+
name="libzim",
78+
version="0.0.1",
7379
url=GITHUB_URL,
7480
project_urls={
7581
'Source': GITHUB_URL,
@@ -78,43 +84,24 @@
7884
'Documentation': f'{GITHUB_URL}/blob/master/README.md',
7985
'Donate': 'https://www.kiwix.org/en/support-us/',
8086
},
81-
author=AUTHOR,
82-
author_email=AUTHOR_EMAIL,
83-
license=LICENSE,
84-
description=DESCRIPTION,
85-
long_description=(BASE_DIR / 'README.md').read_text(),
87+
author="Monadical Inc.",
88+
author_email="[email protected]",
89+
license="GPLv3+",
90+
description="A python-facing API for creating and interacting with ZIM files",
91+
long_description=get_long_description(),
8692
long_description_content_type="text/markdown",
8793
python_requires='>=3.6',
88-
include_package_data=True,
89-
ext_modules=cythonize(
90-
[
91-
Extension(
92-
"libzim_wrapper",
93-
sources=[
94-
f"{BINDINGS_CYTHON_DIR}/*.pyx",
95-
f"{BINDINGS_CYTHON_DIR}/lib.cxx",
96-
],
97-
include_dirs=[
98-
BINDINGS_CYTHON_DIR,
99-
LIBZIM_INCLUDE_DIR,
100-
],
101-
libraries=[
102-
'zim',
103-
],
104-
library_dirs=[
105-
LIBZIM_LIBRARY_DIR,
106-
],
107-
extra_compile_args=[
108-
"-std=c++11",
109-
"-Wall",
110-
"-Wextra",
111-
],
112-
language="c++",
113-
)
114-
],
115-
compiler_directives={"language_level" : "3"},
94+
95+
# Content
96+
ext_modules=cythonize([wrapper_extension],
97+
compiler_directives={"language_level": "3"}
11698
),
99+
100+
# Packaging
101+
include_package_data=True,
117102
zip_safe=False,
103+
104+
# Extra
118105
classifiers=[
119106
"Development Status :: 3 - Alpha",
120107

0 commit comments

Comments
 (0)