Skip to content

Commit 2440893

Browse files
authored
chore: require Python 3.6+ (#64)
* chore: bump to pybind11 2.8.0 * chore: drop Python 2 support, require 3.6+ * style: run pre-commit * refactor: clean up settings a bit, require PyTest 6+
1 parent 31bc276 commit 2440893

13 files changed

+85
-134
lines changed

.appveyor.yml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ environment:
99
PYTHONWARNINGS: ignore:DEPRECATION
1010
MSSdk: 1
1111
matrix:
12-
- PYTHON: 27
1312
- PYTHON: 36
1413
install:
1514
- cmd: '"%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM%'

setup.cfg renamed to .flake8

-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,3 @@
33
ignore = E203, E231, E501, W503, B950
44
select = C,E,F,W,B,B9
55
exclude = docs/conf.py
6-
7-
[tool:pytest]
8-
addopts = -ra
9-
testpaths =
10-
tests

.github/workflows/pip.yml

+1-17
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
platform: [windows-latest, macos-latest, ubuntu-latest]
16-
python-version: ["2.7", "3.5", "3.8", "3.9"]
16+
python-version: ["3.6", "3.8", "3.10"]
1717

1818
runs-on: ${{ matrix.platform }}
1919

@@ -29,22 +29,6 @@ jobs:
2929
- name: Add requirements
3030
run: python -m pip install --upgrade wheel setuptools
3131

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-
4832
- name: Build and install
4933
run: pip install --verbose .[test]
5034

.github/workflows/wheels.yml

+2-52
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ on:
1010
types:
1111
- published
1212

13-
env:
14-
CIBW_TEST_COMMAND: pytest {project}/tests
15-
CIBW_TEST_EXTRAS: test
16-
17-
1813
jobs:
1914
build_sdist:
2015
name: Build SDist
@@ -48,15 +43,9 @@ jobs:
4843
with:
4944
submodules: true
5045

51-
- uses: pypa/cibuildwheel@v1.12.0
46+
- uses: pypa/cibuildwheel@v2.2.0
5247
env:
53-
# Python 2.7 on Windows requires a workaround for C++11 support,
54-
# built separately below
55-
CIBW_SKIP: cp27-win*
5648
CIBW_ARCHS_MACOS: auto universal2
57-
CIBW_TEST_SKIP: "*universal2:arm64"
58-
CIBW_TEST_EXTRAS: test
59-
CIBW_TEST_COMMAND: pytest {project}/tests
6049

6150
- name: Verify clean directory
6251
run: git diff --exit-code
@@ -68,48 +57,9 @@ jobs:
6857
path: wheelhouse/*.whl
6958

7059

71-
# Windows 2.7 (requires workaround for MSVC 2008 replacement)
72-
build_win27_wheels:
73-
name: Py 2.7 wheels on Windows
74-
runs-on: windows-latest
75-
76-
steps:
77-
- uses: actions/checkout@v2
78-
with:
79-
submodules: true
80-
81-
- uses: ilammy/msvc-dev-cmd@v1
82-
83-
- name: Build 64-bit wheel
84-
uses: pypa/[email protected]
85-
env:
86-
CIBW_BUILD: cp27-win_amd64
87-
DISTUTILS_USE_SDK: 1
88-
MSSdk: 1
89-
90-
- uses: ilammy/msvc-dev-cmd@v1
91-
with:
92-
arch: x86
93-
94-
- name: Build 32-bit wheel
95-
uses: pypa/[email protected]
96-
env:
97-
CIBW_BUILD: cp27-win32
98-
DISTUTILS_USE_SDK: 1
99-
MSSdk: 1
100-
101-
- name: Verify clean directory
102-
run: git diff --exit-code
103-
shell: bash
104-
105-
- uses: actions/upload-artifact@v2
106-
with:
107-
path: wheelhouse/*.whl
108-
109-
11060
upload_all:
11161
name: Upload if release
112-
needs: [build_wheels, build_win27_wheels, build_sdist]
62+
needs: [build_wheels, build_sdist]
11363
runs-on: ubuntu-latest
11464
if: github.event_name == 'release' && github.event.action == 'published'
11565

.gitmodules

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "pybind11"]
2-
path = pybind11
3-
url = https://github.com/pybind/pybind11.git
4-
branch = master
2+
path = pybind11
3+
url = https://github.com/pybind/pybind11.git
4+
branch = master

.pre-commit-config.yaml

+38-5
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,71 @@
1212
#
1313
# See https://github.com/pre-commit/pre-commit
1414

15+
ci:
16+
autoupdate_commit_msg: "chore: update pre-commit hooks"
17+
autofix_commit_msg: "style: pre-commit fixes"
18+
1519
repos:
1620
# Standard hooks
1721
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v3.2.0
22+
rev: v4.0.1
1923
hooks:
2024
- id: check-added-large-files
2125
- id: check-case-conflict
2226
- id: check-merge-conflict
2327
- id: check-symlinks
2428
- id: check-yaml
29+
exclude: ^conda\.recipe/meta\.yaml$
2530
- id: debug-statements
2631
- id: end-of-file-fixer
2732
- id: mixed-line-ending
2833
- id: requirements-txt-fixer
2934
- id: trailing-whitespace
30-
- id: fix-encoding-pragma
3135

3236
# Black, the code formatter, natively supports pre-commit
3337
- repo: https://github.com/psf/black
34-
rev: 20.8b1
38+
rev: 21.9b0
3539
hooks:
3640
- id: black
37-
exclude: ^docs/conf.py$
41+
exclude: ^(docs)
42+
43+
# Sort your imports in a standard form
44+
- repo: https://github.com/PyCQA/isort
45+
rev: 5.9.3
46+
hooks:
47+
- id: isort
48+
49+
# Upgrade older Python syntax
50+
- repo: https://github.com/asottile/pyupgrade
51+
rev: v2.29.0
52+
hooks:
53+
- id: pyupgrade
54+
args: ["--py36-plus"]
3855

3956
# Changes tabs to spaces
4057
- repo: https://github.com/Lucas-C/pre-commit-hooks
41-
rev: v1.1.9
58+
rev: v1.1.10
4259
hooks:
4360
- id: remove-tabs
61+
exclude: ^(docs)
4462

4563
- repo: https://gitlab.com/pycqa/flake8
4664
rev: 3.8.3
4765
hooks:
4866
- id: flake8
4967
additional_dependencies: [flake8-bugbear]
68+
69+
# CMake formatting
70+
- repo: https://github.com/cheshirekow/cmake-format-precommit
71+
rev: v0.6.13
72+
hooks:
73+
- id: cmake-format
74+
additional_dependencies: [pyyaml]
75+
types: [file]
76+
files: (\.cmake|CMakeLists.txt)(.in)?$
77+
78+
# Suggested hook if you add a .clang-format file
79+
# - repo: https://github.com/pre-commit/mirrors-clang-format
80+
# rev: v13.0.0
81+
# hooks:
82+
# - id: clang-format

CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ pybind11_add_module(cmake_example src/main.cpp)
66

77
# EXAMPLE_VERSION_INFO is defined by setup.py and passed into the C++ code as a
88
# define (VERSION_INFO) here.
9-
target_compile_definitions(cmake_example PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})
9+
target_compile_definitions(cmake_example
10+
PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})

README.md

+3-25
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,15 @@ existing CMake project structure. This is in many cases superseded by
2929
packages to be driven from CMake. However, there are still cases where you
3030
might want full control over the CMake run; and both of these approaches have
3131
some trade-offs not present in a pure setuptools build (see
32-
[`python_example`](https://github.com/pybind/python_example))
32+
[`python_example`](https://github.com/pybind/python_example)). Python 3.6+ required;
33+
see the commit history for older versions of Python.
3334

3435
## Prerequisites
3536

36-
**On Unix (Linux, OS X)**
37-
3837
* A compiler with C++11 support
39-
* CMake >= 3.4 or Pip 10+
38+
* Pip 10+ or CMake >= 3.4 (or 3.8+ on Windows, which was the first version to support VS 2015)
4039
* Ninja or Pip 10+
4140

42-
**On Windows**
43-
44-
* Visual Studio 2015 or newer (required for all Python versions, see notes below)
45-
* CMake >= 3.8 (3.8 was the first version to support VS 2015) or Pip 10+
46-
4741

4842
## Installation
4943

@@ -59,22 +53,6 @@ With the `setup.py` file included in this example, the `pip install` command wil
5953
invoke CMake and build the pybind11 module as specified in `CMakeLists.txt`.
6054

6155

62-
## Special notes for Windows
63-
64-
**Compiler requirements**
65-
66-
Pybind11 requires a C++11 compliant compiler, i.e Visual Studio 2015 on Windows.
67-
This applies to all Python versions, including 2.7. Unlike regular C extension
68-
modules, it's perfectly fine to compile a pybind11 module with a VS version newer
69-
than the target Python's VS version. See the [FAQ] for more details.
70-
71-
**Runtime requirements**
72-
73-
The Visual C++ 2015 redistributable packages are a runtime requirement for this
74-
project. It can be found [here][vs2015_runtime]. If you use the Anaconda Python
75-
distribution, you can add `vs2015_runtime` as a platform-dependent runtime
76-
requirement for you package: see the `conda.recipe/meta.yaml` file in this example.
77-
7856

7957
## Building the documentation
8058

docs/conf.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# python_exameple documentation build configuration file, created by
43
# sphinx-quickstart on Fri Feb 26 00:29:33 2016.
@@ -12,8 +11,8 @@
1211
# All configuration values have a default; values that are commented out
1312
# serve to show the default.
1413

15-
import sys
1614
import os
15+
import sys
1716

1817
# If extensions (or modules to document with autodoc) are in another directory,
1918
# add these directories to sys.path here. If the directory is relative to the
@@ -52,18 +51,18 @@
5251
master_doc = 'index'
5352

5453
# General information about the project.
55-
project = u'cmake_example'
56-
copyright = u'2016, Sylvain Corlay'
57-
author = u'Sylvain Corlay'
54+
project = 'cmake_example'
55+
copyright = '2016, Sylvain Corlay'
56+
author = 'Sylvain Corlay'
5857

5958
# The version info for the project you're documenting, acts as replacement for
6059
# |version| and |release|, also used in various other places throughout the
6160
# built documents.
6261
#
6362
# The short X.Y version.
64-
version = u'0.0.1'
63+
version = '0.0.1'
6564
# The full version, including alpha/beta/rc tags.
66-
release = u'0.0.1'
65+
release = '0.0.1'
6766

6867
# The language for content autogenerated by Sphinx. Refer to documentation
6968
# for a list of supported languages.
@@ -228,8 +227,8 @@
228227
# (source start file, target name, title,
229228
# author, documentclass [howto, manual, or own class]).
230229
latex_documents = [
231-
(master_doc, 'cmake_example.tex', u'cmake_example Documentation',
232-
u'Sylvain Corlay', 'manual'),
230+
(master_doc, 'cmake_example.tex', 'cmake_example Documentation',
231+
'Sylvain Corlay', 'manual'),
233232
]
234233

235234
# The name of an image file (relative to this directory) to place at the top of
@@ -258,7 +257,7 @@
258257
# One entry per manual page. List of tuples
259258
# (source start file, name, description, authors, manual section).
260259
man_pages = [
261-
(master_doc, 'cmake_example', u'cmake_example Documentation',
260+
(master_doc, 'cmake_example', 'cmake_example Documentation',
262261
[author], 1)
263262
]
264263

@@ -272,7 +271,7 @@
272271
# (source start file, target name, title, author,
273272
# dir menu entry, description, category)
274273
texinfo_documents = [
275-
(master_doc, 'cmake_example', u'cmake_example Documentation',
274+
(master_doc, 'cmake_example', 'cmake_example Documentation',
276275
author, 'cmake_example', 'One line description of project.',
277276
'Miscellaneous'),
278277
]

pybind11

Submodule pybind11 updated 143 files

pyproject.toml

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22
requires = [
33
"setuptools>=42",
44
"wheel",
5-
"ninja; sys_platform != 'win32' and platform_machine != 'arm64'",
5+
"ninja",
66
"cmake>=3.12",
77
]
88
build-backend = "setuptools.build_meta"
9+
10+
[tool.isort]
11+
profile = "black"
12+
13+
[tool.pytest.ini_options]
14+
minversion = "6.0"
15+
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
16+
xfail_strict = true
17+
filterwarnings = ["error"]
18+
testpaths = ["tests"]
19+
20+
[tool.cibuildwheel]
21+
test-command = "pytest {project}/tests"
22+
test-extras = ["test"]
23+
test-skip = ["*universal2:arm64"]

0 commit comments

Comments
 (0)