|
3 | 3 | from io import open
|
4 | 4 | import os
|
5 | 5 | import sys
|
6 |
| - |
| 6 | +import platform |
| 7 | +from setuptools import Extension, setup |
| 8 | +from Cython.Build import cythonize |
7 | 9 |
|
8 | 10 | here = os.path.abspath(os.path.dirname(__file__))
|
9 | 11 |
|
10 | 12 | # Get the long description from the README file
|
11 | 13 | with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
|
12 | 14 | long_description = f.read()
|
13 | 15 |
|
14 |
| -cmake_args = [] |
15 |
| -for option in ("CYTHON_LINETRACE", "CYTHON_ANNOTATE"): |
16 |
| - value = os.environ.get(option) |
17 |
| - if value is not None and bool(int(value)): |
18 |
| - cmake_args.append("-D{}:BOOL=TRUE".format(option)) |
19 |
| - |
20 |
| -# On Mac, require OSX >= 10.9 so we can use te new libc++ targeting C++11 |
21 |
| -if sys.platform == "darwin": |
22 |
| - cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9") |
| 16 | +define_macros = [('HB_NO_MT', '1')] |
| 17 | +linetrace = False |
| 18 | +if int(os.environ.get('CYTHON_LINETRACE', '0')): |
| 19 | + linetrace = True |
| 20 | + define_macros.append(('CYTHON_TRACE_NOGIL', '1')) |
| 21 | + |
| 22 | +extra_compile_args = [] |
| 23 | +if platform.system() != 'Windows': |
| 24 | + extra_compile_args.append('-std=c++11') |
| 25 | + |
| 26 | +extension = Extension( |
| 27 | + 'uharfbuzz._harfbuzz', |
| 28 | + define_macros=define_macros, |
| 29 | + include_dirs=['harfbuzz/src'], |
| 30 | + sources=['src/uharfbuzz/_harfbuzz.pyx', 'harfbuzz/src/harfbuzz.cc'], |
| 31 | + language='c++', |
| 32 | + extra_compile_args=extra_compile_args, |
| 33 | +) |
23 | 34 |
|
24 |
| -setup_params = dict( |
| 35 | +setup( |
25 | 36 | name="uharfbuzz",
|
26 | 37 | use_scm_version={"write_to": "src/uharfbuzz/_version.py"},
|
27 | 38 | description="Streamlined Cython bindings for the harfbuzz shaping engine",
|
|
35 | 46 | packages=["uharfbuzz"],
|
36 | 47 | zip_safe=False,
|
37 | 48 | setup_requires=["setuptools_scm"],
|
38 |
| - cmake_args=cmake_args, |
39 | 49 | python_requires=">=3.5",
|
| 50 | + ext_modules = cythonize( |
| 51 | + extension, |
| 52 | + annotate=bool(int(os.environ.get('CYTHON_ANNOTATE', '0'))), |
| 53 | + compiler_directives={"linetrace": linetrace}, |
| 54 | + ), |
40 | 55 | )
|
41 |
| - |
42 |
| - |
43 |
| -if __name__ == "__main__": |
44 |
| - import sys |
45 |
| - # cibuildwheel calls setup.py --name to get the package name; no need |
46 |
| - # to require scikit-build at that stage: it will be installed later with |
47 |
| - # the rest of the build requirements. Also, creating an sdist can be done |
48 |
| - # with plain setuptools since there is no cmake involved there, and we |
49 |
| - # generate the manifest using setuptools_scm anyway. |
50 |
| - args = sys.argv[1:] |
51 |
| - if len(args) == 1 and {"--name", "sdist"}.intersection(args): |
52 |
| - from setuptools import setup |
53 |
| - else: |
54 |
| - from skbuild import setup |
55 |
| - setup(**setup_params) |
0 commit comments