Skip to content

Commit 088596d

Browse files
authored
feat: clean up and update to pybind11 2.6.0 (#28)
* feat: update to pybind11 2.6.0 * fix: try to support Windows * fix: try to use compiler discovery * wip: try to fix win issue * wip: try to fix win issue 2 * fix: use normal generator on Windows * fix: conda issue * fix: proper support for plat * fix: travis/appveyor from python_example * docs: update README * style: add style checking * docs: more notes in the README * style: pre-commit check * fix: drop a few unneeded things * fix: some review points from @YannickJadoul * fix: review points from @HDembinski * fix: support self.parallel and other generators * fix: support Python 2 again * fix: describe error code purpose and drop an extra * fix: only require ninja on unix * fix: simplify parallel handling
1 parent 11a6440 commit 088596d

21 files changed

+666
-262
lines changed

.appveyor.yml

+13-23
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,28 @@
11
version: '{build}'
2-
image: Visual Studio 2017
2+
image: Visual Studio 2015
33
platform:
44
- x86
55
- x64
66
environment:
7+
global:
8+
DISTUTILS_USE_SDK: 1
9+
PYTHONWARNINGS: ignore:DEPRECATION
10+
MSSdk: 1
711
matrix:
812
- PYTHON: 27
913
- PYTHON: 36
10-
- CONDA: 27
11-
- CONDA: 36
1214
install:
15+
- cmd: '"%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM%'
1316
- ps: |
1417
git submodule update -q --init --recursive
15-
if ($env:PYTHON) {
16-
if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" }
17-
$env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH"
18-
pip install --disable-pip-version-check --user --upgrade pip setuptools
19-
} elseif ($env:CONDA) {
20-
if ($env:CONDA -eq "27") { $env:CONDA = "" }
21-
if ($env:PLATFORM -eq "x64") { $env:CONDA = "$env:CONDA-x64" }
22-
$env:PATH = "C:\Miniconda$env:CONDA\;C:\Miniconda$env:CONDA\Scripts\;$env:PATH"
23-
conda config --set always_yes yes --set changeps1 no
24-
conda config --add channels conda-forge
25-
conda update -q conda
26-
conda install -q conda-build
27-
}
18+
if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" }
19+
$env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH"
20+
python -m pip install --disable-pip-version-check --upgrade --no-warn-script-location pip build
2821
build_script:
2922
- ps: |
30-
if ($env:PYTHON) {
31-
python setup.py sdist
32-
pip install --verbose dist\cmake_example-0.0.1.tar.gz
33-
} else {
34-
conda build conda.recipe
35-
conda install --use-local cmake_example
36-
}
23+
python -m build -s
24+
cd dist
25+
python -m pip install --verbose cmake_example-0.0.1.tar.gz
26+
cd ..
3727
test_script:
3828
- ps: python tests\test.py

.github/workflows/conda.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Conda
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
platform: [ubuntu-latest, windows-2016, macos-latest]
16+
python-version: ["3.6", "3.8"]
17+
18+
runs-on: ${{ matrix.platform }}
19+
20+
# The setup-miniconda action needs this to activate miniconda
21+
defaults:
22+
run:
23+
shell: "bash -l {0}"
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
with:
28+
submodules: true
29+
30+
- name: Get conda
31+
uses: conda-incubator/[email protected]
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
channels: conda-forge
35+
channel-priority: strict
36+
37+
- name: Prepare
38+
run: conda install conda-build conda-verify
39+
40+
- name: Build
41+
run: conda build conda.recipe
42+
43+
- name: Install
44+
run: conda install -c ${CONDA_PREFIX}/conda-bld/ cmake_example
45+
46+
- name: Test
47+
run: python tests/test.py

.github/workflows/format.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This is a format job. Pre-commit has a first-party GitHub action, so we use
2+
# that: https://github.com/pre-commit/action
3+
4+
name: Format
5+
6+
on:
7+
workflow_dispatch:
8+
pull_request:
9+
push:
10+
branches:
11+
- master
12+
13+
jobs:
14+
pre-commit:
15+
name: Format
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: actions/setup-python@v2
20+
- uses: pre-commit/[email protected]

.github/workflows/pip.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Pip
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
10+
jobs:
11+
build:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
platform: [windows-latest, macos-latest, ubuntu-latest]
16+
python-version: ["2.7", "3.5", "3.8", "3.9"]
17+
18+
runs-on: ${{ matrix.platform }}
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
with:
23+
submodules: true
24+
25+
- uses: actions/setup-python@v2
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Add requirements
30+
run: python -m pip install --upgrade wheel setuptools
31+
32+
# Eventually Microsoft might have an action for setting up
33+
# MSVC, but for now, this action works:
34+
- name: Prepare compiler environment for Windows 🐍 2.7
35+
if: matrix.python-version == 2.7 && runner.os == 'Windows'
36+
uses: ilammy/msvc-dev-cmd@v1
37+
with:
38+
arch: x64
39+
40+
# This makes two environment variables available in the following step(s)
41+
- name: Set Windows 🐍 2.7 environment variables
42+
if: matrix.python-version == 2.7 && runner.os == 'Windows'
43+
shell: bash
44+
run: |
45+
echo "DISTUTILS_USE_SDK=1" >> $GITHUB_ENV
46+
echo "MSSdk=1" >> $GITHUB_ENV
47+
48+
- name: Build and install
49+
run: pip install --verbose .
50+
51+
- name: Test
52+
run: python tests/test.py

.github/workflows/wheels.yml

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Wheels
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
release:
10+
types:
11+
- published
12+
13+
env:
14+
CIBW_TEST_COMMAND: python {project}/tests/test.py
15+
16+
17+
jobs:
18+
build_sdist:
19+
name: Build SDist
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
with:
24+
submodules: true
25+
26+
- uses: actions/setup-python@v2
27+
28+
- name: Install deps
29+
run: python -m pip install twine build
30+
31+
- name: Build SDist
32+
run: python -m build -s
33+
34+
- name: Check metadata
35+
run: twine check dist/*
36+
37+
- uses: actions/upload-artifact@v2
38+
with:
39+
path: dist/*.tar.gz
40+
41+
42+
build_wheels:
43+
name: Wheels on ${{ matrix.os }}
44+
runs-on: ${{ matrix.os }}
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
os: [ubuntu-latest, windows-latest, macos-latest]
49+
50+
steps:
51+
- uses: actions/checkout@v2
52+
with:
53+
submodules: true
54+
55+
- uses: actions/setup-python@v2
56+
57+
- name: Install cibuildwheel
58+
run: python -m pip install cibuildwheel==1.6.3
59+
60+
- name: Build wheel
61+
run: python -m cibuildwheel --output-dir wheelhouse
62+
env:
63+
# Python 2.7 on Windows requires a workaround for C++11 support,
64+
# built separately below
65+
CIBW_SKIP: cp27-win*
66+
67+
- name: Show files
68+
run: ls -lh wheelhouse
69+
shell: bash
70+
71+
- name: Verify clean directory
72+
run: git diff --exit-code
73+
shell: bash
74+
75+
- name: Upload wheels
76+
uses: actions/upload-artifact@v2
77+
with:
78+
path: wheelhouse/*.whl
79+
80+
81+
# Windows 2.7 (requires workaround for MSVC 2008 replacement)
82+
build_win27_wheels:
83+
name: Py 2.7 wheels on Windows
84+
runs-on: windows-latest
85+
86+
steps:
87+
- uses: actions/checkout@v2
88+
with:
89+
submodules: true
90+
91+
- uses: actions/setup-python@v2
92+
93+
- name: Install cibuildwheel
94+
run: python -m pip install cibuildwheel==1.6.3
95+
96+
- uses: ilammy/msvc-dev-cmd@v1
97+
98+
- name: Build 64-bit wheel
99+
run: python -m cibuildwheel --output-dir wheelhouse
100+
env:
101+
CIBW_BUILD: cp27-win_amd64
102+
DISTUTILS_USE_SDK: 1
103+
MSSdk: 1
104+
105+
- uses: ilammy/msvc-dev-cmd@v1
106+
with:
107+
arch: x86
108+
109+
- name: Build 32-bit wheel
110+
run: python -m cibuildwheel --output-dir wheelhouse
111+
env:
112+
CIBW_BUILD: cp27-win32
113+
DISTUTILS_USE_SDK: 1
114+
MSSdk: 1
115+
116+
- name: Show files
117+
run: ls -lh wheelhouse
118+
shell: bash
119+
120+
- name: Verify clean directory
121+
run: git diff --exit-code
122+
shell: bash
123+
124+
- uses: actions/upload-artifact@v2
125+
with:
126+
path: wheelhouse/*.whl
127+
128+
129+
upload_all:
130+
name: Upload if release
131+
needs: [build_wheels, build_win27_wheels, build_sdist]
132+
runs-on: ubuntu-latest
133+
if: github.event_name == 'release' && github.event.action == 'published'
134+
135+
steps:
136+
- uses: actions/setup-python@v2
137+
138+
- uses: actions/download-artifact@v2
139+
with:
140+
name: artifact
141+
path: dist
142+
143+
- uses: pypa/[email protected]
144+
with:
145+
user: __token__
146+
password: ${{ secrets.pypi_password }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ _generate/
55
*.so
66
*.py[cod]
77
*.egg-info
8+
*env*

.pre-commit-config.yaml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# To use:
2+
#
3+
# pre-commit run -a
4+
#
5+
# Or:
6+
#
7+
# pre-commit install # (runs every time you commit in git)
8+
#
9+
# To update this file:
10+
#
11+
# pre-commit autoupdate
12+
#
13+
# See https://github.com/pre-commit/pre-commit
14+
15+
repos:
16+
# Standard hooks
17+
- repo: https://github.com/pre-commit/pre-commit-hooks
18+
rev: v3.2.0
19+
hooks:
20+
- id: check-added-large-files
21+
- id: check-case-conflict
22+
- id: check-merge-conflict
23+
- id: check-symlinks
24+
- id: check-yaml
25+
- id: debug-statements
26+
- id: end-of-file-fixer
27+
- id: mixed-line-ending
28+
- id: requirements-txt-fixer
29+
- id: trailing-whitespace
30+
- id: fix-encoding-pragma
31+
32+
# Black, the code formatter, natively supports pre-commit
33+
- repo: https://github.com/psf/black
34+
rev: 20.8b1
35+
hooks:
36+
- id: black
37+
exclude: ^docs/conf.py$
38+
39+
# Changes tabs to spaces
40+
- repo: https://github.com/Lucas-C/pre-commit-hooks
41+
rev: v1.1.9
42+
hooks:
43+
- id: remove-tabs
44+
45+
- repo: https://gitlab.com/pycqa/flake8
46+
rev: 3.8.3
47+
hooks:
48+
- id: flake8
49+
additional_dependencies: [flake8-bugbear]

0 commit comments

Comments
 (0)