Skip to content

Commit 5a19e3e

Browse files
authored
chore: drop Python 2, require Python 3.6+ (#91)
* chore: drop Python 2 support, require 3.6+ * style: run pre-commit
1 parent fdc222c commit 5a19e3e

File tree

11 files changed

+326
-344
lines changed

11 files changed

+326
-344
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%'

.github/workflows/conda.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
with:
3131
python-version: ${{ matrix.python-version }}
3232
channels: conda-forge
33-
33+
3434
- name: Prepare
3535
run: conda install conda-build conda-verify
3636

.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.10"]
1717

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

@@ -27,22 +27,6 @@ jobs:
2727
- name: Add requirements
2828
run: python -m pip install --upgrade wheel setuptools
2929

30-
# Eventually Microsoft might have an action for setting up
31-
# MSVC, but for now, this action works:
32-
- name: Prepare compiler environment for Windows 🐍 2.7
33-
if: matrix.python-version == 2.7 && runner.os == 'Windows'
34-
uses: ilammy/msvc-dev-cmd@v1
35-
with:
36-
arch: x64
37-
38-
# This makes two environment variables available in the following step(s)
39-
- name: Set Windows 🐍 2.7 environment variables
40-
if: matrix.python-version == 2.7 && runner.os == 'Windows'
41-
shell: bash
42-
run: |
43-
echo "DISTUTILS_USE_SDK=1" >> $GITHUB_ENV
44-
echo "MSSdk=1" >> $GITHUB_ENV
45-
4630
- name: Build and install
4731
run: pip install --verbose .
4832

.github/workflows/wheels.yml

+3-50
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ on:
1010
types:
1111
- published
1212

13-
env:
14-
CIBW_TEST_COMMAND: python {project}/tests/test.py
15-
CIBW_ARCHS_MACOS: auto universal2
16-
CIBW_TEST_SKIP: "*universal2:arm64"
17-
18-
1913
jobs:
2014
build_sdist:
2115
name: Build SDist
@@ -45,11 +39,9 @@ jobs:
4539
steps:
4640
- uses: actions/checkout@v2
4741

48-
- uses: pypa/cibuildwheel@v1.12.0
42+
- uses: pypa/cibuildwheel@v2.2.0
4943
env:
50-
# Python 2.7 on Windows requires a workaround for C++11 support,
51-
# built separately below
52-
CIBW_SKIP: cp27-win*
44+
CIBW_ARCHS_MACOS: auto universal2
5345

5446
- name: Verify clean directory
5547
run: git diff --exit-code
@@ -61,48 +53,9 @@ jobs:
6153
path: wheelhouse/*.whl
6254

6355

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

.pre-commit-config.yaml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
ci:
16+
autoupdate_commit_msg: "chore: update pre-commit hooks"
17+
autofix_commit_msg: "style: pre-commit fixes"
18+
19+
repos:
20+
# Standard hooks
21+
- repo: https://github.com/pre-commit/pre-commit-hooks
22+
rev: v4.0.1
23+
hooks:
24+
- id: check-added-large-files
25+
- id: check-case-conflict
26+
- id: check-merge-conflict
27+
- id: check-symlinks
28+
- id: check-yaml
29+
exclude: ^conda\.recipe/meta\.yaml$
30+
- id: debug-statements
31+
- id: end-of-file-fixer
32+
- id: mixed-line-ending
33+
- id: requirements-txt-fixer
34+
- id: trailing-whitespace
35+
36+
# Black, the code formatter, natively supports pre-commit
37+
- repo: https://github.com/psf/black
38+
rev: 21.9b0
39+
hooks:
40+
- id: black
41+
files: ^(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"]
55+
56+
# Changes tabs to spaces
57+
- repo: https://github.com/Lucas-C/pre-commit-hooks
58+
rev: v1.1.10
59+
hooks:
60+
- id: remove-tabs
61+
62+
# Suggested hook if you add a .clang-format file
63+
# - repo: https://github.com/pre-commit/mirrors-clang-format
64+
# rev: v13.0.0
65+
# hooks:
66+
# - id: clang-format

README.md

+3-32
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,21 @@ python_example
2121
[actions-wheels-link]: https://github.com/pybind/python_example/actions?query=workflow%3AWheels
2222
[actions-wheels-badge]: https://github.com/pybind/python_example/workflows/Wheels/badge.svg
2323
[travis-link]: https://travis-ci.org/pybind/python_example
24-
[travis-badge]: https://travis-ci.org/pybind/python_example.svg?branch=master&status=passed
24+
[travis-badge]: https://travis-ci.org/pybind/python_example.svg?branch=master&status=passed
2525
[appveyor-link]: https://ci.appveyor.com/project/wjakob/python-example
2626
<!-- TODO: get a real badge link for appveyor -->
2727
[appveyor-badge]: https://travis-ci.org/pybind/python_example.svg?branch=master&status=passed
2828

2929
An example project built with [pybind11](https://github.com/pybind/pybind11).
30+
This requires Python 3.6+; for older versions of Python, check the commit
31+
history.
3032

3133
Installation
3234
------------
3335

34-
**On Unix (Linux, OS X)**
35-
3636
- clone this repository
3737
- `pip install ./python_example`
3838

39-
**On Windows (Requires Visual Studio 2015)**
40-
41-
- For Python 3.5+:
42-
- clone this repository
43-
- `pip install ./python_example`
44-
- For Python 2.7:
45-
46-
Pybind11 requires a C++11 compliant compiler (i.e. Visual Studio 2015 on
47-
Windows). Running a regular `pip install` command will detect the version
48-
of the compiler used to build Python and attempt to build the extension
49-
with it. We must force the use of Visual Studio 2015.
50-
51-
- clone this repository
52-
- `"%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x64`
53-
- `set DISTUTILS_USE_SDK=1`
54-
- `set MSSdk=1`
55-
- `pip install ./python_example`
56-
57-
Note that this requires the user building `python_example` to have registry edition
58-
rights on the machine, to be able to run the `vcvarsall.bat` script.
59-
6039
CI Examples
6140
-----------
6241

@@ -65,14 +44,6 @@ binary "wheels" for all platforms is illustrated in the "wheels.yml" file,
6544
using [`cibuildwheel`][]. You can also see a basic recipe for building and
6645
testing in `pip.yml`, and `conda.yml` has an example of a conda recipe build.
6746

68-
Windows Python 2.7 runtime requirements
69-
----------------------------
70-
71-
On Windows, the Visual C++ 2015 redistributable packages are a runtime
72-
requirement for this project if you build for Python 2.7 (newer versions of
73-
Python include this redistributable). It can be found
74-
[here](https://www.microsoft.com/en-us/download/details.aspx?id=48145).
75-
7647

7748
Building the documentation
7849
--------------------------

0 commit comments

Comments
 (0)