forked from pymupdf/PyMuPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
94 lines (88 loc) · 3.19 KB
/
setup.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from distutils.core import setup, Extension
from distutils.command.build_py import build_py as build_py_orig
import sys, os
# custom build_py command which runs build_ext first
# this is necessary because build_py needs the fitz.py which is only generated
# by SWIG in the build_ext step
class build_ext_first(build_py_orig):
def run(self):
self.run_command("build_ext")
return super().run()
# check the platform
if sys.platform.startswith("linux"):
module = Extension(
"fitz._fitz", # name of the module
["fitz/fitz.i"],
include_dirs=[ # we need the path of the MuPDF headers
"/usr/include/mupdf",
"/usr/local/include/mupdf",
],
# library_dirs=['<mupdf_and_3rd_party_libraries_dir>'],
libraries=[
"mupdf",
#'crypto', #openssl is required by mupdf on archlinux
#'jbig2dec', 'openjp2', 'jpeg', 'freetype',
"mupdf-third",
], # the libraries to link with
)
elif sys.platform.startswith(("darwin", "freebsd")):
module = Extension(
"fitz._fitz", # name of the module
["fitz/fitz.i"],
# directories containing mupdf's header files
include_dirs=["/usr/local/include/mupdf", "/usr/local/include"],
# libraries should already be linked here by brew
library_dirs=["/usr/local/lib"],
# library_dirs=['/usr/local/Cellar/mupdf-tools/1.8/lib/',
#'/usr/local/Cellar/openssl/1.0.2g/lib/',
#'/usr/local/Cellar/jpeg/8d/lib/',
#'/usr/local/Cellar/freetype/2.6.3/lib/',
#'/usr/local/Cellar/jbig2dec/0.12/lib/'
# ],
libraries=["mupdf", "mupdf-third"],
)
else:
# ===============================================================================
# Build / set up PyMuPDF under Windows
# ===============================================================================
module = Extension(
"fitz._fitz",
["fitz/fitz.i"],
include_dirs=[ # we need the path of the MuPDF's headers
"./mupdf/include",
"./mupdf/include/mupdf",
],
libraries=[ # these are needed in Windows
"libmupdf",
"libresources",
"libthirdparty",
],
extra_link_args=["/NODEFAULTLIB:MSVCRT"],
# x86 dir of libmupdf.lib etc.
library_dirs=["./mupdf/platform/win32/Release"],
# x64 dir of libmupdf.lib etc.
# library_dirs=['./mupdf/platform/win32/x64/Release'],
)
pkg_tab = open("PKG-INFO").read().split("\n")
long_dtab = []
classifier = []
for l in pkg_tab:
if l.startswith("Classifier: "):
classifier.append(l[12:])
continue
if l.startswith(" "):
long_dtab.append(l.strip())
long_desc = "\n".join(long_dtab)
setup(
name="PyMuPDF",
version="1.17.3",
description="Python bindings for the PDF rendering library MuPDF",
long_description=long_desc,
classifiers=classifier,
url="https://github.com/pymupdf/PyMuPDF",
author="Jorj McKie, Ruikai Liu",
author_email="[email protected]",
cmdclass={"build_py": build_ext_first},
ext_modules=[module],
py_modules=["fitz.fitz", "fitz.utils", "fitz.__main__"],
)