Skip to content

Commit c4822b8

Browse files
authored
Windows support (#22)
1 parent e8194a5 commit c4822b8

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ name: CI
33
on:
44
pull_request:
55
push:
6-
branches: master
6+
branches:
7+
- master
78
tags:
89
- 'v*'
910

@@ -14,6 +15,8 @@ jobs:
1415
matrix:
1516
python-version:
1617
- 3.6
18+
- 3.7
19+
- 3.8
1720
- 3.9
1821
runs-on:
1922
- ubuntu-latest
@@ -31,8 +34,32 @@ jobs:
3134

3235
- name: Test package
3336
run: python -m pytest --forked
37+
38+
checks_windows:
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
python-version:
43+
- 3.8
44+
- 3.9
45+
runs-on:
46+
- windows-latest
47+
runs-on: ${{ matrix.runs-on }}
48+
name: Test • 🐍 ${{ matrix.python-version }} • ${{matrix.runs-on}}
49+
steps:
50+
- uses: actions/checkout@v2
51+
- uses: actions/setup-python@v2
52+
with:
53+
python-version: ${{ matrix.python-version }}
3454

55+
- name: Install package
56+
run: python -m pip install .[test]
3557

58+
- name: Test package
59+
env:
60+
LIBCLANG_PATH: C:\msys64\mingw64\bin\libclang.dll
61+
run: python -m pytest -n2
62+
3663
dist:
3764
runs-on: ubuntu-latest
3865
name: Build distribution

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ py::class_<MyClass>(m, "MyClass", DOC(MyClass))
7676

7777
## Limitations
7878

79-
This tool supports Linux and macOS and requires Clang/LLVM to be installed. It
80-
has never been used on Windows and will likely require adaptations.
79+
This tool supports Linux and macOS for Python versions 3.6 to 3.9. On Windows you at least need Python version 3.8.
80+
Also, it requires Clang/LLVM to be installed.
8181

8282

8383
## Testing
@@ -94,5 +94,5 @@ python3 -m pip install .
9494

9595
And execute the tests (forked)
9696
```
97-
python3 -m pip pytest --forked
98-
```
97+
python3 -m pytest --forked
98+
```

pybind11_mkdoc/mkdoc_lib.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import re
1313
import textwrap
1414

15+
import ctypes.util
16+
1517
from clang import cindex
1618
from clang.cindex import CursorKind
1719
from collections import OrderedDict
@@ -272,6 +274,18 @@ def read_args(args):
272274
sysroot_dir = os.path.join(sdk_dir, next(os.walk(sdk_dir))[1][0])
273275
parameters.append('-isysroot')
274276
parameters.append(sysroot_dir)
277+
elif platform.system() == 'Windows':
278+
if 'LIBCLANG_PATH' in os.environ:
279+
library_file = os.environ['LIBCLANG_PATH']
280+
if os.path.isfile(library_file):
281+
cindex.Config.set_library_file(library_file)
282+
else:
283+
raise FileNotFoundError("Failed to find libclang.dll! "
284+
"Set the LIBCLANG_PATH environment variable to provide a path to it.")
285+
else:
286+
library_file = ctypes.util.find_library('libclang.dll')
287+
if library_file is not None:
288+
cindex.Config.set_library_file(library_file)
275289
elif platform.system() == 'Linux':
276290
# cython.util.find_library does not find `libclang` for all clang
277291
# versions and distributions. LLVM switched to a monolithical setup

0 commit comments

Comments
 (0)