comparison mupdf-source/thirdparty/zxing-cpp/wrappers/python/setup.py @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 import os
2 import platform
3 import subprocess
4 import sys
5
6 from setuptools import setup, Extension
7 from setuptools.command.build_ext import build_ext
8
9
10 # Adapted from here: https://github.com/pybind/cmake_example/blob/master/setup.py
11 class CMakeExtension(Extension):
12 def __init__(self, name, sourcedir=''):
13 Extension.__init__(self, name, sources=[])
14 self.sourcedir = os.path.abspath(sourcedir)
15
16
17 class CMakeBuild(build_ext):
18 def build_extension(self, ext):
19 extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
20 cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
21 '-DPython3_EXECUTABLE=' + sys.executable,
22 '-DVERSION_INFO=' + self.distribution.get_version()]
23
24 cfg = 'Debug' if self.debug else 'Release'
25 build_args = ['--config', cfg,
26 '-j', '8']
27
28 if platform.system() == "Windows":
29 cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)]
30 if sys.maxsize > 2**32:
31 cmake_args += ['-A', 'x64']
32 else:
33 cmake_args += ['-A', 'Win32']
34 build_args += ['--', '/m']
35 else:
36 cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
37
38 if not os.path.exists(self.build_temp):
39 os.makedirs(self.build_temp)
40
41 subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp)
42 subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
43
44
45 with open("README.md", "r", encoding="utf-8") as fh:
46 long_description = fh.read()
47
48
49 setup(
50 name='zxing-cpp',
51 # setuptools_scm cannot be used because of the structure of the project until the following issues are solved:
52 # https://github.com/pypa/setuptools_scm/issues/357
53 # https://github.com/pypa/pip/issues/7549
54 # Because pip works on a copy of current directory in a temporary directory, the temporary directory does not hold
55 # the .git directory of the repo, so that setuptools_scm cannot guess the current version.
56 # use_scm_version={
57 # "root": "../..",
58 # "version_scheme": "guess-next-dev",
59 # "local_scheme": "no-local-version",
60 # "tag_regex": "v?([0-9]+.[0-9]+.[0-9]+)",
61 # },
62 version='2.3.0',
63 description='Python bindings for the zxing-cpp barcode library',
64 long_description=long_description,
65 long_description_content_type="text/markdown",
66 author='ZXing-C++ Community',
67 author_email='zxingcpp@gmail.com',
68 url='https://github.com/zxing-cpp/zxing-cpp',
69 license='Apache License 2.0',
70 keywords=['barcode'],
71 classifiers=[
72 "Development Status :: 4 - Beta",
73 "Programming Language :: Python :: 3",
74 "License :: OSI Approved :: Apache Software License",
75 "Operating System :: OS Independent",
76 "Topic :: Multimedia :: Graphics",
77 ],
78 python_requires=">=3.6",
79 ext_modules=[CMakeExtension('zxingcpp')],
80 cmdclass=dict(build_ext=CMakeBuild),
81 zip_safe=False,
82 )