Skip to content

Commit 985eda0

Browse files
authored
Use harfbuzz's amalgam instead cmake
1 parent bcebfee commit 985eda0

10 files changed

+34
-143
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "harfbuzz"]
2+
path = harfbuzz
3+
url = https://github.com/harfbuzz/harfbuzz

CMakeLists.txt

-60
This file was deleted.

appveyor.yml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ branches:
2020
- /^v\d+\.\d+.*$/
2121

2222
install:
23+
- cd %APPVEYOR_BUILD_FOLDER%
24+
- git submodule update --init --recursive
2325
- SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
2426
- python -m pip install --upgrade pip
2527
- pip install cibuildwheel==1.1.0

harfbuzz

Submodule harfbuzz added at e4203c1

pyproject.toml

-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@ requires = [
44
"wheel",
55
"setuptools_scm >= 2.1",
66
"cython >= 0.28.1",
7-
"scikit-build >= 0.9.0",
8-
"cmake",
9-
"ninja",
107
]
118
build-backend = "setuptools.build_meta"

requirements-dev.txt

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
cython>=0.29.1
2-
scikit-build>=0.8.1
3-
cmake
4-
ninja
52

63
# we need wheel >= 0.31.0 to support Markdown long_description
74
wheel>=0.31

setup.py

100644100755
+27-27
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,36 @@
33
from io import open
44
import os
55
import sys
6-
6+
import platform
7+
from setuptools import Extension, setup
8+
from Cython.Build import cythonize
79

810
here = os.path.abspath(os.path.dirname(__file__))
911

1012
# Get the long description from the README file
1113
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
1214
long_description = f.read()
1315

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+
)
2334

24-
setup_params = dict(
35+
setup(
2536
name="uharfbuzz",
2637
use_scm_version={"write_to": "src/uharfbuzz/_version.py"},
2738
description="Streamlined Cython bindings for the harfbuzz shaping engine",
@@ -35,21 +46,10 @@
3546
packages=["uharfbuzz"],
3647
zip_safe=False,
3748
setup_requires=["setuptools_scm"],
38-
cmake_args=cmake_args,
3949
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+
),
4055
)
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)

src/uharfbuzz/CMakeLists.txt

-47
This file was deleted.

src/uharfbuzz/_harfbuzz.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#cython: language_level=3
22
from enum import IntEnum
3-
from charfbuzz cimport *
3+
from .charfbuzz cimport *
44
from libc.stdlib cimport free, malloc
55
from libc.string cimport const_char
66
from typing import Callable, Dict, List, Tuple

tox.ini

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ setenv =
1818
commands =
1919
!cov: pytest {posargs}
2020
cov: python setup.py develop
21-
cov: python -c 'import shutil, glob; src = glob.glob("_skbuild/*/cmake-build/uharfbuzz-prefix/src/uharfbuzz-build/_harfbuzz.c"); src and shutil.copy(src[0], "src/uharfbuzz/_harfbuzz.c")'
22-
cov: python -c 'import shutil, glob; src = glob.glob("_skbuild/*/cmake-build/uharfbuzz-prefix/src/uharfbuzz-build/_harfbuzz.html"); src and shutil.copy(src[0], "src/uharfbuzz/_harfbuzz.html")'
2321
cov: coverage run --parallel -m pytest {posargs}
2422

2523
[testenv:coverage]

0 commit comments

Comments
 (0)